Repository navigation
[diffusion] model: support FastH3 (4-step VSA-distilled MiniMax-H3) with a VSA-H3 attention backend - #37480
Conversation
BBuf
left a comment
There was a problem hiding this comment.
Change summary: this PR adds the FastH3 model/overlay and its fixed distilled sampling path, the learned to_gate_compress projection, a video_sparse_attn_h3 backend with an in-tree Triton/TMA block-sparse kernel, per-step denoising metadata, Ulysses support, docs, benchmarks, and unit/server coverage. The VSA math and tensor layout are broadly aligned with the FastVideo reference, but two model-contract paths currently fail open, so I am requesting changes.
flowchart LR
A["/v1/videos T2VA request"] --> B["FastH3 registry + pinned overlay"]
B --> C["FastH3 sampling/admission"]
C --> D["Per-step VSA-H3 metadata"]
D --> E["MiniMax-H3 Q/K/V + trained gate"]
E --> F["Ulysses all-to-all"]
F --> G["64-token tile pack/pool + top-k"]
G --> H["Triton sparse attention + compression"]
H --> I["Untile + DiT/VAEs"]
L["Legend: dashed border = changed in this PR"]
classDef changed stroke-dasharray: 5 5
class B,C,D,E,F,G,H,L changed
The registry recognizes the released or materialized FastH3 repository, applies the pinned base-H3 overlay, and enables the per-block compression gate. Admission then selects the five-point shifted sigma schedule. On every DiT step, the denoising stage installs segment/tile metadata; the attention layer sequence-shards Q/K/V and the gate under Ulysses, pools 64-token tiles, chooses the trained top-k policy, executes sparse attention, adds the gated pooled-value correction, and scatters the result back into packed-token order before the normal H3 output and VAE paths continue.
Historical coverage: I swept all 26 touched paths plus the relevant kernel/model-loading/sparse-attention risks through the SGLang maintainer-review corpus, then widened the pass to non-inline PR conversations. The available MiniMax optimization history is MiniMax-M2-only and has no direct H3/diffusion precedent, so I used the FastVideo implementation, the released FastH3 inference metadata, and the published checkpoint contents as the semantic references. The recurring relevant review expectation is that new model/kernel paths encode their checkpoint and schedule assumptions explicitly and exercise the claimed GPU/topology path.
Findings:
- [P1] Require every trained FastH3 gate weight —
python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py:809. The explicit zero-init policy bypasses the model-wide required-parameter pass, so an incomplete overlay can load successfully as a different model. - [P1] Reject non-distilled inference-step counts —
python/sglang/multimodal_gen/configs/sample/minimax_h3.py:311. The accepted value needs to be exactly five sigma points; otherwise the code generates and runs an off-distribution schedule instead of rejecting the request.
Validation performed: git diff --check, compileall, and the CI lint selection (F401,F821,UP037) pass on this head. I could not execute the Torch/pytest or GPU suites in the local environment. GitHub lint passed, but the base/extra GPU workflows stopped at pr-gate because the PR has no run-ci label, so the newly registered 4xH100 case and the VSA tests have not run in CI. Please run the relevant CI after the fixes. Also note that the H100 server case currently disables consistency, component-accuracy, and input-reference checks, so it is only a generation smoke test; the stated 4xH200 frame parity and B300 measurements remain manual evidence, especially for the SM103 path.
| quant_config=None, | ||
| prefix=f"{prefix}.to_gate_compress", | ||
| ) | ||
| self.to_gate_compress.weight.missing_param_init = "zeros" |
There was a problem hiding this comment.
[P1] Please fail closed when a trained FastH3 gate is missing. MiniMaxH3DiTModel.__init__() later marks every parameter without an explicit policy as missing_param_init = "error", but this explicit "zeros" survives that pass, and fsdp_load.py then synthesizes a zero tensor. Base H3 already represents the no-gate behavior with has_gate_compress=False; whenever this module exists, the FastH3 checkpoint is expected to provide each trained to_gate_compress.weight (the released checkpoint has one for every main block). An incomplete/broken overlay would therefore start successfully as a different pure-sparse model and silently change output quality. Please use the required/error policy here and add a missing-gate loading test.
There was a problem hiding this comment.
Fixed in bfbbd2d0b4: the explicit missing_param_init = "zeros" is removed, so to_gate_compress.weight falls under the model-wide required policy set by _mark_missing_params_required() and a checkpoint missing any gate now fails the load with the required-parameter error. Base H3 keeps the no-gate behaviour through has_gate_compress=False (no module is built). test_fasth3_gates_stay_bf16_under_runtime_quantization asserts the gate carries the error policy on the FastH3 meta model. Re-verified the released checkpoint still loads (all 50 gates present) with byte-identical output.
|
|
||
| num_inference_steps: int = 5 | ||
|
|
||
| def _validate(self) -> None: |
There was a problem hiding this comment.
[P1] Please enforce num_inference_steps == 5 in the FastH3 admission contract. This class documents five sigma points/four DiT evaluations, the released inference metadata pins the four DMD steps [999, 749, 500, 250], and the cookbook says not to send the base schedule. Today FastH3SamplingParams(..., num_inference_steps=50) passes this validator; timestep preparation then creates a 50-point shifted grid and runs 49 off-distribution DiT forwards instead of rejecting it. That is a silent correctness and latency failure for an otherwise accepted request. Please reject non-5 values here and add a negative test.
There was a problem hiding this comment.
Fixed in bfbbd2d0b4: FastH3SamplingParams._validate now rejects any num_inference_steps other than 5 with a message pointing to base MiniMax-H3 for other schedules; test_fasth3_sampling_defaults_and_task_rejection covers num_inference_steps=50. Warmup requests are unaffected since Req.set_as_warmup overrides the step count after admission. Cookbook wording updated to match. The branch is also rebased onto current main (docs conflict with the new SpargeAttention section resolved).
|
/tag-and-rerun-ci |
…ith a native VSA-H3 attention backend Adds FastVideo/FastVideo-FastH3-4-step-Preview-v1-VSA-DataFree as a MiniMax-H3 family variant, following the FastWan precedent and the support-new-models guideline (no core-file changes): - First bundled model overlay: materializes the flat native-Diffusers repo into the base-H3 partition layout (symlinks + a materializer that re-serializes the video VAE to source form bit-identically, injects the derivable rope.inv_freq bit-exactly, and patches VAE config class names). - FastH3PipelineConfig / FastH3SamplingParams / FastH3Pipeline: 5 sigma grid points (4 DiT forwards; the distilled schedule is the standard shift-12/3 grid), t2va-only admission via the release tasks contract, loud rejections for --model-variant, quality="high", ring/compile/BCG with VSA-H3. - New VIDEO_SPARSE_ATTN_H3 backend: segment-pure prefix tiles + (4,4,4) video tiles at 64-token granularity, in-tree Triton block-sparse forward (adapted from fastvideo-kernel, Apache-2.0), trained to_gate_compress compression branch (zero gates == pure sparse == base H3), exempt/compete key modes, vsa_dense_first_n_steps / vsa_dense_layers knobs, Ulysses supported, token refiner auto-falls back to dense FA. - Trained gates load as head-sharded bf16 ColumnParallelLinear on MiniMaxH3Attention, gated by arch.has_gate_compress. Verified on 4x H200 (768x1344): steady-state denoise 4.66 s at 5 s video, 10.18 s at 10 s video (1.33x over dense FA, output at parity with the FastVideo reference); 114 H3 unit tests green, including a sparsity->0 == dense kernel equivalence gate. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BJ7c2UYeWf3knMtLCEmkQN
…se style Non-behavioral pass over the FastH3 port, verified by the 114-test H3 unit sweep and a VSA-H3 e2e rerun (identical first-request denoise time): - Tile scratch buffer moves from a module-level holder onto the per-step metadata (tile_buf), matching Wan VSA's contract and dropping module state. - forward_varlen split into _tile_scores_and_mask and _add_compression_branch to meet the function-size rule. - Attribution headers in the vendored backend/kernel files follow the "Copied and adapted from" convention of video_sparse_attn.py. - attention_backends.mdx: vsa_dense_layers corrected to list[int] (the documented str form would not parse) and the vsa_tile_size row added. - Import order, keyword-form multi-arg calls, black/isort/ruff, unused import and unused test-helper parameter removed. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BJ7c2UYeWf3knMtLCEmkQN
Validate the Triton tile-64 kernel on B300 (SM103) and admit (10, 3) in the VSA-H3 resolver; SM120 stays out. Profiling a 10 s FastH3 request on 4x B300 showed the block-sparse kernel at 10 ms per DiT layer next to 12 ms of surrounding data movement: two index copies for tiling, a stack, three transposes, a bool mask and a sequential mask-to-index kernel, and two more index copies to untile. Replace them with: - one Triton pack kernel that gathers packed rows into the kernel's head-major padded tile layout and pools q/k/v per tile in the same pass; - top-k emitted directly as the kernel's index lists (prefix rows and the always-selected prefix columns are static per geometry); - one Triton untile kernel that folds in the gated compression branch; - TMA descriptors for the attention kernel loads (bit-identical, 1.2x). The workspace is process-wide, as the old tile buffer was. Per layer at the 10 s shape: 35 ms -> 24 ms; 10 s e2e 8.9 s -> 7.0 s, 15 s e2e 15.2 s -> 11.5 s (4x B300, stage sum). Outputs match the previous implementation bit-for-bit without the gate and within one bf16 ulp with it; the test file gains a sparsity-0.5 masked-dense reference check with gates for both modes. Co-Authored-By: Claude Fable 5.1 <[email protected]>
- Reject the FastVideo FastH3 LoRA bundles with a readable error: their .diff/.diff_b deltas and to_gate_compress.set_weight tensors match no LoRA mapping rule and were previously accepted silently. - Let the AdaLN cache builder read Diffusers-layout transformers (FastH3's diffusion_pytorch_model index, transformer_blocks.* names, bf16 time embedder) and resolve the cache partition through the pipeline config so FastH3, which rejects --model-variant, can serve a cache. - Log a clear no-op instead of silently mounting generic Cache-DiT when the request's DiT forwards do not exceed max_warmup_steps (FastH3: 4 <= 4). - Pin the VSA gates to unquantized bf16 under fp8 and kitchen_int8 in a unit test. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Add the B300 measurements (HTTP e2e median of three, denoise/decode/peak per duration), the validated deployment variants, the Cache-DiT no-op note, the LoRA bundle decision, and a `fasth3-t2va-vsa` denoise benchmark preset. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Style pass per the contributing guide: comments that restate the code or narrate the history are removed, docstrings are cut to the shape contracts callers need, and internal-consistency checks in the VSA-H3 kernel wrappers become a single contiguity assert as in sparse_linear_attn. Co-Authored-By: Claude Fable 5.1 <[email protected]>
… other overlay entries Moves the FastH3 overlay out of the source tree to kevin-mi/FastH3-4step-Preview-overlay (revision-pinned), matching the convention of the four existing overlay registry entries. Drops the model_overlays/ package-data plumbing; the sglang-side footprint is now the single registry entry. Tokenless materialization from the public overlay repo verified end-to-end (completeness check passes). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BJ7c2UYeWf3knMtLCEmkQN
Main now lets auxiliary components fall back from a DiT-only global backend on their own and rejects an explicit component backend that does not control every attention layer; the H3 text encoder has SDPA-only layers, so the override we documented is both unnecessary and refused. Remove it from the cookbook, backend docs, compatibility matrix, GPU case and benchmark preset. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…layout guard FastWan makes no special case for Cache-DiT on a distilled schedule; neither should FastH3 (the mount never hits and output is unchanged). The packed- layout invariant is already validated by the tile geometry builder. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ead VSA-H3 code The ring-parallel check in the attention core is unreachable: the pipeline config already rejects --ring-degree > 1 with VSA-H3 at startup. Shorten the non-LoRA tensor rejection to the repo's plain-message style and drop the narrative comments around the compression gate. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ke other DiTs Co-Authored-By: Claude Fable 5.1 <[email protected]>
Module-level imports and one-line names in the FastH3 tests, drop an unused helper argument in the VSA-H3 tests, and cut the backend doc to the constraints a user needs. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…tests Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Restore FastVideo's num_stages 2..7 search (their sm_121 optimum is 5, which the trimmed range could not reach) and divide the pooled tile sums by the tile size as upstream does instead of multiplying by a reciprocal. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…totuning Every new process re-ran the 12-config benchmark on the first request for each sequence length (2.3 s with warm binaries, ~20 s cold). Measured on B300 at 5/10/15 s, num_warps=4 wins everywhere and num_stages=5 is within 0.5% of the best; FastVideo reports the same Blackwell optimum. Pin both, like the other diffusion Triton kernels do. First call in a fresh process: 2.3 s -> 0.3 s; steady state unchanged (8.1 -> 8.0 ms per layer at 10 s). Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ction shift Co-Authored-By: Claude Fable 5.1 <[email protected]>
… section Co-Authored-By: Claude Fable 5.1 <[email protected]>
Review follow-ups: a FastH3 model must load every to_gate_compress.weight, so the parameter now takes the model-wide required policy instead of a synthesized zero; and FastH3SamplingParams rejects any num_inference_steps other than 5, since the distilled schedule is the four DMD forwards. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…repo id Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
/rerun-failed-ci |
|
/tag-and-rerun-ci |
|
/tag-and-rerun-ci |
|
/tag-and-rerun-ci |
…th a VSA-H3 attention backend (sgl-project#37480) Co-authored-by: Claude Fable 5 <[email protected]>
Motivation
Add FastVideo/FastVideo-FastH3-4-step-Preview-v1-VSA-DataFree, the 4-step DMD2 distillation of MiniMax-H3 trained with Video Sparse Attention (0.9 sparsity, 64-token tiles), together with the
video_sparse_attn_h3backend it was trained for.4x B300, 1344x768 at 24 fps with audio, bf16 eager, Ulysses 4,
VSA_sparsity0.9, seed 1000. Clean E2E is the client wall clock of a/v1/videosrequest againstsglang serveincluding decode, muxing and file output (median of three after one warm request); the stage columns are the server timings of the same request. H3 aligns the requested durations to 124, 243 and 362 frames.All three satisfy client RTF <= 1.0. For reference, FastVideo's published 4x B200 VSA numbers for the same shapes are 6.1 / 12.0 / 15.5 s, and vllm-project/vllm-omni#6909 reports 8.68 s clean E2E at 10 s and 14.18 s at 15 s on 8x B300 (1.383 s and 2.379 s per forward). Dense FA4 on the same weights and GPUs: 3.77 / 9.84 / 18.45 s (
sglang generate, stage sum).Modifications
FastH3PipelineConfig/FastH3SamplingParams/FastH3Pipelineare thin MiniMax-H3 variants that reuse every H3 stage, loader and admission path; no core files change. The flat native-Diffusers repo is materialized into the base-H3 layout by a revision-pinned model overlay (kevin-mi/FastH3-4step-Preview-overlay@f769cb80, same mechanism as the LTX-2.3 / JoyAI / SANA-WM entries). The distilled schedule is the standard shift-12/3 sigma grid atnum_inference_steps=5(four DiT forwards); no DMD plumbing.has_gate_compressadds the trained per-blockto_gate_compressprojection, kept bf16 and unquantized; base H3 loads zeros and runs pure sparse.--attention-backend video_sparse_attn_h3). Segment-pure prefix tiles plus (4, 4, 4) video tiles over H3's packed[text | keyframes | audio | video]sequence; the FastVideo tile-64 Triton kernel with TMA loads and a pinned launch config; one fused pack-and-pool kernel, top-k emitted directly as kernel index lists, one fused untile with the compression branch folded in. Knobs:VSA_sparsity,vsa_mode(exempt/compete),vsa_dense_first_n_steps,vsa_dense_layers. Only the DiT runs sparse; the token refiner, text encoder and VAEs keep their dense defaults. Ulysses supported; ring,torch.compileand breakable CUDA graph rejected. Validated on SM90, SM100 and SM103.--model-variant,quality="high",fl2va/ref2va, anynum_inference_stepsother than 5,vsa_tile_size != 64, a checkpoint missing any trainedto_gate_compress.weight(required parameter, never synthesized), and the sibling FastH3 LoRA bundles (their.diff/.diff_b/set_weighttensors match no LoRA mapping rule and would otherwise be dropped silently).test_minimax_h3_fasth3.py(5),test_vsa_h3_attention.py(6, including a sparsity-0.5 masked-dense reference with gates for both modes), GPU casefasth3_t2va_vsa_4gpu_h100, cookbook section, attention-backends and compatibility-matrix entries,fasth3-t2va-vsabenchmark preset.Validated deployments on 4x B300 at 5 s: tp2 x ulysses2 (3.42 s, 61 GB),
--use-fsdp-inference(3.42 s, 50 GB),--quantization fp8(2.93 s, 63 GB, gates stay bf16),--quantization kitchen_int8(functional),num_outputs_per_promptfan-out,torch_sdpaandsage_attndense fallbacks. Rejected with a clear message:subblock_sparse_attnon SM103 (sm_100a-only kernel), the AdaLN cache (requires--model-variant), and the LoRA bundle.SGLANG_CACHE_DIT_ENABLED=1behaves as on FastWan: mounts, never hits at four forwards, output unchanged.Accuracy Tests
The port follows FastVideo's
video_sparse_attn_h3backend andblock_sparse_attn_triton.py: same tile geometry, pooling, top-k budgets (exempt/compete), compression branch and online-softmax kernel. On 4x H200 the VSA-H3 output was checked frame by frame against the FastVideo upstream reference for the same prompt and seed and judged at parity. The fused data path is bit-identical to the original port without the gate and within one bf16 ulp with it; the unit test compares the kernel against an fp32 masked-dense reference at sparsity 0.5 with gates in both modes.4x B300, 1344x768, 5 s, seed 1000, t = 0.5 / 2.5 / 4.5 s:
Note for reviewers: the 4-step schedule amplifies rounding-level differences (Ulysses vs TP2 x Ulysses2, fp8, one-ulp kernel changes) into a different but equally coherent sample from the same seed, so SSIM against a single-seed reference is not a meaningful gate for this model.
Speed Tests and Profiling
compare_perf.py, dense FA4 baseline vs VSA-H3 on the same weights (sglang generate, 4x B300, 2-step warmup):Profile-driven: the first trace showed the sparse kernel at 10 ms per DiT layer next to 12 ms of tile gather/scatter, stack, transposes and mask-to-index; the fused path brings that bookkeeping to about 1 ms per layer (35 to 24 ms per layer at 10 s). Remaining per-layer budget at 10 s: attention 9.0 ms, GEMMs 8.4 ms, all-to-all 2.5 ms. The kernel launch config is pinned from a 12-config sweep on B300 (
num_warps=4,num_stages=5), so a fresh process pays 0.3 s on its first sparse call instead of a 2.3 s autotune per sequence length.Known limitations
FastVideo-FastH3-4-step-Preview-v1-LoRAadapters are out of scope by design: fusing them onto base H3 reproduces the merged checkpoint this PR serves.Checklist
CI States
Latest PR Test (Base): ✅ Run #33629244466
Latest PR Test (Extra): ❌ Run #33629244087
Latest PR Test (AMD ROCm 7.2): ⏳ Run #33629244460