Repository navigation
Conversation
8 tasks done
Collaborator
Author
|
Consolidated into #36680 as requested. The full segmented-pack/static-FA commit, benchmark, tests, and docs are now preserved there. |
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.
Motivation
Qwen-Image joint attention keeps text and image Q/K/V in separate tensors, then materializes three
[text, image]concatenations before the masked varlen path immediately gathers the valid rows again. On a 1024x1024 Qwen-Image-2512 request this adds three dense copies in every one of the 60 transformer blocks.The same profile also showed that batch-1 packed attention used FA3's
VarlenDynamicPersistentscheduler while vLLM-Omni used the fasterStaticPersistentscheduler for the equivalent single sequence.Modifications
[prefix, main]Q/K/V sequence without materializing the three concatenations.USPAttentionaccept an optional Q/K/V prefix on its local masked FA path.Accuracy Tests
Validated on the latest main used for this PR (
b647ae8) and 2x NVIDIA H200:pytest -q test/registered/kernels/ops/diffusion/test_layout.py -k "segmented_pack or dense_scheduler": 16 passed.torch.cat+fused_pack_qkvacross BF16/FP16 and batch/shape variants.862fd0c4fbaf443a5595058255e665ff0bd801f7e7cafc1b1f115a16df10161b.Speed Tests and Profiling
Environment: 2x H200, TP=2, Qwen/Qwen-Image-2512, 1024x1024, 50 steps, guidance=1, BCG enabled, torch.compile disabled. The incremental A/B used the same CustomAllReduceV2 stack on both sides.
[B=1, text=64, image=4096, H=12, D=128]: materialized 47.74 us, segmented 21.11 us (2.26x faster).CatArrayBatchedCopycalls / 10.768 ms disappeared from a 402-attention-call trace. The replacement segmented pack costs 18.0 us/call, matching the old pack itself.VarlenDynamicPersistent159.4 us plusprepare_varlen_num_blocks3.44 us toStaticPersistent147.1 us, matching vLLM-Omni's measured 147.4 us.Checklist
Background benchmark investigation: BBuf/how-to-optim-algorithm-in-cuda#21
CI States
Latest PR Test (Base): ❌ Run #33069117658
Latest PR Test (Extra): ❌ Run #33069117413
Latest PR Test (AMD ROCm 7.2): ❌ Run #33069117562