Repository navigation
[None][perf] MiniMax-H3 Modeling V2: fused SM100 kernels, cross-block/cross-step AdaLN, VAE overlap, and 50L text encoder - #23284
Draft
luyiyun1021 wants to merge 9 commits into
Draft
luyiyun1021 wants to merge 9 commits into
luyiyun1021 wants to merge 9 commits into
Conversation
Add a VisualGen V2 catalog op for the shared DeCo-Attention kernels and select it for H3 CUTEDSL attention with deco_attention. H3 passes the key padding mask and the modality tags of the whole padded sequence, so the recipe also works with Ulysses. Calls the kernels do not take run unquantized with the recipe's padding semantics. Signed-off-by: Yiyun Lu <55233584+luyiyun1021@users.noreply.github.com>
Run base H3 and FastH3 only on Modeling V2. Remove the V1 package, its tests and test-list entries, the TLLM_VISUALGEN_MODELING2_H3 switch and the opt-in loader. register_pipeline takes a family router that receives the resolved checkpoint directory; the H3 family registers MiniMaxH3ModularPipeline with the former metadata and routes to h3_pipeline or fasth3. Remove code that only V1 used, with its tests: the TP process-group hooks in LLM attention, mapping, device mesh and AllReduce; the opt-in BF16 SwiGLU GEMM epilogue in GatedMLP and its QuACK wrapper; and the H3 Turbo LoRA name heuristic in runtime_lora.py. Import the TP text encoder only when one is built. Point the sleep, serve-endpoint and LoRA tests at V2 and add V2 cases for padding, DeCo layer selection and Turbo LoRA names. Signed-off-by: Yiyun Lu <55233584+luyiyun1021@users.noreply.github.com>
… into the catalog op deco_attention runs the calls its kernels do not take unquantized, with the same padding semantics, so callers no longer carry the fallback; H3 only delegates. The op moves the key padding mask to the device of q on both paths. The H3 fallback test becomes a catalog cell with per-sample padding. Signed-off-by: Yiyun Lu <55233584+luyiyun1021@users.noreply.github.com>
… attention ops Each dense catalog attention op states in key_padding() whether, under a given configuration, it excludes padded keys by any boolean mask, by a per-sample prefix, or not at all; FlashInfer takes no mask in quantized or causal calls. H3 reads the padding its attention accepts from the op its backend runs, from its own SDPA call for VANILLA, or from the prefix trimming of its TRTLLM attention, which takes no padding with a quantized recipe or skip-softmax. This replaces H3's hand-written backend table. With Ulysses, H3 now rejects quantized FLASHINFER and TRTLLM with a quantized recipe or skip-softmax when it loads. These configurations used to load and then raise during generation on every request whose packed length needs padding. The padding errors name the configurations that accept padding. Signed-off-by: Yiyun Lu <55233584+luyiyun1021@users.noreply.github.com>
Drop the model-specific MiniMax-H3 Notes section from docs/source/models/visual-generation.md (moving the checkpoint license link to examples/visual_gen/README.md), clarify target/family/catalog concepts in VisualGen Modeling V2 README, remove the deleted fuse_bf16_gate_up_swiglu argument from test_quant_ignore_runtime.py, drop the obsolete V1 sleep waive from waives.txt, and narrow types in pipeline.py and test_minimax_h3_transformer.py for Pyrefly. Signed-off-by: Yiyun Lu <55233584+luyiyun1021@users.noreply.github.com>
…wlist to NVIDIA#23019 Signed-off-by: Yiyun Lu <55233584+luyiyun1021@users.noreply.github.com>
Signed-off-by: Yiyun Lu <55233584+luyiyun1021@users.noreply.github.com>
…ling V2 parallel changes Signed-off-by: Yiyun Lu <55233584+luyiyun1021@users.noreply.github.com>
luyiyun1021
force-pushed
the
perf/minimax-h3-v2-fusion
branch
from
December 3, 2026 08:37
b2942ab to
bfa9794
Compare
There was a problem hiding this comment.
⚠️ Pyrefly: 79 diagnostics from your changes
Found after merging this PR (172fa93) into the latest main (86f778c). Line numbers refer to the merged code.
This check is advisory and does not block the PR for now. Some of the diagnostics below may come from a semantic conflict with the latest main, so please look at each one carefully and decide whether to fix it. Resolve this conversation before merging the PR.
Show the diagnostics
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/components/transformer.py:1038
[missing-attribute] Object of class `Tensor` has no attribute `linear`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/components/transformer.py:1066
[missing-attribute] Object of class `Tensor` has no attribute `linear`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/components/transformer.py:1066
[missing-attribute] Object of class `Tensor` has no attribute `linear`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/components/vae.py:144
[missing-attribute] Object of class `Tensor` has no attribute `weight`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/components/vae.py:145
[missing-attribute] Object of class `Tensor` has no attribute `eps`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/components/vae.py:148
[missing-attribute] Object of class `Tensor` has no attribute `weight`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/components/vae.py:148
[missing-attribute] Object of class `Tensor` has no attribute `eps`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/components/vae.py:155
[missing-attribute] Object of class `Tensor` has no attribute `weight`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/components/vae.py:156
[missing-attribute] Object of class `Tensor` has no attribute `eps`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/h3_pipeline/pipeline.py:301
[missing-attribute] Object of class `NoneType` has no attribute `encode`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:73
[unbound-name] `dsl_user_op` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:76
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:88
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:101
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:187
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:215
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:229
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:242
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:254
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:266
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:285
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:334
[unbound-name] `cute` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:349
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:367
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:386
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:400
[missing-attribute] No attribute `StructType` in module `cutlass._mlir.dialects.llvm`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:440
[missing-attribute] Object of type `Integer | Pointer | int | tuple[IntTuple, ...]` has no attribute `toint`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:441
[missing-attribute] Object of type `Integer | Pointer | int | tuple[IntTuple, ...]` has no attribute `toint`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:442
[missing-attribute] Object of type `Integer | Pointer | int | tuple[IntTuple, ...]` has no attribute `toint`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:443
[missing-attribute] Object of type `Integer | Pointer | int | tuple[IntTuple, ...]` has no attribute `toint`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:444
[missing-attribute] Object of type `Integer | Pointer | int | tuple[IntTuple, ...]` has no attribute `toint`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:445
[missing-attribute] Object of type `Integer | Pointer | int | tuple[IntTuple, ...]` has no attribute `toint`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:453
[missing-attribute] Object of type `Integer | Pointer | int | tuple[IntTuple, ...]` has no attribute `toint`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:454
[missing-attribute] Object of type `Integer | Pointer | int | tuple[IntTuple, ...]` has no attribute `toint`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/adaln_cute.py:478
[missing-attribute] No attribute `rsqrt` in module `cutlass.cute.math`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/ffn_swiglu_cute.py:71
[unbound-name] `dsl_user_op` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/ffn_swiglu_cute.py:264
[unbound-name] `cute` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/ffn_swiglu_cute.py:906
[unbound-name] `stage_bytes` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/ffn_swiglu_cute.py:907
[unbound-name] `desc_a_root` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/ffn_swiglu_cute.py:908
[unbound-name] `desc_b_roots` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/ffn_swiglu_cute.py:911
[unbound-name] `num_kphase` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/ffn_swiglu_cute.py:912
[unbound-name] `kphase_bytes` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/ffn_swiglu_cute.py:917
[unbound-name] `acc_tmem` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/ffn_swiglu_cute.py:920
[unbound-name] `idesc` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/fused_adaln.py:305
[unexpected-keyword] Unexpected keyword argument `num_warps` in function `_minimax_h3_adaln_pow2_bf16_kernel`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/fused_vae.py:283
[unexpected-keyword] Unexpected keyword argument `num_warps` in function `_minimax_h3_vae_qk_norm_rope_fp16_kernel`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/fused_vae.py:445
[unexpected-keyword] Unexpected keyword argument `num_warps` in function `_minimax_h3_vae_rmsnorm_fp16_kernel`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/fused_vae.py:575
[unexpected-keyword] Unexpected keyword argument `num_warps` in function `_minimax_h3_vae_scale_resid_rmsnorm_fp16_kernel`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/fused_vae.py:704
[unexpected-keyword] Unexpected keyword argument `num_warps` in function `_minimax_h3_vae_scale_resid_add_kernel`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/fused_vae.py:820
[unexpected-keyword] Unexpected keyword argument `num_warps` in function `_minimax_h3_vae_swiglu_fp16_kernel`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/qkv_qk_rope_cute.py:76
[unbound-name] `cutlass` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/qkv_qk_rope_cute.py:108
[unbound-name] `cute` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/qkv_qk_rope_cute.py:456
[missing-attribute] Object of type `Integer | Tensor | int | tuple[IntTuple, ...] | Unknown` has no attribute `to`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/qkv_qk_rope_cute.py:457
[missing-attribute] Object of type `Integer | Tensor | int | tuple[IntTuple, ...] | Unknown` has no attribute `to`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/qkv_qk_rope_cute.py:685
[missing-attribute] No attribute `rsqrt` in module `cutlass.cute.math`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/vae_qkv_qk_rope_cute.py:51
[unbound-name] `cutlass` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/vae_qkv_qk_rope_cute.py:74
[unbound-name] `cute` may be uninitialized
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/kernels/vae_qkv_qk_rope_cute.py:108
[missing-attribute] No attribute `rsqrt` in module `cutlass.cute.math`
tensorrt_llm/_torch/visual_gen/modeling_v2/models/minimax_h3/pipeline.py:754
[missing-attribute] Object of class `NoneType` has no attribute `vae_ranks`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:26
[missing-argument] Missing argument `num_latent_frames` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:26
[missing-argument] Missing argument `latent_height` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:26
[missing-argument] Missing argument `latent_width` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:26
[missing-argument] Missing argument `num_audio_latents` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:28
[unexpected-keyword] Unexpected keyword argument `video_frames` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:29
[unexpected-keyword] Unexpected keyword argument `video_height` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:30
[unexpected-keyword] Unexpected keyword argument `video_width` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:31
[unexpected-keyword] Unexpected keyword argument `audio_frames` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:40
[missing-attribute] Object of class `NoneType` has no attribute `text_dim`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:42
[missing-attribute] Object of class `NoneType` has no attribute `video_patch_dim`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:47
[missing-attribute] Object of class `NoneType` has no attribute `audio_in_channels`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:110
[missing-argument] Missing argument `num_latent_frames` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:110
[missing-argument] Missing argument `latent_height` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:110
[missing-argument] Missing argument `latent_width` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:110
[missing-argument] Missing argument `num_audio_latents` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:112
[unexpected-keyword] Unexpected keyword argument `video_frames` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:113
[unexpected-keyword] Unexpected keyword argument `video_height` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:114
[unexpected-keyword] Unexpected keyword argument `video_width` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:115
[unexpected-keyword] Unexpected keyword argument `audio_frames` in function `tensorrt_llm._torch.visual_gen.modeling_v2.models.minimax_h3.packing.build_packed_sequence`
tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py:118
[missing-attribute] Object of class `NoneType` has no attribute `text_dim`
…/cross-step AdaLN, VAE overlap, and 50L text encoder Optimize MiniMax-H3 BF16 forward inference in VisualGen Modeling V2 on top of PR NVIDIA#23013 (`22be854515`) while preserving V1 unchanged, keeping a single target, and adding no public config knobs: - Catalog (`catalog/gemm/`): - Add `bf16_gemm_quack.py` (`Bf16GemmQuack` OpWrapper) with pinned SM100 2-CTA 256x512 `swap_ab=True` BF16 GEMM, load-time `supports_linear()`, and per-call `can_use()` dynamic token-threshold dispatch for large projections (`down_proj`, `to_out`). - Extend `gate_up_swiglu_quack.py` with `pack_interleaved_swiglu_for_quack` and `GateUpSwiGLUFp16` (`gate_up_swiglu_quack_fp16`) for FP16+bias SwiGLU reuse in Video VAE FFN. - Family ops & kernels (`models/minimax_h3/{ops,kernels}/`): - Wrap all forward custom GPU kernels (CuTe-DSL and Triton) in stateless `OpWrapper`s with `reference()`, `is_valid()`, `CELLS`, and `ARCHS`, splitting static load-time eligibility (`supports_*`) from per-step tensor checks (`can_use`): `ops/qkv_qk_rope.py` (`qkv_qk_rope_cute.py`), `ops/ffn_swiglu.py` (`ffn_swiglu_cute.py` -> QuACK custom-op with runtime unfused fallback), `ops/vae.py` (`H3VaeQkvQkRope`, `H3VaeQkNormRope`, `H3VaeScaleResRmsNorm`, `H3VaeScaleResAdd`, `H3VaeRmsNorm`, `H3VaeSwiGLU`), and `ops/adaln.py` (`adaln_cute.py` -> Triton `fused_adaln.py` + cross-block `Ext`/`Final`). - Family components & shared pipeline (`models/minimax_h3/`): - Evaluate static kernel eligibility once at load time in `linear.py`, `mlp.py`, `attention.py`, and `vae.py`, collapsing duplicate backend/loop branches in `transformer.py`. - Add cross-step `prepare_adaln_plan()` (batching 50-layer `adaln_proj` BF16 at M=97 while keeping small FP32 `time_embedder` and `norm_out` per-step for bit-exactness under `allow_tf32=True`) and request-static `MiniMaxH3LayoutInfo` pack/slice/async validation. - Fold Audio VAE `weight_norm` hooks at load time and overlap Audio VAE decode on a secondary CUDA stream behind Video VAE decode. - Target (`models/minimax_h3/h3_pipeline/`): - Reuse the truncated 50-layer fused text encoder at `tp_size=1` for text-only prompts with lazy HF Qwen3-VL fallback for vision inputs. - Tests: - Add and extend unit tests across catalog and MiniMax-H3 family (`test_bf16_gemm_quack.py`, `test_gate_up_swiglu_quack.py`, `test_qkv_qk_rope.py`, `test_ffn_swiglu.py`, `test_vae.py`, `test_minimax_h3_fused_adaln.py`, `test_minimax_h3_v2_fusion.py`, and `test_minimax_h3_transformer.py`); `test_dependencies.py` passes with 0 V1 violations. Signed-off-by: Yiyun Lu <55233584+luyiyun1021@users.noreply.github.com>
luyiyun1021
force-pushed
the
perf/minimax-h3-v2-fusion
branch
from
December 3, 2026 12:11
bfa9794 to
172fa93
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Optimizes MiniMax-H3 BF16 forward inference in VisualGen Modeling V2 across Catalog, Model Family (
models/minimax_h3/), and existing Target (h3_pipeline/) without touching V1 or adding a new target, using fully automatic hardware/shape dispatch with zero new user knobs or environment variables:1. Architecture & Modeling V2 Placement
catalog/gemm/) — model-agnostic ops:bf16_gemm_quack.py:Bf16GemmQuack(OpWrapper)pinned SM100 2-CTA256x512 swap_ab=TrueBF16 GEMM for TDP-efficient large projections (down_proj,to_out).gate_up_swiglu_quack.py: addspack_interleaved_swiglu_for_quackandGateUpSwiGLUFp16(OpWrapper)(gate_up_swiglu_quack_fp16) for FP16+bias SwiGLU reuse in Video VAE FFN.models/minimax_h3/{ops,kernels}/) — H3-shaped & cross-op fused kernels behindOpWrapper:ops/qkv_qk_rope.py(H3QkvQkNormRope) wrappingkernels/qkv_qk_rope_cute.py(trtllm::minimax_h3_v2_qkv_qk_rope_cute); centralizes all hardware/shape/dtype/TP guards in.can_use(...).ops/ffn_swiglu.py(H3GateUpSwiGLU) dispatching SM100 H3 CuTe-DSLkernels/ffn_swiglu_cute.py(trtllm::minimax_h3_v2_ffn_swiglu_cute) -> cataloggate_up_swiglu_quack_bf16, keepingcomponents/mlp.pyat a single branch.ops/adaln.py(H3GateResNormModSM100 CuTe-DSLkernels/adaln_cute.py(trtllm::minimax_h3_v2_adaln_cute) -> Tritonkernels/fused_adaln.py, plus cross-block carryH3GateResNormModExt/H3GateResNormModFinal).ops/vae.py(H3VaeQkvQkRope,H3VaeScaleResRmsNorm,H3VaeRmsNorm) wrappingkernels/vae_qkv_qk_rope_cute.py(trtllm::minimax_h3_v2_vae_qkv_qk_rope_cute) andkernels/fused_vae.pywith centralized.can_use(...)guards.models/minimax_h3/):mlp.py,attention.py,vae.py, andtransformer.py.prepare_adaln_plan()batches all 50 layers' BF16adaln_projatM=97(bit-exact to per-stepM=2), while keeping tiny FP32time_embedderandnorm_out.linearper-step to prevent silent TF32 downcasting underallow_tf32=True.MiniMaxH3LayoutInfo(t2va/fl2vafast pack/slice, cachedadaln_indices, async per-step finite/nonzero checks).weight_normweight folding at load time + secondary CUDA stream overlap behind Video VAE decoding.models/minimax_h3/h3_pipeline/):text_encoder_tp.py) attp_size=1for text-only prompts (-15.29 GiBVRAM), with lazy HF Qwen3-VL fallback for vision inputs.modeling_v2/README.md):ops/, centralizingcan_use()guards for boundary-changing fusions, avoiding Cartesian-product loops, protecting small-MFP32 schedule layers from TF32 batching, and keeping shared runtime/media optimizations (tensorrt_llm/media/) in separate runtime PRs.2. Measured Performance & Lossless Quality (OCI GB200, 1344x768, 124 frames, 50 steps, BF16 VANILLA,
torch.compile=True, CUDA graph OFF)nvl72078-T14, 5-rep median, replayMATCH):gen_latency:126.601 s -> 123.890 s(-2.711 s/-2.14%,denoise:124.400 s -> 121.851 s, spread0.143%,0/5stalls)0.0494(gate<= 0.25), Audio spectral distance0.525 dB(gate<= 4.0 dB), VRAM-15.29 GiBnvl72023-T17, identicalquack-kernels==0.6.5runtime):gen_latency = 122.090 s(LPIPS0.0905, Audio0.470 dB)gen_latency = 119.991 s(-2.098 s/-1.72%faster than PR [None][perf] MiniMax-H3: GEMM-epilogue and fused-norm kernels, faster decode and encode #21549, LPIPS0.0494, Audio0.525 dB, zero C++.sorebuild)3. Test Plan & Verification
tests/unittest/_torch/visual_gen/modeling_v2/catalog/gemm/test_bf16_gemm_quack.py&test_gate_up_swiglu_quack.pytests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/ops/test_{qkv_qk_rope,ffn_swiglu,vae}.pytests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.pypre-commit(ruff, ruff-format, codespell, DCO, mock_interfaces 108/108) PASS;test_dependencies.py(test_v2_model_and_catalog_import_boundaries) PASS with 0 V1 backend exceptions;py_compile27/27 PASS.