Extensions/ComfyUI Spark-H3
ComfyUI Extension

ComfyUI Spark-H3

Spark-H3 extends comfy-kitchen's efficient block-sparse attention (BSA) implementation for ComfyUI's native MiniMax-H3 video generation. It adds two functions—Spark-Reblock and Spark-Reweight—to form Spark-Attn: Reblock groups similar tokens, while Reweight corrects tail-token contributions. v0.1.3 Linux attention speedups versus Dense SDPA (LightX2V 768p 8-step, 1344x768, 345 frames, 24 FPS; topk_ratio 20%, warmup_steps 2): RTX 3090 - Fidelity 2.42x / Speed 4.62x; RTX 4090 - 2.37x / 4.35x; RTX PRO 6000 Blackwell - 2.05x / 3.15x.

By zechengtang·Created 2 months ago·Updated 2 days ago· 200
zechengtang/Spark-H3
Nodes9
On cloudLocal install
Categorymodel/latent/minimax, model_patches/attention
Stars200
Updated2 days ago
Readme
<div align="center"> <h1><img src="assets/spark-h3-wordmark.png" alt="Spark-H3" width="270"></h1> <h3>Adaptive Block Sparse Attention for MiniMax-H3</h3> <p><strong>Reblock similar tokens · Reweight tail tokens</strong></p> <p> <a href="https://zechengtang.github.io/Spark-H3/"><img src="https://img.shields.io/badge/Blog-Spark--H3-f97316?style=flat-square" alt="Spark-H3 technical blog"></a> <a href="https://arxiv.org/abs/2611.24256"><img src="https://img.shields.io/badge/arXiv-2611.24256-b31b1b?style=flat-square" alt="arXiv:2611.24256"></a> <a href="https://huggingface.co/Aazeus/Spark-H3"><img src="https://img.shields.io/badge/%F0%9F%A4%97_Hugging_Face-Spark--H3-ffc107?style=flat-square" alt="Spark-H3 on Hugging Face"></a> <a href="comfyui/README.md"><img src="https://img.shields.io/badge/ComfyUI-Spark_Node-f97316?style=flat-square" alt="Spark-H3 ComfyUI node"></a> <a href="#special-thanks"><img src="https://img.shields.io/badge/Special_Thanks-Community_Contributors-e11d48?style=flat-square" alt="Special thanks to community contributors"></a> <a href="h3_sparse_attention/README.md"><img src="https://img.shields.io/badge/Docs-Usage_%26_Configuration-2563eb?style=flat-square" alt="Usage and configuration guide"></a> <a href="LICENSE"><img src="https://img.shields.io/badge/License-Apache_2.0-15803d?style=flat-square" alt="License: Apache 2.0"></a> <a href="https://github.com/zechengtang/Spark-H3/releases"><img src="https://img.shields.io/github/downloads/zechengtang/Spark-H3/total?style=flat-square&amp;label=Downloads" alt="Total GitHub release downloads"></a> </p> <p> <strong>English</strong> · <a href="README.zh-CN.md">简体中文</a> </p> <p> <a href="#demo">🎬 Demo</a> &nbsp;·&nbsp; <a href="#quick-start">🚀 Quick Start</a> &nbsp;·&nbsp; <a href="#comfyui-installation">🧩 ComfyUI</a> &nbsp;·&nbsp; <a href="https://zechengtang.github.io/Spark-H3/">📖 Technical Blog</a> &nbsp;·&nbsp; <a href="#project-status">🧭 Project Status</a> </p> </div>

[!NOTE] Spark-H3 technical report (November 18, 2026)

We released the Spark-H3 technical report. Read it on arXiv.

[!IMPORTANT] ComfyUI v0.2.0 release: Spark-H3 now uses the isolated spark-h3-kitchen distribution and spark_h3_kitchen import namespace. It no longer replaces or pins ComfyUI's official comfy-kitchen package. The release supports ComfyUI 0.38.x–0.40.x and 0.42.x–0.44.x. For production use, we recommend the default spark-h3-kitchen 0.2.37, which delivered better speed and stability in release testing. Read the v0.2.0 release notes

