[None][feat] Add HunyuanVideo 1.5 text-to-video support to VisualGen - #15562
[None][feat] Add HunyuanVideo 1.5 text-to-video support to VisualGen#15562jloftin-nv wants to merge 8 commits into
Conversation
📝 WalkthroughWalkthroughAdds HunyuanVideo 1.5 single-GPU text-to-video support to TensorRT-LLM: a new ChangesHunyuanVideo 1.5 Text-to-Video Pipeline
Sequence DiagramsequenceDiagram
participant CLI as hunyuan_t2v.py
participant VisualGen
participant HunyuanVideo15Pipeline
participant QwenEncoder as Qwen2.5-VL Encoder
participant ByT5Encoder as ByT5 Encoder
participant Transformer as HunyuanVideo15Transformer3DModel
participant VAE
CLI->>VisualGen: generate(prompt, height, width, num_frames)
VisualGen->>HunyuanVideo15Pipeline: infer(req)
HunyuanVideo15Pipeline->>QwenEncoder: _get_mllm_prompt_embeds(prompt)
QwenEncoder-->>HunyuanVideo15Pipeline: prompt_embeds, prompt_embeds_mask
HunyuanVideo15Pipeline->>ByT5Encoder: _get_byt5_prompt_embeds(glyph_texts)
ByT5Encoder-->>HunyuanVideo15Pipeline: prompt_embeds_2, prompt_embeds_mask_2
HunyuanVideo15Pipeline->>HunyuanVideo15Pipeline: _prepare_latents()
loop Denoising steps
HunyuanVideo15Pipeline->>Transformer: forward_fn(latents, cond_latents, timestep, embeds)
Transformer-->>HunyuanVideo15Pipeline: noise_pred
HunyuanVideo15Pipeline->>HunyuanVideo15Pipeline: scheduler.step()
end
HunyuanVideo15Pipeline->>VAE: decode(latents)
VAE-->>HunyuanVideo15Pipeline: video frames
HunyuanVideo15Pipeline-->>VisualGen: PipelineOutput
VisualGen-->>CLI: saved video path(s)
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/visual_gen/models/hunyuan_t2v.py`:
- Line 1: The file hunyuan_t2v.py is missing the required NVIDIA copyright
header that must appear at the very beginning of all new Python files in the
repository. Add the NVIDIA copyright header preamble with the current year
before the existing module docstring that starts with "HunyuanVideo 1.5
Text-to-Video generation." The header should be placed as the first lines of the
file, preceding all other content including imports and docstrings.
- Line 25: The main function is missing an explicit return type annotation,
which violates the project's Python typing guidelines. Update the main function
signature to include an explicit return type annotation of None, since this
function does not return anything. Change the function definition from `def
main():` to include `-> None` in the signature to satisfy the typing
requirement.
In
`@tensorrt_llm/_torch/visual_gen/models/hunyuan_video1_5/transformer_hunyuan_video1_5.py`:
- Around line 958-959: The condition on line 958 uses `if timestep_r` to check
if the tensor is None, but since timestep_r is typed as
Optional[torch.LongTensor], this raises a RuntimeError when timestep_r contains
multiple elements because the truth value of multi-element tensors is ambiguous.
Replace the implicit truth value check with an explicit None check by changing
`if timestep_r` to `if timestep_r is not None` in the line that assigns
timestep_r to self.config.dtype.
In `@tests/unittest/_torch/visual_gen/test_hunyuan_video1_5_pipeline.py`:
- Around line 219-224: The TestHunyuanVideo15BatchGeneration class docstring
claims to test batch generation with list prompts, but the existing tests only
cover single-prompt behavior. Add a new test method to this class that
explicitly validates the current pipeline contract by passing multiple prompts
as input and asserting that a ValueError is raised (because effective batch size
> 1 is not supported). This ensures the test coverage aligns with the documented
class behavior and validates the expected error handling for batch inputs.
- Around line 149-164: The issue is that if _load_trtllm_pipeline fails on the
first line of the try block, trtllm_pipe is never assigned, causing an
UnboundLocalError in the finally block when _teardown_pipeline attempts to
reference it, which masks the original setup failure. Initialize trtllm_pipe to
None before the try block so the finally block can safely call
_teardown_pipeline even if setup fails. Apply the same pattern to all similar
try-finally blocks in the file (at lines 166-180, 230-247, and 265-283) where
other pipeline variables need initialization before their respective try blocks.
- Around line 386-401: The test_parameter_dtypes method requires CUDA to be
available but lacks a guard to skip the test when CUDA is unavailable, causing
it to fail on CPU-only environments. Add the same CUDA availability guard
decorator that is used by adjacent tests in the file to the
test_parameter_dtypes method to ensure it is skipped when CUDA is not available.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 24b4a132-6d82-4f00-8513-dee5c36edf15
📒 Files selected for processing (14)
docs/source/models/visual-generation.mdexamples/visual_gen/README.mdexamples/visual_gen/configs/hunyuan-t2v-fp8-1gpu.yamlexamples/visual_gen/models/hunyuan_t2v.pyexamples/visual_gen/serve/configs/hunyuan.ymltensorrt_llm/_torch/visual_gen/models/__init__.pytensorrt_llm/_torch/visual_gen/models/hunyuan_video1_5/__init__.pytensorrt_llm/_torch/visual_gen/models/hunyuan_video1_5/pipeline_hunyuan_video1_5.pytensorrt_llm/_torch/visual_gen/models/hunyuan_video1_5/timestep_embedding.pytensorrt_llm/_torch/visual_gen/models/hunyuan_video1_5/transformer_hunyuan_video1_5.pytensorrt_llm/_torch/visual_gen/pipeline_registry.pytests/integration/test_lists/test-db/l0_b200.ymltests/unittest/_torch/visual_gen/test_hunyuan_video1_5_pipeline.pytests/unittest/_torch/visual_gen/test_hunyuan_video1_5_transformer.py
e8446d4 to
ddffac0
Compare
|
/bot run |
| return x, gate_msa, shift_mlp, scale_mlp, gate_mlp | ||
|
|
||
|
|
||
| class HunyuanVideo15AdaLayerNormContinuous(torch.nn.Module): |
There was a problem hiding this comment.
Not a blocker, cross-cutting across both your VG ports: this AdaLayerNormContinuous / timestep-embedding / FeedForward stack is a near-duplicate of what Qwen-Image already has and what the GlmImage PR (#16018) adds again. visual_gen/modules/ has no home for these yet — could the most uniform ones (timestep embeddings first) move into a shared module instead of another copy, or is there a port-fidelity reason to keep per-model copies? Worth a team-sync call either way.
There was a problem hiding this comment.
Mainly just following precedent with each model having repeat/similar AdaNorms. Is it ok if I resolve this comment here and we can do a separate MR unifying timestep and AdaNorms?
Signed-off-by: Joseph Loftin <jloftin@nvidia.com>
Signed-off-by: Joseph Loftin <jloftin@nvidia.com>
Signed-off-by: Joseph Loftin <jloftin@nvidia.com>
Signed-off-by: Joseph Loftin <jloftin@nvidia.com>
Signed-off-by: Joseph Loftin <jloftin@nvidia.com>
Signed-off-by: Joseph Loftin <jloftin@nvidia.com>
Signed-off-by: Joseph Loftin <jloftin@nvidia.com>
cd9ee5b to
ef040c2
Compare
Signed-off-by: Joseph Loftin <jloftin@nvidia.com>
Summary by CodeRabbit
New Features
Documentation
Tests
Description
Added support for HunyuanVideo1.5 T2V pipeline along with unit tests and example to VisualGen. Wanted to get this merged then follow up with cache, parallelism, and maybe sage attention support
Test Coverage
Added test_hunyuan_video1_5_transformer.py and test_hunyuan_video1_5_pipeline.py
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.