Nodes/ComfyUI-Pt-Wrapper/Pto Lr Scheduler Reduce On Plateau
ComfyUI Node

Pto Lr Scheduler Reduce On Plateau

Pto Lr Scheduler Reduce On Plateau lowers the rate only when progress stalls

By HowToSD·Created about a year ago·Updated about a year ago· 7
Pto Lr Scheduler Reduce On Plateau
  • optimizer
  • PTLRSCHEDULER
grace_period10
gamma0

PtoLrSchedulerReduceOnPlateau is the "leave me alone, I'll react when I'm stuck" scheduler. Instead of decaying the learning rate on a fixed schedule like StepLR or cosine annealing, it watches validation loss, and only when that loss has stopped improving for a while does it multiply the learning rate down by gamma. It's the scheduler in the pack's rnn_classification.json workflow, and it's the right choice whenever you don't know in advance how long training will take - you can just let it run and it paces itself.

Why you'd reach for it

Fixed schedulers assume you know your epoch count. Real training often doesn't: the RNN in the example may converge in 15 epochs or 40 depending on initialization and data. Reduce-on-plateau removes that assumption. The mechanism (PyTorch's ReduceLROnPlateau in mode="min"): every epoch, the trainer reports the validation loss; if it hasn't decreased for grace_period epochs, the learning rate is multiplied by gamma (e.g. 0.5 → learning rate halves). This keeps repeating, so a stuck model gently sheds learning rate until it can settle into a minimum. It's the set-and-forget scheduler - great for long training runs on a small GPU where you'd rather not babysit.

Inputs

  • optimizer (PTOPTIMIZER) - the optimizer to schedule. Any of the pack's Pto* optimizers.
  • grace_period - how many epochs of no improvement before the rate drops. Maps to PyTorch's patience. Too small and you'll drop the rate while training is still warming up; too large and you waste epochs sitting on a plateau. 10 (the default) is a reasonable starting point.
  • gamma - the multiplier applied to the learning rate each time the grace period is exceeded. 0.1 is the default and a common classic choice; gentler decays like 0.5 are easier on delicate models.

Output is a single PTLRSCHEDULER, wired into a training node that accepts a scheduler.

The one big caveat

This scheduler only works if your training node actually reports a validation metric to it - it can't reduce on plateau if it's never told what the loss is doing. In the pack's design the training nodes handle that plumbing (the RNN trainer feeds the val loss in), so as long as you wire it into a training node that supports schedulers, you're fine. Just don't expect this node to do anything on its own outside a training loop. And remember the ordering: model → optimizer → scheduler must all reference the same run.

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 files needed.

CategoryTraining

Inputs (3)

NameTypeDefaultDescription
optimizerPTOPTIMIZER
grace_periodINT100–100000000
gammaFLOAT00.000001–1

Outputs (1)

NameTypeDescription
PTLRSCHEDULERPTLRSCHEDULER