VPack v0.1.0: A separate ComfyUI plugin that compresses reference videos in Ref2VA workflows. VPack GitHub repository

👉 Ref2VA 任务加速解决方案


<a id="demo"></a>

🎬 Demo

Native MiniMax-H3 · VDN Selected Prompt 06 · 1344×768 · 14.4 seconds. The three panels compare Dense, Spark-H3 Fidelity (2.19×), and Spark-H3 Speed (3.12×). The animated preview and linked clip cover the final 5.4 seconds, starting at 9 seconds.

Animated Native MiniMax-H3 attic comparison: Dense, Spark-H3 Fidelity, and Spark-H3 Speed

<p align="center"><a href="https://huggingface.co/Aazeus/Spark-H3/resolve/main/comfyui/demos/H3_native_vdn_selected_0006_dense_fidelity_speed_native_resolution.mp4">Watch the full 14.4-second comparison</a></p>

✨ Spark-Attn

Spark-Attn is a block sparse attention method for MiniMax-H3 video generation. It combines two operations:

  • 🧩 Reblocking groups similar tokens into blocks so sparse attention can select more relevant interactions.
  • ⚖️ Reweighting assigns different weights to tokens within each tail block when building key/value summaries, with a correction for attention mass.

Spark-H3 provides the Spark attention kernels and MiniMax-H3 inference integration.

<a id="quick-start"></a>

🚀 Quick Start

Set up your H3 pipeline using the upstream MiniMax-H3 instructions, then install Spark in the same environment with a compatible PyTorch/CUDA stack:

python -m pip install -e '.[cuda]'

Wrap an already loaded pipeline with the Spark installer:

from h3_sparse_attention import install_h3_spark_attn

# MiniMaxH3Scheduler includes the terminal sigma=0 in num_inference_steps,
# but that terminal point does not run the transformer.
num_denoise_steps = 19
num_inference_steps = num_denoise_steps + 1

with install_h3_spark_attn(
    pipe.transformer,
    num_denoise_steps=num_denoise_steps,
    warmup_mode="warmup_steps",
    warmup_steps=4,
    dense_layers=0,
    topk_ratio=0.1,
):
    result = pipe(**inputs, num_inference_steps=num_inference_steps)

<a id="comfyui-installation"></a>

🧩 ComfyUI Installation

Spark-H3 v0.2.0 provides standalone nodes for ComfyUI 0.38.x–0.40.x and 0.42.x–0.44.x. Its isolated spark-h3-kitchen backend is installed alongside ComfyUI's official comfy-kitchen package instead of replacing it. Linux and Windows x86_64 packages are produced for SM86, SM89, and SM120. Choose the CUDA 13.0 package matching your operating system and GPU architecture. ComfyUI and model weights are not included.

For installation and example workflows, see the ComfyUI guide or 中文安装指南.

For reference-video compression in Ref2VA workflows, install the separate VPack v0.1.0 plugin.

Step-count convention

MiniMaxH3Scheduler includes the final σ=0 endpoint in num_inference_steps, so the default num_inference_steps=50 runs 49 denoising steps. See the Hugging Face scheduler documentation.

<!-- ### Benchmark comparability Match the **actual** `torch.compile` state across all Diffusers runs before comparing quality or speed. In a controlled 25-prompt H3 check, switching denoising compilation changed Spark PSNR by **3.15 dB**, despite otherwise matched settings. This is a protocol difference, not evidence of a Spark kernel regression. Do not mix compiled and uncompiled benchmark results. The sibling MiniMax-H3-Benchmark's standard Diffusers denoising runner and radial/attention harnesses require compilation and verify that all transformer blocks were wrapped. Do not mix their results with historical uncompiled experiments. `inputs` contains your pipeline's generation arguments. The context manager restores the original attention processors on exit. → See the [usage and configuration guide](h3_sparse_attention/README.md) for requirements, defaults, and options. -->

<a id="todo"></a> <a id="project-status"></a>

🧭 Project Status & Roadmap

