Nodes/ComfyUI-WanVideoWrapper/WanVideo Set Radial Attention
ComfyUI Node Runs on cloud

WanVideo Set Radial Attention

Sparse attention that pays off on long Wan clips

By kijai·Created about a year ago·Updated 2 months ago· 6,651
WanVideo Set Radial Attention
  • model
  • model
dense_attention_modesageattn
dense_blocks1
dense_vace_blocks1
dense_timesteps2
decay_factor0.20
block_size128

Radial Attention is a sparse-attention trick out of MIT's Han Lab (the same group behind SageAttention) built specifically for long video generation. Normal attention cost scales quadratically with sequence length, and video sequences are long, so the longer your clip the more brutal it gets. Radial Attention swaps in an O(n log n) attention pattern with "energy decay" - nearby frames attend densely, distant ones sparsely - and the lab claims a 2-4x speedup without quality loss on models like Wan. This node applies it to your Wan model. It patches the model in and hands it back, so you drop it between your model loader and your sampler.

The honest framing up front: this earns its keep on long clips. On a standard 81-frame generation, the overhead can eat the savings, and at least one user found it slower than plain SageAttention for their case. The payoff curve bends the right way as length grows.

How it works

The node sets radial-attention parameters on the model. "Dense" here means normal (full) attention - the settings let you keep certain early blocks and early timesteps on dense attention (where precision matters most for setting up structure) while the rest run the cheaper radial pattern. That hybrid is the whole design: full attention where it counts, sparse attention where you can afford it.

The inputs and outputs that matter

  • model (WANVIDEOMODEL) - your loaded Wan model. Out comes the patched model.
  • dense_attention_mode (sdpa / flash_attn_2 / flash_attn_3 / sageattn / sparse_sage_attention, default sageattn) - which backend handles the dense blocks. sageattn pairs the two accelerators, which is the combination people specifically wanted.
  • dense_blocks (default 1) and dense_timesteps (default 2) - how many blocks and early timesteps stay on full attention. Raising these trades speed for fidelity; lowering them pushes harder on sparsity.
  • decay_factor (default 0.2) - how aggressively attention falls off with temporal distance. Higher = sparser = faster, but too high starts costing coherence.
  • block_size (128 / 64) - the sparse block granularity.
  • dense_vace_blocks (default 1) - same idea, for VACE blocks if you're running a VACE graph.

Output is the patched model (WANVIDEOMODEL) → into your sampler (or the next model patch).

How to install it

ComfyUI Manager - search ComfyUI-WanVideoWrapper, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-WanVideoWrapper
pip install -r ComfyUI-WanVideoWrapper/requirements.txt

then restart. Radial Attention relies on the sparse/Sage attention kernels being installed - which on Windows means the notoriously painful Triton + SageAttention setup. If those backends aren't present, the dense modes that depend on them won't work.

Common issues & troubleshooting

It made generation slower, not faster. This is the most common surprise, and it's real - on short clips (81 frames) the sparse-attention bookkeeping can outweigh what it saves, and users have reported it running slower than plain SageAttention. Radial Attention is for long generations; if you're doing standard 5-second clips, you may be better off with SageAttention alone.

Backend errors on dense_attention_mode. flash_attn_3 and the Sage variants need those kernels compiled and installed. If you get an import or CUDA error, drop back to sdpa (which always works) to confirm the node itself is fine, then sort out the accelerator install separately.

Coherence dropped on distant frames. Push decay_factor down and bump dense_blocks / dense_timesteps up - you're being too aggressive with sparsity. The defaults are a reasonable middle; tune from there.

CategoryWanVideoWrapper

Inputs (7)

NameTypeDefaultDescription
modelWANVIDEOMODEL
dense_attention_modeCOMBOsageattnThe attention mode for dense attention
dense_blocksINT10–40Number of blocks to apply normal attention to
dense_vace_blocksINT10–15Number of vace blocks to apply normal attention to
dense_timestepsINT20–100The step to start applying sparse attention
decay_factorFLOAT0.200–1Controls how quickly the attention window shrinks as the distance between frames increases in the sparse attention mask.
block_sizeCOMBO128Radial attention block size, larger blocks are faster but restricts usable dimensions more.

Outputs (1)

NameTypeDescription
modelWANVIDEOMODEL