Nodes/ComfyUI-FlashVSR-Stock/FlashVSR Sparge Attention
ComfyUI Node

FlashVSR Sparge Attention

The optional Sparge route — only install it if you know why

By Pizzawookiee·Created about a month ago·Updated 8 days ago· 2
FlashVSR Sparge Attention
  • model
  • MODEL

Be honest about what brought you here: a workflow with a node called "Sparge Attention," and you're wondering whether you need it and what it even does. The short answer is that this is the optional node in the FlashVSR-Stock pack - the only one that requires an extra library you have to install by hand - and you can run the entire pack happily without it. You should install it only when the default path isn't cutting it, and you should understand what it's for before you do.

FlashVSR uses a special attention pattern called LCSA - local causal sparse attention - where each query block only attends to a small, locally-causal set of key blocks instead of the whole video. In the streaming modes, the FlashVSR One-Step Sampler builds that LCSA mask and hands it to whatever attention backend the model has selected. If your backend accepts an arbitrary per-head mask, that works fine through a dense masked kernel - slower than it could be, but correct. This node exists for the case where you want the sparse path actually executed sparsely: it uses the separately installed SpargeAttn library to skip rejected key blocks at the kernel level.

How it works

The mechanism, per the author's own description: FlashVSR's routing happens on logical 128-query by 128-key blocks, and the mask is converted to the GPU kernel's physical block geometry only after routing. Sparge then processes the complete compact block mask in one sparse call. Two important limits:

  • It is not a ModelAttentionBackend replacement. Dense self-attention, cross-attention, and full_video_dense still go through the model's selected ComfyUI backend. Patch order relative to Configure FlashVSR Upscaling or ModelAttentionBackend doesn't matter - Sparge only takes over the FlashVSR streaming self-attention.
  • It needs a matching SpargeAttn wheel - matching ComfyUI's Python, PyTorch, CUDA, and GPU architecture - plus a CUDA GPU. The pack's requirements install a Triton runtime that Sparge uses, but they deliberately do not install a SpargeAttn wheel; you grab one from the SpargeAttn releases. The node imports it as spas_sage_attn only when the patch is actually used, so a broken install won't break the rest of the pack.

There's a hardware asterisk worth knowing: the current native adapter targets RTX 4000-series (SM89). Sparge exposes ABIs for other architectures too, but the README is explicit that those paths are untested by this project - a missing symbol or layout error just disables the native route and falls back to the v0.33 compatibility path, so a failure isn't a crash, it's a silent downgrade to the older path.

The node's interface is almost comically small for the complexity involved: one required model input (MODEL), one MODEL output. Wire the model in, get it back out patched, keep going down the same path.

Installing it

The node itself comes with the ComfyUI-FlashVSR-Stock pack (ComfyUI Manager: search ComfyUI FlashVSR Stock Wan, or git clone + pip install -r requirements.txt). The extra step is the SpargeAttn wheel, from the release page, matched to your environment. If the wheel is missing or incompatible, the README's guidance is blunt: remove this node and use a mask-capable attention backend - the dense fallback is the intended baseline, not a consolation prize.

Common issues

  • "No module named spas_sage_attn". You installed the pack but not the SpargeAttn wheel. Either install a matching wheel or remove this node - the pack runs fine without it.
  • No speedup. Possible and normal. The value depends on your video's actual sparsity and your GPU. The README describes Sparge as a private route for streaming self-attention, not a general acceleration.
  • Confused about ordering. There is no ordering requirement. Patch order relative to the apply node and the attention backend doesn't matter; Sparge only handles the FlashVSR streaming mask, and everything else stays on the model's selected backend.

If you're on a 6 GB card and fighting OOM in the attention stage, this node (or a mask-capable attention backend) is one of the levers - but it's the fiddly one, and the README's own first move for OOM is the sampler's streaming_faithful_lowvram mode, which needs no extra install at all.

CategoryFlashVSR/model_patches

Inputs (1)

NameTypeDefaultDescription
modelMODEL

Outputs (1)

NameTypeDescription
MODELMODEL