Add HunyuanVideo-1.5 contrib model#130
Open
jimburtoft wants to merge 4 commits intoaws-neuron:mainfrom
Open
Conversation
8.33B DiT text-to-video pipeline on trn2.3xlarge (TP=4, NKI flash attention). 55s E2E with CFG, 25s without. Photorealistic 480x848 output. Components: DiT (328ms/step), VAE (tiled, 8.5s), byT5 (4.4ms), LLM (CPU). 5 code patches for Neuron compatibility documented in README.
- byT5 test: use actual HunyuanVideo loading code instead of nonexistent load_byt5_models(), fix mapper to single bf16 arg, add torch_neuronx import - VAE test: use TiledVAEDecoderNeuron._decode_tile() with correct tile shape, add spatial dimension validation (16x upsampling) - E2E tests: use subprocess to run e2e_pipeline.py (argparse-based, not importable) - Document NeuronCore contention: component and E2E tests must run separately - Update performance threshold to 120s wall-clock (includes model loading overhead) Tested on trn2.3xlarge SDK 2.28: byT5 encoder cos_sim=1.000001, mapper cos_sim=0.999947 VAE tile decode: [1,3,5,128,128], 177ms, all finite E2E 2-step: 5 frames at 480x848, 23.2s E2E 50-step: 327ms/step avg, 60.8s wall-clock
Include nki_rope.py with a contiguous-layout NKI kernel for fused RoPE rotation. Benchmarked at ~3% speedup per DiT step (250ms vs 257ms). Disabled by default due to modest gain; enabled via env var for users who want to experiment with NKI custom kernels.
STA enables block-sparse attention for sequences too long for dense O(n^2) attention (e.g., 129-frame 480p at ~52K tokens). Tokens are tiled in 3D (T,H,W) and each tile attends only to its spatio-temporal neighborhood using the attention_cte NKI kernel. Key design decisions: - Auto-enabled via sta_config parameter (no env var needed) - Scatter-free architecture: boundary clamping ensures uniform neighborhood sizes, eliminating global scatter that caused SBUF overflow at 64K+ tokens - Per-chunk KV gather to avoid materializing full gather tensors - Same model weights for both dense and STA modes (no learned parameters) Files added: - src/sta_attention.py: STAAttention module with pre-computed indices Files modified: - src/dit_tp_wrapper.py: Added sta_attention param to TPMMDoubleStreamBlock, sta_config param to HunyuanDiTTPWrapper, STA/dense dispatch in forward() - README.md: STA documentation, benchmarks, compilation instructions
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.
Note: The below template includes items meant for model contributions only. For other contributions such as bug fixes, features, etc., only fill out the relevant portions of the form.
Description
HunyuanVideo-1.5 text-to-video generation on AWS Trainium. 8.33B DiT transformer with TP=4 parallelism and NKI flash attention, producing 480x848 video at ~55s with Classifier-Free Guidance.
Multi-component pipeline: DiT backbone (Neuron TP=4), 3D Causal VAE (Neuron tiled decode), byT5 glyph encoder (Neuron traced), Qwen2.5-VL 7B LLM text encoder (CPU bf16).
Model Information
Model Name: HunyuanVideo-1.5 (tencent/HunyuanVideo-1.5)
Model Architecture: 54 double-stream DiT blocks, hidden_size=2048, 16 attention heads, head_dim=128, flow matching with Euler scheduler
Purpose: Text-to-video generation (480x848 resolution, 5 frames)
Checklist
Required Components
Accuracy Test (
test/integration/test_model.py)README.md with the following sections:
Source Code (
src/)torch_neuronx.trace()+parallel_model_trace()for TP=4Optional Components
Folder Structure
Confirm your contribution follows this structure:
Testing
How did you test this change?
All tests executed on trn2.3xlarge (LNC=2, 4 logical NeuronCores) with pre-compiled models.
Component tests (byT5 + VAE) run in-process; E2E tests run as subprocess.
Tests must be run in two groups to avoid NeuronCore contention:
Test Results:
Compatibility
Tested with:
Additional Information
5 code patches required for Neuron compatibility:
Performance:
Known limitations:
Related Issues
N/A
vLLM Integration
By submitting this PR, I confirm that: