Adjust PE [Sweetspot] ππ π
Remapping AnimateDiff's positional encoding around its trained sweet spot
- prev_pe_adjust
- PE_ADJUST
Motion modules weren't trained uniformly across every possible context length - there's usually a length they saw the most and perform best at, a "sweet spot." Adjust PE [Sweetspot] is the AnimateDiff-Evolved node that lets you tell the model "treat this length as your sweet spot" instead of accepting whatever the checkpoint shipped with, which is the gentler of the two automatic PE-remapping strategies (the other being Full Stretch).
What it's actually doing
AnimateDiff's temporal attention layers rely on positional encoding to know where each frame sits in the sequence. Push a context length past what the module was trained on and that encoding starts extrapolating into positions it's never seen - a real contributor to the coherence loss and motion smear people run into on long, high-context generations. Full Stretch handles this by proportionally stretching the whole trained range across your target length. Sweetspot takes a different angle: rather than reshaping everything uniformly, it works around the specific length the model performs best at, remapping that sweet spot to a new one. That distinction matters in practice - the two nodes are alternative strategies for the same problem, not interchangeable settings, and which one gives you better output depends on your specific motion model and how far you're pushing it.
Inputs and output
sweetspot(int, default 16) - the context length you're telling the node to treat as the model's known-good sweet spot. 16 is the sane default for the original SD 1.5 motion modules; if you're on a v3 model or a different architecture, you may want a different starting point.new_sweetspot(int, default 16) - the length you actually want the model to behave well at.print_adjustment(bool, off by default) - logs the computed values so you can see what the remapping is actually doing instead of guessing from the output video alone.prev_pe_adjust(optional,PE_ADJUST) - chain onto a previous PE adjustment if you're stacking effects.- Output:
PE_ADJUST- a settings object, not a visible result. Wire it into whichever node in your graph collects per-model AnimateDiff settings, which attaches to your motion model loader.
Installing the pack
ComfyUI Manager: search AnimateDiff Evolved, confirm Kosinkadink as the author, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved
restart. This node is pure settings and needs no model file of its own, but the workflow around it does - download at least one motion module (mm_sd_v15_v2, v3_sd15_mm, and friends) into ComfyUI/models/animatediff_models before any of this matters.
Common issues
You don't know what your model's real sweet spot is. Neither do most people who use this node - the pack doesn't expose it as a published number per model, and the sensible way to find it is empirically: leave sweetspot/new_sweetspot at the same value (a no-op) and dial sweetspot alone while watching where quality holds up longest.
Setting sweetspot and new_sweetspot to the same number does nothing. By design - that's a no-op mapping. If you're not seeing any effect, check that the two values actually differ.
This isn't fixing your seams. Sweetspot addresses positional-encoding quality inside a single context window, not the visible jump or morph where sliding-context windows stitch together. If your artifacts are at the window boundaries rather than a general softness/coherence loss across the whole clip, the fix is in Context Options (overlap and schedule), not here.
You're reaching for this too early. If your context length is already near the model's native training length, you likely don't need PE adjustment at all. This is a tool for when you're already pushing past that and Context Options tuning alone hasn't been enough.
KB gap: what each motion module's actual trained sweet-spot length is isn't documented anywhere we have - worth capturing the pack's own node docs (documentation/nodes on GitHub) next time this comes up, since it would turn this from an empirical-tuning node into one with a real starting recommendation.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| sweetspot | INT | 160β9007199254740991 | β |
| new_sweetspot | INT | 160β9007199254740991 | β |
| print_adjustment | BOOLEAN | false | β |
| prev_pe_adjustopt | PE_ADJUST | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| PE_ADJUST | PE_ADJUST | β |