[varlen Kernel] Extend paged attention v2 to varlen [4/n]#166
Merged
LxYuan0420 merged 6 commits intovllm-project:mainfrom Mar 17, 2026
Merged
[varlen Kernel] Extend paged attention v2 to varlen [4/n]#166LxYuan0420 merged 6 commits intovllm-project:mainfrom
LxYuan0420 merged 6 commits intovllm-project:mainfrom
Conversation
Signed-off-by: ran <hzz5361@psu.edu>
bc616e4 to
6e5a957
Compare
Signed-off-by: ran <hzz5361@psu.edu>
Signed-off-by: ran <hzz5361@psu.edu>
Signed-off-by: ran <hzz5361@psu.edu>
Signed-off-by: ran <hzz5361@psu.edu>
30 tasks
LxYuan0420
approved these changes
Mar 17, 2026
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.
Summary
find_seq_idxbinary search to the v2 Metal kernel so each threadgroup discovers its sequence from a flatcu_seqlens_qarray, enabling variable-length queries (prefill + decode in one launch)mx.sdpafor prefilling, and use this PR v2 for decoding. But the kernels_v2 is identical to previous v1, by freezing some parameters.Notes:
Triangle Test Status
Before: 15 passed + 21 xfail → After: 36 passed + 0 xfail
What's NOT in this PR
The kernel now supports unified prefill+decode, but production still uses the split path (MLX SDPA for prefill, v2 kernel for decode). Wiring
metal_unified_attention()intomodel_runner.pyis a follow-up.Numeric Stability
However, I don't want to change the test for now. The test result will flip on and off later by the following PRs.
Benchmark
run same benchmark script as #136
This PR:
before this PR:
This PR has no effects on the performance. It paves the way for continuous batching.
Possible Limitation