NABLA Attention KJ
Experimental sparse attention for Kandinsky 5 video
- model
- latent
- MODEL
Long video generation is expensive mostly because attention scales badly - every frame attends to every other frame, and the cost balloons as clips get longer. Sparse attention is one answer: skip the attention blocks that don't matter and only compute the ones that do. NABLA_AttentionKJ patches a video model to use NABLA sparse attention, and it's flagged plainly in its own description as "experimental" and, as of now, "only works with Kadinsky5" (Kandinsky 5). So set expectations accordingly - this is a bleeding-edge lever for one specific model, not a general speed-up.
It lives in KJNodes' experimental category, which is where Kijai parks the "this might change or break" stuff. Kijai has a long history of being first to wire up brand-new model tricks - fp8 conversions and wrappers that land within hours of a release - and this is that instinct applied to attention on a niche video model.
How it works
You hand it a model and a latent; it patches the model's attention path to compute a sparse pattern instead of dense all-to-all. It keeps a dense local window (so nearby frames and nearby spatial regions still attend fully) and drops a configurable fraction of the rest. Less attention computed means less time and less memory on long clips - at some quality risk, which is the trade you're tuning.
The inputs and outputs that matter
model(MODEL) andlatent(LATENT) - your Kandinsky 5 model and the video latent it's operating on.sparsity(FLOAT, default 0.9) - how much attention to drop. 0.9 keeps only the densest ~10%. Higher is faster and lighter but riskier for quality; back it off if the output degrades.window_time(11),window_width(3),window_height(3) - the local dense window kept fully computed. Larger windows preserve more detail but save less.torch_compile(BOOLEAN, default true) - compiles the patched attention for real speed. Leave on for the gains, but know it adds a warmup and has its own failure modes.
The single output is a patched MODEL - wire it into your sampler.
How to install it
ComfyUI Manager: search KJNodes for ComfyUI, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KJNodes
pip install -r ComfyUI-KJNodes/requirements.txt
then restart (portable: run pip via python_embeded\python.exe).
Common issues & troubleshooting
It only supports Kandinsky 5. This is stated in the node itself. Point it at Wan, Hunyuan, or any other model and it either no-ops or errors. Don't spend an afternoon debugging why it "isn't working" on the wrong architecture - that's the intended behavior.
torch_compile blows up, especially on Windows. torch.compile needs a working Triton/compiler backend and is notoriously flaky on Windows. If enabling it throws compile errors, turn torch_compile off - you lose the speed but the sparse pattern still applies.
Missing attention backend. KJNodes' attention-optimization nodes lean on optimized attention libraries, and a very common KJNodes error in the wild is ModuleNotFoundError: No module named 'sageattention' when a node expects a fast-attention backend that isn't installed. If you hit a missing-module error running this, install the required attention backend (or fall back to a mode that doesn't need it) rather than assuming the node is broken.
Quality dropped off a cliff. Lower sparsity and/or widen the windows. At 0.9 you're throwing away most of the attention; some content tolerates that and some doesn't. It's experimental - treat every setting as something to sweep, not a fixed recipe.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| latent | LATENT | Only used to get the latent shape | |
| window_time | INT | 11 | Temporal attention window size |
| window_width | INT | 3 | Spatial attention window size |
| window_height | INT | 3 | Spatial attention window size |
| sparsity | FLOAT | 0.900–1 | — |
| torch_compile | BOOLEAN | true | Most likely required for reasonable memory usage |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |