Nodes/TrentNodes/Patch Sol-Attention - Trent
ComfyUI Node

Patch Sol-Attention - Trent

Faster Long-Video Sampling — If Your GPU Is New Enough

By TrentHunter82·Created 9 months ago·Updated 4 days ago· 36
Patch Sol-Attention - Trent
  • model
  • MODEL
enabledtrue
tau1.00
dense_start_percent0.20
min_tokens4096

Long video generation has a nasty scaling problem: attention is quadratic in sequence length, so doubling your frames quadruples the cost of every self-attention call. Sol-Attn is a training-free trick that routes only the important tokens through full attention and approximates the rest, and this node patches it into any diffusion model's attention with one wire. The catch, and it's a real one: the reference kernel needs an sm90+ GPU - think H100, or Blackwell - and it only pays off on genuinely long sequences.

How it works

The node follows the familiar KJNodes patch pattern: it clones your MODEL and installs an optimized_attention_override in the model's transformer options. Bypass the node and the patch is gone; no messy manual reversion. Inside, the override is strict about when it actually routes through the sparse Triton kernel:

  • Long self-attention only. Cross attention, masked attention, GQA, and non-CUDA tensors all fall through to normal attention automatically.
  • Sequence-length gate. Self-attention sequences shorter than min_tokens (default 4096) stay dense. Sol-Attn is only a win when the token count is huge - exactly the long-video case.
  • Dense warmup. dense_start_percent (default 0.2) keeps the first 20% of sampling steps dense. The reasoning, from NVIDIA's own Wan recipe this node mirrors: structure forms early in sampling, so you want exact attention while the image composition is being decided. It's the first 10 of 50 steps in the paper's example.
  • Dense at the end, too. If the kernel ever throws, the node flips a kernel_broken flag, logs a warning, and runs dense attention for the rest of the run. You don't get a crash mid-sampler; you get a silent-ish fallback.

The knobs that matter

  • enabled - the toggle. Leave the node wired, flip this to try the patch on and off without unplugging anything.
  • tau (default 1.0) - the routing threshold. Higher = sparser and faster; lower = more exact blocks and slower. Very negative values (like -10) approach exact attention. If output quality dips, this is the first thing to lower.
  • dense_start_percent and min_tokens - mostly set-and-forget at the defaults, unless you're on a task where structure forms late.

The hard requirements

The source code checks two things and raises before sampling if you don't have them: a CUDA GPU with compute capability ≥ 9.0 (so sm90 = H100-era and newer), and head_dim == 128, which the kernel hard-codes. The Triton kernel also needs a working Triton install. If your attention heads use a different dim, the node simply won't engage - it falls through to dense silently, and the log line that says "Sol-Attn active" never appears.

This is a legitimately experimental node (EXPERIMENTAL = True in the code), and the "Sol-Attn" name traces to an NVIDIA sparse-attention technique the pack credits by arXiv ID - worth knowing it's a bleeding-edge trick, not a settled best practice. On a consumer GPU it will refuse to run at all, which is correct behavior: better an error than a broken render.

Installing it

Part of TrentNodes; one install for the whole pack:

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

ComfyUI Manager ("Trent Nodes") works too, with the known caveat that the author's day-one repo rename left two registry entries and Manager sometimes flags the pack as "unsafe" - clone manually if so.

Should you bother?

Honestly: only if you own or rent an H100/Blackwell and are sampling very long video (Wan, Hunyuan, LTX at high frame counts). On a 4090 or anything consumer, the node will just error out, and you haven't lost anything. If you do have the hardware, wire it after your model loader, keep dense_start_percent where it is, and watch the console for the "Sol-Attn active" log to confirm the kernel actually engaged.

CategoryTrent/Optimization

Inputs (5)

NameTypeDefaultDescription
modelMODEL
enabledBOOLEANtrueToggle the patch without unplugging the node.
tauFLOAT1.00-10–10Routing threshold. Higher = sparser and faster, lower = more exact blocks and slower. 1.0 is the paper default. Very low values (e.g. -10) are near-exact attention.
dense_start_percentFLOAT0.200–1Fraction of sampling steps at the start that run dense attention. NVIDIA used the first 10 of 50 steps (0.2) for Wan. Structure forms early, so keep some dense warmup.
min_tokensINT4096256–1048576Self-attention sequences shorter than this run dense. Sol-Attn only pays off on long video sequences.

Outputs (1)

NameTypeDescription
MODELMODEL