Nodes/AnimateDiff Evolved/ContextRef Modeβ—†Sliding πŸŽ­πŸ…πŸ…“
ComfyUI Node Runs on cloud

ContextRef Modeβ—†Sliding πŸŽ­πŸ…πŸ…“

Sliding β€” anchoring long AnimateDiff generations

By KosinkadinkΒ·Created 3 years agoΒ·Updated 8 days agoΒ· 3,519
ContextRef Modeβ—†Sliding πŸŽ­πŸ…πŸ…“
    • CONTEXTREF_MODE
    β—„sliding_width2β–Ί

    A quick word up front: this is a genuinely obscure node, even by the standards of a pack full of them. It's part of ContextRef, which the README lists under its features as "novel cross-context consistency techniques" alongside NaiveReuse - and that's about as much detail as the README itself gives. Checking the wider community for how people actually use it turns up essentially nothing; it hasn't accumulated a body of shared knowledge the way sliding context windows or Motion LoRAs have. Take what follows as a reasoned read of what it's for, not a battle-tested guide.

    The problem it's aimed at

    Sliding context windows are what let AnimateDiff-Evolved generate video far longer than a motion module's native training length (16 frames for the original SD1.5 modules): process overlapping chunks of frames rather than the whole thing at once. It works, but it has a known weakness - each window only "sees" a limited stretch of frames, so there's no true whole-video memory. Over a long generation, content can slowly drift: a character's outfit shifts, a background detail mutates, because nothing is anchoring frame 200 back to frame 1. ContextRef is AnimateDiff-Evolved's own answer to that drift, sharing some kind of reference signal across context windows rather than letting each one sample in isolation.

    What "Sliding" mode adds

    This particular node configures ContextRef's sliding mode specifically - as opposed to whatever alternative mode(s) exist elsewhere in the ContextRef submenu. The one input, sliding_width, controls how many context windows apart the reference re-anchors: a smaller width re-anchors more often (tighter consistency, more overhead), a larger one re-anchors less often (looser consistency, presumably cheaper). Output is CONTEXTREF_MODE, which plugs into the broader ContextRef/context-extras chain feeding your Context Options setup.

    The one input that matters

    • sliding_width - how many context windows between re-anchoring points, minimum 2, default 2. Given the total absence of community tuning guidance, treat the default as your starting point and adjust experimentally rather than assuming a "correct" value for your use case.

    How to install it

    Ships with the base pack - ContextRef is a built-in feature, not a separate download.

    • ComfyUI Manager - search AnimateDiff Evolved by Kosinkadink, install, restart.
    • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved, restart.
    • You need Context Options set up in your graph (the node that actually creates sliding windows) for ContextRef to have anything to operate across - this node configures a mode that plugs into that broader chain.

    Common issues & troubleshooting

    There's very little to go on here, and that's worth saying plainly. A search across community discussion for ContextRef turns up nothing - not "a little," genuinely nothing. If you're experimenting with it, you're closer to the frontier than to a documented path; keep test renders short and cheap while you find settings that work for your specific generation.

    Content still drifts over a long generation even with ContextRef enabled. Long-form consistency in a sliding-window AnimateDiff pipeline is a hard problem this feature is aimed at, not one it's guaranteed to fully solve - if drift is still bad, it's worth comparing against a run without ContextRef at all to confirm it's actually improving things for your specific workflow before spending more time tuning sliding_width.

    If long-form consistency is the actual goal and this feels too experimental, it's worth knowing the wider video-generation landscape has moved past AnimateDiff for that particular problem - newer video models handle long, coherent clips more directly. ContextRef is worth reaching for specifically if you're already committed to an AnimateDiff/SD1.5 pipeline and want to push its length further, not as a first choice for long-video work in general.

    CategoryAnimate Diff πŸŽ­πŸ…πŸ…“/context opts/context extras/contextref

    Inputs (1)

    NameTypeDefaultDescription
    sliding_widthoptINT22–9007199254740991β€”

    Outputs (1)

    NameTypeDescription
    CONTEXTREF_MODECONTEXTREF_MODEβ€”