Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ComfyUI-MiniMax-H3-FastVideo-Experimental

⚠️ EXPERIMENTAL — for testers only.

This node has been tested on a single machine (RTX 3090 Ti, Windows, SwarmUI + ComfyUI). It requires a very specific set of files, a compatible GPU, and a non-trivial setup process. If you are not comfortable debugging Python environments and ComfyUI internals, please wait for an official integration. Things will break. There is no support guarantee.


A ComfyUI custom node that routes MiniMax H3 diffusion transformer attention through FastVideo's Video Sparse Attention (VSA). Combined with FastVideo's 4-step distillation LoRA, it produces watchable draft video in under a minute on a 24 GB card.

VSA is a speed optimization for attention, not a memory optimization — it lets attention compute skip most of its work by only attending to a small subset of block-level "important" tokens (selected by a trained gate). It does not reduce activation memory, so it will not fit longer/higher-resolution videos that don't already fit under dense attention.

Measured performance

RTX 3090 Ti, 24 GB, 5-second video at 0.8 MP, sampling-only wall time (excludes model load and VAE decode):

Configuration Steps topk s/step Sampling
Base H3, no LoRA, no VSA (reference) 20 24.6 8:12
LoRA + VSA @ topk=1.0 (dense) 4 1.0 39.4 2:37
LoRA + VSA @ topk=0.75 4 0.75 31.6 2:06
LoRA + VSA @ topk=0.50 4 0.50 25.5 1:41
LoRA + VSA @ topk=0.10 (recommended for drafts) 4 0.10 12.3 0:49

Speedup vs 20-step base: roughly 3× at topk=1.0 (best quality with this LoRA) and 10× at topk=0.10 (draft quality).

Notes:

  • SageAttention and ComfyKitchen were tested at topk=0.10 on 5 s / 0.8 MP clips and made no measurable difference — VSA fully dominates the attention cost at that sparsity. They might help more at longer videos or lower topk, but that was not tested here.
  • Per-step time is essentially identical at 4 vs 8 steps (12.3 vs 12.6 s/step). The LoRA is trained for 4 steps; more steps do not improve quality noticeably but may need more tests.
  • ComfyUI was launched with these extra flags on the test machine, in case it helps reproduce the numbers: --fast fp16_accumulation cublas_ops --preview-method latent2rgb
  • If you hit OOM errors, lower the resolution or shorten the video. VSA does not reduce activation memory, so long/high-res clips can exceed 24 GB even though attention itself is cheaper.

Quality trade-off (observed on this hardware)

  • topk=0.10 — great for drafts. Small details (faces, text, thin lines) can shift slightly frame-to-frame.
  • topk=0.50–0.75 — noticeably better on small detail. Some sparse-attention flicker remains.
  • topk=1.0 — best quality this LoRA can produce. Detail shift mostly gone.
  • Base at 20 steps — cleanest overall (nothing skipped, longest schedule) but ~10× slower.

Higher resolution helps VSA quality (more tokens = more blocks = the gate has more to choose from) but the 3090 is close to its VRAM ceiling already at 0.8 MP / 5 s.

Who this is for

  • You already have MiniMax H3 running in ComfyUI
  • You want to test FastVideo's VSA approach right now, before official tooling exists
  • You understand this is a research-grade port and may need fixing as upstream changes

Only tested on RTX 3090 Ti. Other GPUs may or may not work — feedback welcome.

If you want something stable and well-supported, wait. FastVideo and/or Comfy-Org will likely publish an official integration. This repo exists for people who can't wait.


Requirements

Requirement Version
GPU NVIDIA CUDA GPU with Triton support. Only tested on RTX 3090 Ti.
VRAM ~22 GB peak at 0.8 MP / 5 s. Longer or higher-res videos may not fit on 24 GB.
RAM 32 GB minimum, 64 GB recommended
ComfyUI 0.30.0+ (native MiniMax H3 support required)
PyTorch 2.4+
Triton 3.6+
CUDA 12+
Base model minimax_h3_fl2va_pruned_int8_convrot.safetensors from Comfy-Org/MiniMax-H3
LoRA + gate See below

Installation

