Nodes/Spark-H3/MiniMax H3 Spark Attention (SM86)
ComfyUI Node

MiniMax H3 Spark Attention (SM86)

Spark Attention (SM86)

By zechengtang·Created about a month ago·Updated about 3 hours ago· 82
MiniMax H3 Spark Attention (SM86)
  • model
  • MODEL
◄modefidelity►
◄steps20►
◄warmup_modewarmup_ratio►
◄warmup_ratio0.20►
◄warmup_steps4►
◄topk_modetopk_ratio►
◄topk_ratio0.20►
◄topk_blocks228►
◄dense_layers0►
◄min_tokens12288►
◄stricttrue►
◄dense_backendinherit►
◄tail_granularityquery►
◄reblock_layoutq_reuse_k►

Here's the number that makes people stop scrolling: on a 3090 running the LightX2V 768p 8-step workflow at 1344×768 and 345 frames, this node measured 2.42× faster than dense attention in fidelity mode and 4.62× in speed mode. The 4090 gets 2.37×/4.35× and an RTX PRO 6000 Blackwell gets 2.05×/3.15×. Older, slower attention has more headroom to win back, which is why the 30-series node - added in v0.1.3, validated by the authors on both Linux and Windows RTX 3090 - is the one many people actually care about.

The pack is Spark-H3: adaptive block sparse attention for MiniMax-H3, the 33B omni-modal video model that generates picture and stereo audio together. The attention math over tens of thousands of video tokens is the bottleneck, and this node replaces it.

How it works, briefly

H3's dense attention is quadratic in sequence length, and the sequence is enormous - the pack's own docs use a 10-second 768p sample with 72,576 video tokens, which is 1,134 blocks of 64. Block-sparse attention splits that into an exact branch (a selected set of blocks, computed properly) and a compressed branch (everything else, summarised cheaply). Spark's two contributions target those branches separately:

Spark-Reblock groups tokens by attention preference into the 64-token blocks, instead of using consecutive tokens or fixed spatio-temporal tiles. Similarity is a Mahalanobis cosine distance under the opposite side's second moment - queries are compared with M_K = E[kkᵀ], keys with M_Q = E[qqᵀ] - and a capacity-constrained hierarchical partitioner splits down to exact 64-token leaves. It never changes the Q/K/V values, only which tokens share a block, and it's rebuilt per layer and per step from the current input. At a 10% budget the authors report +12.88 points of attention-mass recall and +3.80 dB mean PSNR over fixed block partitioning.

Spark-Reweight fixes the compressed branch's mean-pooling bias with weighted summaries and a log-mass correction: −28% absolute log-mass error, +0.56 dB at the same 10% density. Tail tokens, the awkward remainder at the end of the sequence, get their own treatment.

The inputs that matter

model goes in - connect it after your model loader, before the guider/scheduler - and a patched MODEL comes out. Everything else has a sensible default, so here's the short list of what you'd actually touch.

  • mode - fidelity (default) fills in a 20% dense warmup; speed sets it to zero and goes sparse from the first evaluation; custom is what you get once you've hand-edited an active warmup value; dense bypasses the patch entirely and passes the model through. The pack recommends speed for the high-resolution second pass of a two-pass workflow, where a dense warmup is wasted.
  • steps - must equal the sampler's actual model-evaluation count. MiniMax's scheduler counts the terminal σ=0 endpoint as a step, so the default 50-step H3 run is 49 evaluations, and a 20-step run is 19. Get this wrong and your warmup percentage is computed against a step count that doesn't exist.
  • topk_mode + topk_ratio - the exact branch's budget. topk_ratio=0.2 (default) is the pack's recommended balance; 0.1 is fastest, 0.3 is the fidelity end. topk_blocks is the alternative fixed-block-count form (228 ≈ 20% on a 10-second 768p sample).
  • dense_layers - how many leading transformer blocks always run dense. Default 0.
  • min_tokens - below this sequence length everything stays dense, because sparse overhead isn't worth it on short clips. Default 12288.
  • strict - keep it on while you're setting up. With it off, unsupported inputs silently fall back to the original attention and log the reason, which is a great way to benchmark a fallback path by accident.
  • Optional: dense_backend (inherit/kitchen/sage/sdpa) picks the attention backend for the dense warmup steps, and tail_granularity / reblock_layout are the fidelity/perf knobs the shipped workflows pin to query and q_reuse_k.

Installing, and the arch wall

cd /path/to/ComfyUI/custom_nodes
unzip /path/to/ComfyUI-Spark-H3-<version>-linux-x86_64-sm86-cu130.zip
/path/to/ComfyUI/.venv/bin/python ComfyUI-Spark-H3/install.py

Or install from ComfyUI Manager (registry publisher zechengtang, node ID comfyui-spark-h3), which pulls the matching wheel. Use the ComfyUI venv's Python, never a system one. The installer picks the comfy-kitchen backend matching your ComfyUI release (0.2.36 for 0.38.x, 0.2.37 for 0.39.x) and rejects a wheel built for another architecture or CUDA toolchain - there is no silent fallback.

