Nodes/H3 Motion Context/H3 Sparse Hold (experimental)
ComfyUI Node

H3 Sparse Hold (experimental)

Keeping the join sharp under sparse attention

By NikoDemon80·Created 4 months ago·Updated 5 days ago· 1,466
H3 Sparse Hold (experimental)
  • model
  • model
◄hold_frames22►
◄dense_after24►

Sparse attention is the reason long H3 clips are affordable at all. Instead of every part of the picture looking closely at every other part, each block of tokens attends only the key blocks it scores as relevant, and the rest of the frame reaches it as a summary. You get most of the picture quality for a fraction of the compute. You also get a specific failure at exactly the wrong place.

ComfyUI's Model Sparse Attention keeps a set of things exact regardless: the text, your reference blocks, pinned keyframes and the sound. Everything packed in front of the picture, in other words. The picture itself is left to the sparse selection.

Here's the problem with a chained clip. The carried head - the previous clip's last frames, held with a mask or redrawn as pinned keyframes - is in the picture. The frames right after the join are built out of it, and under sparse attention they see it only partly. So the join is the one spot in the clip where the model is working from an incomplete view of its own starting point. That's what shows up as a soft or drifting first second after a cut, even when everything else looks right.

What the node does

It runs the join dense. The held head, plus dense_after frames past it, attend every token exactly as they would with no sparse attention at all. The rest of the clip stays precisely as stock sparse attention runs it - same speed, same cost per token, nothing else moved.

dense_after is measured in frames, and 24 frames is one second at 24fps. More is safer and slower. hold_frames is the length of the held head, and you wire it from H3 Motion Context's trim_frames so that the first clip in a chain - trim 0, nothing carried - runs plain sparse with no dense window at all. That wiring is what makes the node safe to leave in a graph permanently.

The mechanism is a hook, and it's worth knowing how it lands because it explains the failure modes. ComfyUI's sparse node keeps its settings on one object that every H3 block consults for its exact row ranges. This node finds that object behind the model's block patches and wraps that single question. It reads the join from the model it outputs, so the model going in is untouched, and bypassing this node gives you stock sparse behaviour.

There's a design story in the source worth repeating: the first version made every frame of the clip see the held head exactly. Joins came out clean, and mid-clip the picture could snap to the reference image, background and all, while the motion carried on - with the reference and the head the only things a frame saw sharply, the reference won once the scene moved. Making only the join dense keeps every other frame stock, which never did that.

Wiring

Load Diffusion Model -> Model Sparse Attention -> H3 Sparse Hold -> sampler
Motion Context trim_frames -> H3 Sparse Hold hold_frames

Inputs are model, hold_frames (default 22) and dense_after (default 24). One output, model, into the sampler. That's the entire node.

It works with Model Sparse Attention's sol-attn and sla methods. vsa reorders the picture into 3D cubes before attention, so the join stops being one contiguous stretch - the node refuses rather than producing something subtly wrong. Other sparse attention packs are their own code and aren't touched. And if you're on plain dense attention (flash, sage, the usual), you don't need this at all: those already see every frame.

Install

ComfyUI Manager → H3 Motion Context, or:

cd ComfyUI/custom_nodes
git clone https://github.com/NikoDemon80/ComfyUI-H3-Motion-Context

Then restart. ComfyUI 0.34.0 or newer. No model downloads, no extra checkpoints, no requirements.txt - the pack runs on ComfyUI's own numpy/PIL/aiohttp environment and imports PyAV only when writing video. If you had ComfyUI-H3-Disk-Upscale installed, remove it.

Common issues

"No Model Sparse Attention found on this model." The node looks for the sparse settings object behind the model, and either it isn't there or it isn't where it expects. Put this node directly after ComfyUI's Model Sparse Attention node. If it already is, ComfyUI's sparse code has changed shape and the node needs an update - it checks rather than guessing.

"Model Sparse Attention is set to vsa." Switch the sparse node to sol-attn or sla, or bypass this one.

The first clip looks different now. It shouldn't, if hold_frames is wired from trim_frames. Hard-coded 22 with no wiring means clip 1 also runs a dense join at the top, where there's nothing to hold. Harmless, but it's spending time for nothing.

It ate your speed gains. It will, a little - that's the trade. dense_after 24 is a second of dense attention at the head of each clip; drop it to 12 if you're chasing throughput, raise it if the second after the join still looks soft.

One honest caveat: this leans on ComfyUI internals that aren't a public interface, in a model family that's still young. The author knows, checks what it finds, and refuses loudly. A loud refusal is much better than a join that quietly comes out wrong.

Categoryconditioning/minimax

Inputs (3)

NameTypeDefaultDescription
modelMODELFrom ComfyUI's Model Sparse Attention node, set to sol-attn or sla.
hold_framesINT220–56Wire from Motion Context's trim_frames, so the first clip runs normally.
dense_afterINT240–120How many frames after the join also get full attention. 24 is one second. More is safer but slower.

Outputs (1)

NameTypeDescription
modelMODEL—