ComfyUI Node

Pto Simple

Pto Simple does W -= lr * G

By HowToSD·Created about a year ago·Updated about a year ago· 7
Pto Simple
  • model
  • PTOPTIMIZER
learning_rate0

PtoSimple is the most basic optimizer the pack ships: it implements exactly one update rule, W -= lr * G - each weight takes a step in the direction opposite its gradient, scaled by the learning rate. No momentum, no adaptive scaling, no weight decay. It's not a node you'd ship to production training, but it's the single best teaching tool in the pack, and the simple_linear_regression_train.json example uses it to make the whole training loop legible end to end.

Why you'd reach for it

If you've ever looked at Adam's beta1/beta2 and wondered what's actually happening under the hood, this node is the antidote. Because it strips away everything except the one update rule, a working PtoSimple training loop is the clearest possible picture of what "training a neural net" means: compute loss, backprop to get gradients, nudge every weight in the downhill direction, repeat. It's also a useful baseline - if your problem can't be trained with plain gradient descent, you'll learn that fast here, before you spend an afternoon wrestling an optimizer that's masking the real issue.

How it works

The pack's source implements its own SimpleOptimizer subclass that performs, in effect, param -= lr * param.grad for every parameter on each step(). Two inputs, both self-explanatory:

  • model (PTMODEL) - the model whose weights get updated. Wire any model node's output here.
  • learning_rate - the step size. There's no adaptation anywhere in this optimizer, so this is the only knob you have, and it's brutally sensitive: too small and training crawls, too big and loss explodes. Start at 0.001 and be ready to move it.

Output is a single PTOPTIMIZER, feeding into a training node like Pt Train Regression Model (that's the pair used in the linear-regression example) and optionally into an LR scheduler.

What to know before you use it

This is a "look, it works" optimizer, not a "best" one. It converges fine on simple problems - linear regression, small well-conditioned models - and that's exactly what it's for. On anything with real depth or curvature, Adam or AdamW will run circles around it, because they adapt the step size per-parameter while this node can't. Also note that like every optimizer node here, it binds to the model you connect when it runs - swap the model after and you're stepping an orphaned optimizer. If you're using this to learn, wire the graph up, run it, and watch the loss; that's the intended experience.

Installing it

Part of ComfyUI-Pt-Wrapper (HowToSD's no-code PyTorch pack, a spin-off of ComfyUI-Data-Analysis). ComfyUI Manager → search "ComfyUI-Pt-Wrapper", or:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper

Restart after; first boot is slow while pandas, scikit-learn, transformers, sentencepiece, peft and friends install. No model downloads needed.

CategoryTraining

Inputs (2)

NameTypeDefaultDescription
modelPTMODEL
learning_rateFLOAT01e-10–1

Outputs (1)

NameTypeDescription
PTOPTIMIZERPTOPTIMIZER