Which is the first real gotcha: the ComfyUI build ships SM86, SM89 and SM120 only. On an A100 or A800 (SM80) or an H100 (SM90) there is no installer path, despite SM80 kernels existing in the authors' own benchmark harness. On the 30-series side you're fine, and BF16 is what you want - Ampere has no fp8, and the pack targets CUDA 13.0 with BF16 execution. ComfyUI 0.38.x or 0.39.x; 0.39.2 is the current recommendation.

Models aren't bundled. Grab the diffusion model, text encoder and both VAEs from Comfy-Org/MiniMax-H3 into models/diffusion_models, models/text_encoders and models/vae. And the licence heads-up worth repeating: H3's weights are void in the EU, UK, South Korea and the US, outputs included.

Where people get burned

Two attention patches on one model. Apply one. Stacking Spark with another attention patch produces nonsense numbers and occasionally nonsense video.

Combining with KJNodes low-VRAM nodes in the wrong order. If you use MiniMax H3 Low VRAM Attention or MiniMax H3 Chunk FeedForward, the supported chain is loader → Low VRAM Attention → Chunk FeedForward → Spark → sampler. Low VRAM Attention has to come first: Spark detects its compose hook at patch time and switches to a head-chunked path. Reversed, it usually still runs, which is worse - you get the VRAM cost without the benefit.

Judging speed mode by its throughput. The authors are honest about this one: with no warmup the schedule "may deviate more from the dense model", and they treat those speedups as "an optimistic speed upper bound, rather than evidence of comparable quality-preserving acceleration." If you care about matching dense output, fidelity is the mode that's claiming that.

First-run timing. The kernel compiles on the first sparse evaluation, so the first generation after install is slower than the ones after it. Don't benchmark that one.

Categorymodel_patches/attention

Inputs (15)

NameTypeDefaultDescription
modelMODEL接入 MiniMax H3 模型:连接在模型加载节点之后、采样器之前。若使用 KJNodes Low VRAM Attention / Chunk FeedForward,请把它们连接在 Spark 之前。
modeCOMBOfidelityfidelity(默认)填入 20% dense 预热;speed 填入 0%;手动调整有效 warmup 参数后显示 custom;dense 完全旁路 Spark。双采工作流的高分辨率二阶段建议使用 speed。
stepsINT201–200本次采样的模型调用次数,通常与采样器 steps 相同;用于计算预热阶段。
warmup_modeCOMBOwarmup_ratioDense 预热长度的表示法。mode 只会快捷填入这里和对应数值;之后仍可手动修改。
warmup_ratioFLOAT0.200–1开始时保持 dense 的采样调用比例。speed 预设填入 0,fidelity 预设填入 0.2;仅在 warmup_mode=warmup_ratio 时生效。
warmup_stepsINT40–200开始时保持 dense 的模型调用次数;仅在 warmup_mode=warmup_steps 时生效。mode 预设不会删除这个高级设置。
topk_modeCOMBOtopk_ratio选择 Top-K 预算表示法:默认 topk_ratio 使用随视频长度变化的比例;topk_blocks 使用固定块数。
topk_ratioFLOAT0.200.01–1精确计算的候选视频块比例:0.1≈10%(速度最快),0.3≈30%(保真度最好),建议 0.15 或 0.2 取得均衡;仅在 topk_mode=topk_ratio 时生效。
topk_blocksINT2281–262144每个 query 块精确计算的候选视频块数。10 秒 768p 样本中 114≈10%、228≈20%、342≈30%;10% 通常最快,30% 保真度较高,建议先用 228。仅在 topk_mode=topk_blocks 时生效。
dense_layersINT00–50始终使用 dense attention 的前 N 个 Transformer 层;默认 0 表示不固定任何层。
min_tokensINT12288256–262144序列 token 数低于该值时保持 dense;用于避免短序列上稀疏计算反而增加开销。
strictBOOLEANtrue启用时,Spark 不兼容的输入会报错;关闭时对不兼容输入回退原始 attention,并在日志记录原因。
dense_backendoptCOMBOinheritDense 预热、固定 dense 层和 dense 回退所用的 attention 后端。inherit 不强制覆盖,沿用模型或 ComfyUI 当前设置;kitchen、sage、sdpa 强制使用对应后端。
tail_granularityoptCOMBOquery近似分支的 Q 粒度:query(默认)对应 sol-engine Sol,只下采样 K/V、保留逐条真实 Q;block 对应 ComfyUI Sol,Q 和 K/V 都按块下采样,同一 Q 块共享近似结果。精确分支仍使用真实 Q。
reblock_layoutoptCOMBOq_reuse_kreblock 布局:q_reuse_k 只构造 K 侧布局并让 Q 复用,减少 M2、树构建和索引开销;independent 分别构造 Q/K 布局,用于兼容旧结果。

Outputs (1)

NameTypeDescription
MODELMODEL—