Momentum Guidance
EMA-smoothed guidance for flow models
- model
- MODEL
Most of the guidance tricks in this pack are built around SD1.5/SDXL's UNet architecture - self-attention, discrete blocks, the works. Momentum Guidance is one of the two nodes here explicitly called out as not limited to that: it's from "Momentum Guidance: Plug-and-Play Guidance for Flow Models," a 2026 paper, and it's aimed at flow-matching architectures rather than the classic SD lineage.
The field names are the tell for how it works: momentum and ema are straight out of optimizer vocabulary. Rather than applying guidance fresh at every single step based only on that step's prediction, MG smooths the guidance direction across steps using an exponential moving average - the same trick momentum-based optimizers use to avoid getting knocked around by noisy per-step gradients. The idea is a steadier guidance signal step to step, instead of one that jitters with whatever that particular denoising step happened to predict.
The inputs that matter
This is a two-knob node, and unusually for this pack, both fields carry tooltips written directly by the author:
momentum(default 0.5) - described as "controls the scale/strength of Momentum Guidance: setting value to 0.0 completely disables MG. 0.5 should be optimal for MG+CFG combination in most scenarios." So 0 is your clean off-switch for isolating whether MG is doing anything at all, and the default is already the author's recommended starting point when you're running it alongside normal CFG.ema(default 0.6) - the tooltip is explicit about tuning order: "consider tuning this before tuningmomentum." Worth taking at face value - if MG isn't behaving the way you expect, adjustemafirst rather than immediately reaching formomentum.
Output is a MODEL, same pattern as the rest of the pack - feed it into your KSampler.
How to install it
ComfyUI Manager: search "Perturbed-Attention Guidance" (this ships as part of that pack). Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/pamparamm/sd-perturbed-attention
Restart. No model downloads, no additional dependencies.
Common issues & troubleshooting
This is a very fresh node - the underlying paper is from 2026 and there's essentially no community usage trail yet, so treat anything beyond the author's own tooltips as your own experimentation rather than settled advice.
Unsure it's doing anything. Set momentum to 0 as a clean baseline (the tooltip confirms this fully disables it), generate, then bring it back to 0.5 and compare on a fixed seed. That isolates the effect cleanly since there's no other on/off switch on this node.
Tuning feels unstable. Follow the tooltip's own ordering - dial in ema before touching momentum. Optimizer-style EMA parameters are usually more sensitive than the momentum term itself, so getting ema roughly right first will make momentum behave more predictably when you get to it.
Using it on SD1.5/SDXL. Nothing stops you, but this is explicitly the one node in the pack pitched at flow-matching models rather than the classic UNet lineage. If you're getting inconsistent results on an SD1.5/SDXL checkpoint, that's plausibly why - you're outside the regime the paper was built for, and PAG or SEG are the better-trodden path there instead.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| momentum | FLOAT | 0.500–100 | Momentum (alpha) hyperparameter. Controls the scale/strength of Momentum Guidance: setting value to 0.0 completely disables MG. 0.5 should be optimal for MG+CFG combination in most scenarios |
| ema | FLOAT | 0.600–1 | EMA (beta) hyperparameter. Consider tuning this before tuning `momentum` |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |