Skip to content

[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
NVIDIA:mainfrom
luyiyun1021:perf/minimax-h3-v2-fusion
Draft

luyiyun1021 wants to merge 9 commits into
NVIDIA:mainfrom
luyiyun1021:perf/minimax-h3-v2-fusion

Conversation

@luyiyun1021

@luyiyun1021 luyiyun1021 commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Stacked on PR #23013 (12d65b29cb, refactor/visualgen-h3-retire-v1). Base will be retargeted to main cleanly once PR #23013 merges.

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 (catalog/gemm/) — model-agnostic ops:
    • bf16_gemm_quack.py: Bf16GemmQuack(OpWrapper) pinned SM100 2-CTA 256x512 swap_ab=True BF16 GEMM for TDP-efficient large projections (down_proj, to_out).
    • gate_up_swiglu_quack.py: adds pack_interleaved_swiglu_for_quack and GateUpSwiGLUFp16(OpWrapper) (gate_up_swiglu_quack_fp16) for FP16+bias SwiGLU reuse in Video VAE FFN.
  • Model Family Ops & Kernels (models/minimax_h3/{ops,kernels}/) — H3-shaped & cross-op fused kernels behind OpWrapper:
    • ops/qkv_qk_rope.py (H3QkvQkNormRope) wrapping kernels/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-DSL kernels/ffn_swiglu_cute.py (trtllm::minimax_h3_v2_ffn_swiglu_cute) -> catalog gate_up_swiglu_quack_bf16, keeping components/mlp.py at a single branch.
    • ops/adaln.py (H3GateResNormMod SM100 CuTe-DSL kernels/adaln_cute.py (trtllm::minimax_h3_v2_adaln_cute) -> Triton kernels/fused_adaln.py, plus cross-block carry H3GateResNormModExt / H3GateResNormModFinal).
    • ops/vae.py (H3VaeQkvQkRope, H3VaeScaleResRmsNorm, H3VaeRmsNorm) wrapping kernels/vae_qkv_qk_rope_cute.py (trtllm::minimax_h3_v2_vae_qkv_qk_rope_cute) and kernels/fused_vae.py with centralized .can_use(...) guards.
  • Model Family Components & Shared Pipeline (models/minimax_h3/):
    • Collapsed duplicate backend/loop branches in mlp.py, attention.py, vae.py, and transformer.py.
    • Cross-step prepare_adaln_plan() batches all 50 layers' BF16 adaln_proj at M=97 (bit-exact to per-step M=2), while keeping tiny FP32 time_embedder and norm_out.linear per-step to prevent silent TF32 downcasting under allow_tf32=True.
    • Request-static MiniMaxH3LayoutInfo (t2va/fl2va fast pack/slice, cached adaln_indices, async per-step finite/nonzero checks).
    • Audio VAE weight_norm weight folding at load time + secondary CUDA stream overlap behind Video VAE decoding.
  • Existing Target (models/minimax_h3/h3_pipeline/):
    • Reuse truncated 50-layer fused text encoder (text_encoder_tp.py) at tp_size=1 for text-only prompts (-15.29 GiB VRAM), with lazy HF Qwen3-VL fallback for vision inputs.
  • Modeling V2 Guide (modeling_v2/README.md):
    • Clarifies Catalog vs. Family kernel placement, keeping same-boundary dispatch inside ops/, centralizing can_use() guards for boundary-changing fusions, avoiding Cartesian-product loops, protecting small-M FP32 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)

3. Test Plan & Verification

  • Added/extended unit tests mirroring source ownership:
    • tests/unittest/_torch/visual_gen/modeling_v2/catalog/gemm/test_bf16_gemm_quack.py & test_gate_up_swiglu_quack.py
    • tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/ops/test_{qkv_qk_rope,ffn_swiglu,vae}.py
    • tests/unittest/_torch/visual_gen/modeling_v2/models/minimax_h3/components/test_minimax_h3_v2_fusion.py
  • Verified locally: pre-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_compile 27/27 PASS.
  • Note: GPU unit tests and post-refactor E2E regression run will be verified in CI / once OCI maintenance finishes.

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
luyiyun1021 force-pushed the perf/minimax-h3-v2-fusion branch from b2942ab to bfa9794 Compare December 3, 2026 08:37

@github-actions github-actions Bot Dec 3, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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`

Full reports and workflow logs

…/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
luyiyun1021 force-pushed the perf/minimax-h3-v2-fusion branch from bfa9794 to 172fa93 Compare December 3, 2026 12:11

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant