Skip to content

Commit c8d6a2b

Browse files
committed
Scope FastH3 metadata loading to the MiniMax-H3 pipeline
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
1 parent ba6c890 commit c8d6a2b

9 files changed

Lines changed: 42 additions & 56 deletions

File tree

‎docs/source/models/visual-generation.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ Tile geometry and blending follow the loaded Diffusers VAE.
173173
- FastH3 uses the MiniMax-H3 pipeline and transformer architecture with a
174174
distilled 4-step checkpoint. Dense attention and model-specific VSA are supported.
175175
For single-GPU text-to-video with audio, enable VSA using
176-
`fasth3-bf16-trtllm-vsa-1gpu.yaml` or `fasth3-bf16-cutedsl-vsa-1gpu.yaml`.
177-
Both preserve the trained compression gate and dense text/audio routes.
176+
`fasth3-bf16-trtllm-vsa-1gpu.yaml`. To use CUTEDSL instead, set
177+
`attention_config.backend: CUTEDSL` in that config.
178+
Both backends preserve the trained compression gate and dense text/audio routes.
178179
CUTEDSL VSA requires supported Blackwell hardware and at most 4096 tiles;
179180
unsupported shapes fail explicitly rather than silently running dense attention.
180181
- Text-to-video (T2VA), first/last-frame-to-video (FL2VA), and reference-to-video

‎examples/visual_gen/README.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ python models/ltx2.py --visual_gen_args configs/ltx2-1gpu.yaml
2626
# FP8 blockwise config: configs/minimax-h3-fp8-blockwise-1gpu.yaml.
2727
# 8-GPU Ulysses config: configs/minimax-h3-bf16-8gpu.yaml.
2828
python models/minimax_h3.py --model <approved-checkpoint> --visual_gen_args configs/minimax-h3-bf16-1gpu.yaml
29-
python models/fasth3.py --visual_gen_args configs/fasth3-bf16-1gpu.yaml
30-
# FastH3 VSA on Blackwell, with either attention backend:
29+
# FastH3 VSA on Blackwell:
3130
python models/fasth3.py --visual_gen_args configs/fasth3-bf16-trtllm-vsa-1gpu.yaml
32-
python models/fasth3.py --visual_gen_args configs/fasth3-bf16-cutedsl-vsa-1gpu.yaml
3331
python models/flux1.py --visual_gen_args configs/flux1-dev-fp4-1gpu.yaml
3432
python models/flux2.py --visual_gen_args configs/flux2-dev-fp4-1gpu.yaml
3533
python models/cosmos3_ti2v.py --visual_gen_args configs/cosmos3-nano-1gpu.yaml --prompt "A robot arm picks fruit in a grocery store"

‎examples/visual_gen/configs/fasth3-bf16-1gpu.yaml‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎examples/visual_gen/configs/fasth3-bf16-cutedsl-vsa-1gpu.yaml‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎examples/visual_gen/models/fasth3.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def main() -> None:
3232
)
3333
parser.add_argument(
3434
"--visual_gen_args",
35-
default="configs/fasth3-bf16-1gpu.yaml",
35+
default="configs/fasth3-bf16-trtllm-vsa-1gpu.yaml",
3636
help="Path to YAML config (same as trtllm-serve --visual_gen_args).",
3737
)
3838
parser.add_argument(

‎tensorrt_llm/_torch/visual_gen/config.py‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,6 @@ def from_pretrained(
635635
resolved_pipeline_config = dict(args.pipeline_config) if args else {}
636636
extra_attrs.update(resolved_pipeline_config)
637637

638-
fastvideo_inference_path = checkpoint_path / "fastvideo_inference.json"
639-
if fastvideo_inference_path.exists():
640-
with open(fastvideo_inference_path) as f:
641-
fastvideo_inference = json.load(f)
642-
if str(fastvideo_inference.get("schema_version", "")).startswith("fasth3-"):
643-
extra_attrs["fastvideo_inference"] = fastvideo_inference
644-
645-
646638
h3_workflow = resolved_pipeline_config.get("workflow")
647639
if h3_workflow is not None:
648640
if h3_workflow not in ("fl2va", "ref2va"):

‎tensorrt_llm/_torch/visual_gen/models/minimax_h3/pipeline_minimax_h3.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717

1818
"""TRT-LLM VisualGen pipeline for MiniMax-H3 FL2VA and Ref2VA checkpoints."""
1919

20+
import json
2021
import time
2122
from collections.abc import Iterator
2223
from contextlib import contextmanager, nullcontext
2324
from io import BytesIO
25+
from pathlib import Path
2426
from typing import TYPE_CHECKING, Any, Optional
2527

2628
import numpy as np
@@ -307,9 +309,7 @@ def setup_parallel_vae(self) -> None:
307309

308310
@property
309311
def default_generation_params(self) -> dict:
310-
fastvideo_inference = getattr(self.pipeline_config, "extra_attrs", {}).get(
311-
"fastvideo_inference", {}
312-
)
312+
fastvideo_inference = getattr(self, "_fastvideo_inference", {})
313313
return {
314314
# MiniMax-H3 derives the default canvas from the first present
315315
# keyframe, or from 16:9 for T2VA.
@@ -413,6 +413,14 @@ def load_standard_components(
413413
del kwargs
414414
skip_components = skip_components or []
415415

416+
self._fastvideo_inference = {}
417+
fastvideo_inference_path = Path(checkpoint_dir) / "fastvideo_inference.json"
418+
if fastvideo_inference_path.exists():
419+
with fastvideo_inference_path.open() as f:
420+
fastvideo_inference = json.load(f)
421+
if str(fastvideo_inference.get("schema_version", "")).startswith("fasth3-"):
422+
self._fastvideo_inference = fastvideo_inference
423+
416424
if not _component_skipped(skip_components, PipelineComponent.TOKENIZER):
417425
self.tokenizer = Qwen2TokenizerFast.from_pretrained(
418426
checkpoint_dir,

‎tests/unittest/_torch/visual_gen/test_minimax_h3_pipeline.py‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,26 @@ def test_default_generation_steps_match_reference_app() -> None:
468468
assert pipeline.default_generation_params["num_inference_steps"] == 28
469469

470470

471-
def test_fasth3_generation_steps_follow_inference_contract() -> None:
471+
@pytest.mark.parametrize(
472+
"manifest, expected_steps",
473+
[
474+
(None, 28),
475+
({"schema_version": "fasth3-inference-contract-v1", "num_inference_steps": 5}, 5),
476+
({"schema_version": "fasth3-inference-contract-v1"}, 28),
477+
({"schema_version": "other-model-v1", "num_inference_steps": 5}, 28),
478+
],
479+
)
480+
def test_fasth3_generation_steps_follow_inference_contract(
481+
tmp_path: Path, manifest: dict | None, expected_steps: int
482+
) -> None:
483+
if manifest is not None:
484+
(tmp_path / "fastvideo_inference.json").write_text(json.dumps(manifest))
472485
pipeline = _SyntheticMiniMaxH3Pipeline()
473-
pipeline.pipeline_config.extra_attrs = {"fastvideo_inference": {"num_inference_steps": 5}}
486+
pipeline.load_standard_components(
487+
str(tmp_path), torch.device("cpu"), skip_components=list(PipelineComponent)
488+
)
474489

475-
assert pipeline.default_generation_params["num_inference_steps"] == 5
490+
assert pipeline.default_generation_params["num_inference_steps"] == expected_steps
476491

477492

478493
def test_hf_download_is_scoped_to_the_supported_h3_components(
@@ -564,7 +579,13 @@ def test_fasth3_manifest_metadata_controls_pipeline_defaults(tmp_path: Path) ->
564579

565580
config = DiffusionPipelineConfig.from_pretrained(str(tmp_path))
566581

567-
assert config.extra_attrs["fastvideo_inference"]["num_inference_steps"] == 5
582+
assert "fastvideo_inference" not in config.extra_attrs
583+
pipeline = _SyntheticMiniMaxH3Pipeline()
584+
pipeline.pipeline_config = config
585+
pipeline.load_standard_components(
586+
str(tmp_path), torch.device("cpu"), skip_components=list(PipelineComponent)
587+
)
588+
assert pipeline.default_generation_params["num_inference_steps"] == 5
568589

569590

570591
def test_infer_supports_a_last_frame_without_a_first_frame(

‎tests/unittest/_torch/visual_gen/test_minimax_h3_vsa.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55
import torch
66

7-
from tensorrt_llm._torch.visual_gen.attention_backend.trtllm import TrtllmAttention
7+
from tensorrt_llm._torch.visual_gen.attention.backends.trtllm import TrtllmAttention
88
from tensorrt_llm._torch.visual_gen.models.minimax_h3.vsa import (
99
build_h3_vsa_metadata,
1010
h3_vsa_attention,

0 commit comments

Comments
 (0)