The Diffusers and ComfyUI integrations are separate implementation tracks. Their status is listed independently below so that backend work is not confused with ComfyUI packaging or compatibility work.

Diffusers / Python

| Status | Item | Resources | |---|---|---| | ✅ Available | Spark attention integration for MiniMax-H3, with fused kernels for SM80, SM86, SM89, and SM120 | Usage and kernel documentation · Performance matrix | | ✅ Available | Ref2VA pipeline support and released inference examples | Spark-Ref2VA Preview | | 🗓️ Planned | Fused Spark kernels for SM90 and SM100 | Pending hardware resources | | ✅ Released | Spark-H3 technical report | arXiv:2611.24256 |

ComfyUI

| Version | Date | Status | Main improvements / expected updates | Release / tracking | |---|---|---|---|---| | v0.1.1 | 2026-10-09 | ✅ Released | First stable Linux packages for SM89 and SM120; fixed the v0.1.0 CUDA Graph allocation-lifetime issue; bundled five representative workflows | Release notes | | v0.1.2 | 2026-10-11 | ✅ Released | Added validated Windows SM89 and SM120 packages; corrected packaged workflows and optimized the LBH two-pass example | Release notes | | v0.1.3 | 2026-10-13 | ✅ Released | Added validated SM86 packages; integrated with KJNodes low-VRAM patches; added fidelity, speed, custom, and dense presets plus selectable dense backends | Release notes | | v0.1.4 | 2026-10-15 | ✅ Released | Added ComfyUI 0.40.x support, Ref2VA-aware sparse_scope, configurable producer_chunk, and in-node Ref2VA guidance | Release notes | | v0.1.5 | 2026-10-19 | ✅ Released | Added ComfyUI 0.42.x support through comfy-kitchen 0.2.39; released Linux and Windows SM86/SM89/SM120 packages, each also bundling wheels for ComfyUI 0.38.x–0.40.x | Release notes | | v0.2.0 | 2026-11-06 | ✅ Released | Decouples Spark-H3 from ComfyUI's official comfy-kitchen dependency by using an isolated backend; supports ComfyUI 0.38.x–0.40.x and 0.42.x–0.44.x; recommends the default 0.2.37 backend for better tested speed and stability | Release notes |

The v0.2.0 release supports ComfyUI 0.38.x–0.40.x and 0.42.x–0.44.x with Linux and Windows x86_64 packages for SM86, SM89, and SM120. See the ComfyUI guide for workflows and the installation guide for package details. Reference-video compression is provided separately by VPack.

🤝 Acknowledgments

Thanks to MiniMax-H3 and Sol-Attn / Sol-Engine for the model and attention infrastructure. See the third-party notices for kernel attributions and included licenses.

<a id="special-thanks"></a>

❤️ Special Thanks

  • Thanks to Smthem (GitHub · Bilibili) for support and help during the development of Spark-H3's ComfyUI plugin.
  • Thanks to AI绘画KK (GitHub · Bilibili) for valuable guidance and support in exploring and applying MiniMax-H3 workflows, and for helping communicate the community's need for Windows installation packages.
  • Thanks to AIwood爱屋研究室 (GitHub · Bilibili) for identifying a bug when Spark-H3 was used in a two-pass sampling workflow and suggesting a switch to Kitchen as the dense backend, which further improved the plugin's speedup ratio.

⭐ Star History

<p align="center"> <a href="https://www.star-history.com/?repos=zechengtang%2FSpark-H3&amp;type=date&amp;legend=top-left"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=zechengtang/Spark-H3&amp;type=date&amp;theme=dark&amp;legend=top-left"> <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=zechengtang/Spark-H3&amp;type=date&amp;legend=top-left"> <img alt="Spark-H3 GitHub star history chart" src="https://api.star-history.com/chart?repos=zechengtang/Spark-H3&amp;type=date&amp;legend=top-left" width="720"> </picture> </a> </p>

📄 License

Spark-Attn’s original code and documentation are licensed under the Apache License 2.0. Third-party components retain their original licenses and notices; see third-party notices. MiniMax-H3 model weights remain subject to their upstream license.