Nodes/ComfyUI-CustomNodeKit/Wan SCAIL Sparse Attention
ComfyUI Node

Wan SCAIL Sparse Attention

Sparse attention masks

By user2318·Created 4 months ago·Updated about a month ago· 56
Wan SCAIL Sparse Attention
  • model
  • model
mask_typepose_no_main
causal_window-1
local_window1

In SCAIL-2's architecture there are three kinds of tokens fighting for attention: the reference tokens, the pose tokens, and the main video tokens. Full attention lets each group peek at everything, which sounds harmless until you realize it's the mechanism behind one of the model's known failure modes - long-video degeneration, where continued chunks drift, characters melt, and motion quality decays as the sequence grows. Sparse attention is the fix: tell specific token groups they're not allowed to look at specific other groups, and you cut both the drift and the compute.

WanSCAILSparseAttention applies an attention mask to a SCAIL model and hands back the patched model. It works standalone - you don't need the context-window node for it to do something - but the tooltips map each mask to its intended setup, and that mapping is where the value lives.

The mask types (this is the whole game)

  • none - leave attention alone; a glorified bypass.
  • pose_no_main - pose tokens can't attend the main video tokens. The tooltip's recommendation: use with context sampling. When windows are being stitched, pose tokens fixating on main content is what drags the pose off.
  • ref_no_late_main - reference tokens can't attend the back half of the main sequence. Lightweight, and it stacks conceptually with other modes for long clips where the reference should anchor the front and not keep re-injecting itself late.
  • fast_video - a combined scheme: ref sees only the first quarter, main uses a local window, pose doesn't look at main. Uses the local_window parameter (frames of lookahead/lookbehind - 1 = one frame either side). This is the "cheaper generation" preset.
  • causal_with_global_prefix - reference is globally visible, everything else is causal (only looks backward). The tooltip's recommendation: use with previous_frames chaining. This is the mode for single-pass continuation where each new frame should only know the past plus the reference.

The optional causal_window input (-1 = strict causal, >0 = allow looking back N frames) only applies in the causal mode; it's how you let frames see a few frames of future smoothing without going fully non-causal.

What to actually run

For the pack's chunked long-video workflows, pose_no_main plus the context windows is the advertised combo. For the previous_frames-style single-pass continuation, causal_with_global_prefix is the one the tooltip names. The output is a wrapped model that goes straight into the KSampler - chain it after your context-window node or before your sampler, either works since both patch model options.

Honest expectations

This is a compute- and stability optimization on a model that's already compute-hungry; it doesn't fix face identity drift, which the community's standing answer is to drop LightX2V LoRAs and raise steps/CFG. And mask types interact with your workflow structure - pose_no_main in a non-windowed setup can visibly weaken pose adherence, so match the mask to the chaining strategy rather than stacking them blindly.

Install

Part of ComfyUI-CustomNodeKit. ComfyUI Manager → search "ComfyUI-CustomNodeKit", or:

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

Restart ComfyUI. No weights to download.

Categorymodel/attention

Inputs (4)

NameTypeDefaultDescription
modelMODEL要应用稀疏注意力的 SCAIL 模型。The SCAIL model to apply sparse attention to.
mask_typeCOMBOpose_no_main注意力掩码模式: 无 (全注意力): 不修改注意力 姿态不看主帧 (Pose→No Main): pose token 不 attend 主帧。推荐配合上下文采样。 参考不看后半段主帧 (Ref→No Late Main): ref 不 attend 后半段主帧 快速视频 (Fast Video): 组合局部窗口+约束 因果+全局前缀 (Causal+Prefix): ref 全局,其余 causal。推荐配合 previous_frames 接续。 Attention mask type: none: don't modify attention pose_no_main: pose tokens don't attend main. Recommended with context sampling. ref_no_late_main: ref doesn't attend late half of main fast_video: combined local window + constraints causal_with_global_prefix: ref global, rest causal. Recommended with previous_frames chaining.
causal_windowoptINT-1-1–512Causal 滑窗大小,单位:帧 (仅 causal_with_global_prefix 模式有效。-1=严格 causal, >0=允许回头看 N 帧)。Causal window size in frames (only effective in causal_with_global_prefix mode. -1=strict causal, >0=allow looking back N frames).
local_windowoptINT11–512局部窗口大小,单位:帧(仅 fast_video 模式使用。1=前后各看 1 帧,2=前后各看 2 帧)。Local window size in frames (only used in fast_video mode. 1=look 1 frame ahead/behind, 2=look 2 frames).

Outputs (1)

NameTypeDescription
modelMODEL