Step 1 — Install the vsa package (FastVideo's Triton kernel)

The vsa pip package tries to compile a Hopper CUDA extension (block_sparse_h100.cu, -arch=sm_90a) and will fail on non-Hopper cards. The workaround is to grab just the Python sources from the package and drop them where Python can find them — the Triton fallback then activates automatically.

What worked on the test machine (portable ComfyUI / SwarmUI, Windows):

  1. Download the source tarball for vsa==0.0.3 from PyPI or FastVideo's GitHub release.
  2. Extract it. You want the vsa/ directory inside (contains __init__.py, block_sparse_attn_triton.py, block_sparse_wrapper.py, index.py).
  3. Copy that vsa/ directory into your Comfy Python's import path. For the portable install used here that was <comfy>/python_embeded/vsa/ (portable Python has python_embeded on sys.path). For a standard pip-managed Python it would be .../site-packages/vsa/.
  4. pip install pytestvsa imports it at module load.

Verify with python -c "import vsa; print(vsa)" — no CUDA compile, no errors.

If your GPU is Hopper (H100/H200, SM 9.0), pip install vsa should Just Work and use the CUDA kernel automatically. The workaround above is only needed on non-Hopper cards.

Step 2 — Clone this node

cd ComfyUI/custom_nodes
git clone https://github.com/barelymining/ComfyUI-MiniMax-H3-FastVideo ComfyUI-MiniMax-H3-FastVideo

Or copy __init__.py and nodes.py manually into custom_nodes/ComfyUI-MiniMax-H3-FastVideo/.

Step 3 — Get the LoRA and gate files

You need two files from the companion HuggingFace repo:

  • fasth3_vsa_4-steps-v5.safetensors (2.05 GB) — the LoRA
  • fasth3_vsa_gate.safetensors (3.6 GB) — the gate weights

Place both in ComfyUI/models/loras/ (or any subfolder — ComfyUI discovers recursively).

These were converted from FastVideo's VSA-DataFree checkpoint into ComfyUI-native format (fused QKV LoRA, projected AdaLN, extracted gate weights). Conversion scripts are included in the HuggingFace repo if you want to re-run them yourself.

Coming soon: The converted LoRA and gate files will be uploaded to HuggingFace shortly. Check back here for the link.

Step 4 — Restart ComfyUI


Workflow

Load Diffusion Model (pruned INT8 FL2VA base)
    ↓
LoraLoader
    lora_name: fasth3_vsa_4-steps-v5.safetensors
    strength:  1.0
    ↓
MiniMax H3 VSA (FastVideo + gate)     ← this node
    gate_file:   fasth3_vsa_gate.safetensors
    topk_ratio:  0.10   (drafts) or 1.0 (finals)
    min_tokens:  4096
    ↓
KSampler
    steps: 4
    cfg:   1.0
    sampler:   euler
    scheduler: simple
    ↓
VAE Decode

The node appears under the H3 Acceleration category in ComfyUI's node browser.


Settings

Setting Value Note
Steps 4 Distillation was trained for 4 steps. More steps do not help.
CFG 1.0 Distilled models use guidance-free sampling
Sampler / Scheduler euler + simple Safe default
topk_ratio 0.10 (drafts) / 1.0 (finals) 0.10 = fast, 1.0 = best quality this LoRA can produce
min_tokens 4096 Below this the node falls back to dense attention
LoRA strength 1.0 Do not reduce — distillation LoRAs are calibrated at full strength

How it works (brief)

FastVideo's VSA adds a small trained to_gate_compress layer to each H3 transformer block. At inference time this layer scores each token, and only the top-K scoring 64-token blocks attend to each query — skipping ~90% of attention computation at topk_ratio=0.10.

Standard ComfyUI LoRA loading can't inject new layers, so the gate weights ship separately. This node:

  1. Loads the gate weights at node-apply time (kept CPU-pinned to save VRAM)
  2. Injects a to_gate_compress linear layer into each attention module
  3. Patches each block's attn.forward to route through FastVideo's Triton VSA kernel
  4. Streams each block's gate weight to GPU on demand during the forward pass (only ~73 MB at a time on device)

Sample videos

See the Releases page for sample outputs at different topk_ratio values with prompts and settings included.


Known limitations

  • Tested on one machine only (RTX 3090 Ti, 24 GB, Windows, SwarmUI + ComfyUI embedded Python)
  • FL2VA base only — T2VA, Ref2VA, L2VA variants would need matching FastVideo LoRAs (not yet released)
  • Text encoder and VAE do not benefit from VSA
  • Some FastVideo LoRA keys are intentionally dropped during conversion (24 token_refiner.* keys, 17 module-level diff/bias tweaks). Quality impact appears negligible
  • Small-detail flicker at low topk_ratio is inherent to sparse attention — raise topk or use base model at 20 steps if it matters

Attribution

About

A ComfyUI custom node that routes MiniMax H3 diffusion transformer attention through FastVideo's Video Sparse Attention (VSA). Combined with FastVideo's 4-step distillation LoRA, it produces watchable draft video in under a minute on a 24 GB card.

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages