Nodes/AnimateDiff Evolved/Context Extrasโ—†ContextRef ๐ŸŽญ๐Ÿ…๐Ÿ…“
ComfyUI Node Runs on cloud

Context Extrasโ—†ContextRef ๐ŸŽญ๐Ÿ…๐Ÿ…“

Keeping a sliding-window AnimateDiff render consistent

By KosinkadinkยทCreated 3 years agoยทUpdated 8 days agoยท 3,520
Context Extrasโ—†ContextRef ๐ŸŽญ๐Ÿ…๐Ÿ…“
  • prev_extras
  • strength_multival
  • contextref_mode
  • contextref_tune
  • contextref_kf
  • CONTEXT_EXTRAS
โ—„start_percent0.000โ–บ
โ—„end_percent0.250โ–บ

AnimateDiff-Evolved's whole "infinite length" trick is a sliding context window: instead of denoising every frame of a long video together, it processes overlapping chunks - 16 frames at a time, say - and stitches the overlaps back together. That's genuinely what makes arbitrary-length animation possible on consumer VRAM. It also has a known cost: each window makes its own independent decisions about color, lighting, and fine identity, so over a long clip things drift. A shirt shifts a shade bluer, a face subtly reshapes, exposure creeps - because window 40 has no real memory of what window 5 decided.

ContextRef is one of two "novel cross-context consistency techniques" (the README's own words) built to fight that drift - the other being NaiveReuse, its cheaper sibling. ContextRef works by injecting attention features from a reference window into every later window, the same family of trick as the "reference-only" self-attention injection technique ControlNet used for cross-image consistency before adapter models displaced it, except applied across time inside a single sliding-context render instead of across separate generations. Later windows can effectively "look back" at the reference window's features when deciding what to generate, which pulls identity and style back toward a common anchor instead of letting each window drift on its own.

This node is the root of the whole ContextRef setup - it's where you turn it on and configure the top-level behavior, and it outputs a CONTEXT_EXTRAS object.

The inputs that matter

Everything here is optional, which tells you a lot: plug this node in with nothing wired and you get ContextRef at sane defaults. strength_multival is the overall dial - like other Multival inputs across this pack, it can be a flat float, a list of per-frame floats, or a mask, so you can vary how hard the reference locks in across the video or across the frame. contextref_mode takes a Mode node (First or Indexes) and controls which window(s) act as the reference; leave it unplugged and ContextRef falls back to its simple default. contextref_tune takes a Tune node (Attn or Attn+Adain) and controls how the reference gets blended in. contextref_kf lets you schedule strength over the sampling process with a proper keyframe chain instead of one flat number. start_percent / end_percent (0 โ†’ 0.25 by default) bound when in the denoising process ContextRef is active - note it defaults to only the first quarter of steps, which lines up with how diffusion sampling generally works: broad structure, color, and identity get locked in early, so that's when a consistency nudge does the most good without fighting the detail pass later. prev_extras lets you chain this with a NaiveReuse node so both effects apply together - CONTEXT_EXTRAS is a linked list, not a single slot.

Crucially: this node's output has to reach Set Context Extras, wired alongside your Context Options node. ContextRef alone builds a description of what you want; Set Context Extras is what actually attaches it to the pipeline the sampler uses. Skip that step and you'll wonder why nothing changed.

And note the scope: this only matters once you're actually using sliding context windows for a long or looped animation. If your clip fits inside one context window, there's no cross-window drift to fix, and ContextRef has nothing to do.

Installing it

ComfyUI Manager: search AnimateDiff Evolved, author Kosinkadink, install, restart. Manual: git clone https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved into custom_nodes, restart. You'll also need at least one motion module downloaded per the README's Model Setup section - ContextRef configures how context windows relate to each other, it doesn't replace the motion model itself.

Where you're on your own

Worth being straight about this: ContextRef and NaiveReuse are genuinely obscure. Searching the r/StableDiffusion and r/comfyui archive for the exact phrase "ContextRef" returns zero threads - not a handful, zero. This isn't a heavily-discussed, battle-tested feature with a pile of community workflows behind it; it's a deep-cut addition to an already legacy-leaning pack, and you should expect to figure out your own settings by testing rather than finding a tutorial. The one grounded piece of practical advice: if you build a ContextRef setup and see no effect at all, the most likely cause isn't a bad strength_multival - it's forgetting to route it through Set Context Extras.

CategoryAnimate Diff ๐ŸŽญ๐Ÿ…๐Ÿ…“/context opts/context extras

Inputs (7)

NameTypeDefaultDescription
prev_extrasoptCONTEXT_EXTRASโ€”
strength_multivaloptMULTIVALโ€”
contextref_modeoptCONTEXTREF_MODEโ€”
contextref_tuneoptCONTEXTREF_TUNEโ€”
contextref_kfoptCONTEXTREF_KEYFRAMEโ€”
start_percentoptFLOAT0.0000โ€“1โ€”
end_percentoptFLOAT0.2500โ€“1โ€”

Outputs (1)

NameTypeDescription
CONTEXT_EXTRASCONTEXT_EXTRASโ€”