[None][perf] Add Qwen Image VisualGen perf fastpaths - #16142
Conversation
c93d3eb to
4042b3f
Compare
|
/bot run |
096ac00 to
e4fb9ba
Compare
|
B300 follow-up validation for commit Additional issues found and fixed
Real Qwen-Image-2512 BF16 checkpointTP=1, full 60-block transformer, 256 image tokens + 64 text tokens with an interior padded-text mask:
TP=2, same checkpoint and broadcast inputs:
Ulysses=2, full 60-block transformer with 255 image tokens, 63 text tokens, forced padding, and an interior text mask:
The same full forced-padding case on Ulysses=4:
A smaller odd-length forced-padding Ulysses=2 case matched its unpadded TP=1 reference exactly. Focused fused/unfused Q/K preparation measured cosine File-scoped pre-commit, Ruff/format, byte-compilation, diff checks, and DCO pass after the rebase. Local pytest collection remains blocked by the workstation environment ( |
4cd65d5 to
75bd9f2
Compare
75bd9f2 to
c46072b
Compare
|
CUDA Graph + true-CFG follow-up in
|
|
/bot run |
c46072b to
b238aff
Compare
|
/bot run |
|
Cache-DiT compatibility follow-up for
The new A merge-tree audit against #16339 finds one expected textual conflict in the true-CFG denoise loop. The combined resolution preserves both behaviors: clone the positive CUDA Graph output before the negative replay, then switch Cache-DiT to the |
📝 WalkthroughWalkthroughQwen-Image pipeline prompt masks are now optional, CUDA graph true-CFG execution protects positive predictions from buffer aliasing, and the transformer adds fused RoPE/QK-norm paths, tensor-parallel attention handling, backend-aware masking, sequence sharding, and expanded tests. ChangesQwen-Image runtime and validation
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant QwenImageTransformer2DModel
participant SequenceSharder
participant QwenImageTransformerBlock
participant QwenJointAttention
QwenImageTransformer2DModel->>SequenceSharder: shard sequences and masks
SequenceSharder->>QwenImageTransformer2DModel: return sharded inputs
QwenImageTransformer2DModel->>QwenImageTransformerBlock: execute block with rotary inputs
QwenImageTransformerBlock->>QwenJointAttention: run masked joint attention
QwenImageTransformer2DModel->>SequenceSharder: gather and unpad output
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/unittest/_torch/visual_gen/test_qwen_image_pipeline_config.py (1)
550-625: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover final sequence gather and unpadding.
This test exercises
_shard_sequences, but would still pass if modelforward()omitted the final gather or supplied the wrongunpad_to. Coverage is insufficient for that end-to-end contract.Add
test_qwen_transformer_forward_gathers_unpadded_image_tokenstotests/unittest/_torch/visual_gen/test_qwen_image_pipeline_config.py, asserting the original image sequence length is restored.As per path instructions, test feedback should state coverage sufficiency and provide a concrete test file and follow-up.
🤖 Prompt for 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. In `@tests/unittest/_torch/visual_gen/test_qwen_image_pipeline_config.py` around lines 550 - 625, Extend the Qwen transformer tests with test_qwen_transformer_forward_gathers_unpadded_image_tokens, exercising model.forward() rather than only _shard_sequences. Configure the sharder to observe the final gather and unpad_to value, then assert the returned image tokens regain the original sequence length and that the gather uses that length, covering the end-to-end unpadding contract.Source: Path instructions
🤖 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 `@tests/unittest/_torch/visual_gen/test_qwen_image_pipeline_config.py`:
- Around line 493-506: Update
test_qwen_joint_attention_fused_rope_requires_qk_norm to construct
QwenJointAttention with a fused-kernel-supported attention head dimension (64,
128, or 256), adjusting dim consistently with the head configuration while
preserving the qk_norm assertions.
---
Nitpick comments:
In `@tests/unittest/_torch/visual_gen/test_qwen_image_pipeline_config.py`:
- Around line 550-625: Extend the Qwen transformer tests with
test_qwen_transformer_forward_gathers_unpadded_image_tokens, exercising
model.forward() rather than only _shard_sequences. Configure the sharder to
observe the final gather and unpad_to value, then assert the returned image
tokens regain the original sequence length and that the gather uses that length,
covering the end-to-end unpadding contract.
🪄 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: f958c480-1b68-4663-b16a-ad0f0aba08c4
📒 Files selected for processing (4)
tensorrt_llm/_torch/visual_gen/models/qwen_image/pipeline_qwen_image.pytensorrt_llm/_torch/visual_gen/models/qwen_image/transformer_qwen_image.pytests/unittest/_torch/visual_gen/test_qwen_image_pipeline.pytests/unittest/_torch/visual_gen/test_qwen_image_pipeline_config.py
Signed-off-by: Alex Steiner <pst2154@users.noreply.github.com>
b238aff to
958ce5e
Compare
|
/bot run |
karljang
left a comment
There was a problem hiding this comment.
Additionally, please check following issues that my agent found:
- Hybrid CP x Ulysses is incorrect. Qwen shards across the full CP x Ulysses group, but
SEPARATE_QKVdisables Ulysses when CP is also active. Each rank attends to an incomplete sequence before outputs are gathered. Ring configurations are also rejected during construction. - A newly added prompt-mask test cannot initialize the pipeline. It supplies only
torch_dtype, whileBasePipelineimmediately requiresprimary_pretrained_configand other configuration fields.
Thank you!
Signed-off-by: Alex Steiner <asteiner@nvidia.com>
|
/bot run |
|
PR_Github #61620 [ run ] triggered by Bot. Commit: |
|
PR_Github #61620 [ run ] completed with state
|
|
/bot run |
|
PR_Github #61673 [ run ] triggered by Bot. Commit: |
|
PR_Github #61673 [ run ] completed with state
|
|
/bot run |
|
PR_Github #61793 [ run ] triggered by Bot. Commit: |
|
PR_Github #61793 [ run ] completed with state |
Signed-off-by: Alex Steiner <asteiner@nvidia.com>
Signed-off-by: Alex Steiner <asteiner@nvidia.com>
Signed-off-by: Alex Steiner <asteiner@nvidia.com>
|
/bot run |
|
PR_Github #62278 [ run ] triggered by Bot. Commit: |
|
PR_Github #62278 [ run ] completed with state |
Signed-off-by: Alex Steiner <asteiner@nvidia.com>
|
/bot run |
|
PR_Github #62570 [ run ] triggered by Bot. Commit: |
|
PR_Github #62570 [ run ] completed with state
|
|
/bot run |
|
PR_Github #62617 [ run ] triggered by Bot. Commit: |
|
PR_Github #62617 [ run ] completed with state |
Summary
key_padding_maskfor VANILLA attention, including VANILLA-backed Ulysses; reject unsupported masked sequence-parallel combinations instead of silently running rank-local SDPA.[valid text | padded text | valid image].SequenceSharderfor Qwen sequence parallelism: pad and shard image/text tokens and RoPE independently, translate the key-padding mask into Ulysses rank-interleaved order, then gather and unpad image output.gelu-approximatethrough sharedgelu_tanhfor the fused NVFP4 producer path.Checks
pre-commit run --files tensorrt_llm/_torch/visual_gen/models/qwen_image/pipeline_qwen_image.py tensorrt_llm/_torch/visual_gen/models/qwen_image/transformer_qwen_image.py tests/unittest/_torch/visual_gen/test_qwen_image_pipeline.py tests/unittest/_torch/visual_gen/test_qwen_image_pipeline_config.pyruff checkandruff format --checkpass for the changed pipeline and regression test.python3 -m py_compile ...git diff --checkupstream/main.c46072b716.B300 validation
Using Qwen-Image-2512 weights with current PR Python over
nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc18on SM103:(1, 256, 64)output, 4.31 s forward, 38.20 GiB peak, and exactly one complex RoPE conversion.Scope note
This is real-checkpoint transformer validation at a reduced token count, not a full text-encoder/VAE image-generation quality run. Local targeted pytest collection remains blocked by workstation dependencies (
mpi4pythrough the normal harness;nvtxand a usable PyTorch install when bypassing the parent conftest). Repository hooks and focused rc18/B300 validation pass.Summary by CodeRabbit
Performance
Reliability
Tests