Repository navigation
Allow attention layers to opt out of the prefill wrapper - #40683
Merged
Merged
Conversation
Preserve expanded Q/K/V rows and the caller-provided batch when a layer manages its own prefill attention dispatch. Keep the wrapper enabled by default. Co-authored-by: Lu Fang <[email protected]>
metamergebot
requested review from
BBuf,
Edwardf0t1,
Fridge003,
HaiShaw,
Ying1123,
ch-wan,
ispobock and
merrymercy
as code owners
September 22, 2026 05:37
Collaborator
Author
|
This port clears our bar on gate 19✓✂3 lint✓ build✗1✂1 A✓ B✓ C 5/10⏳ other✗1✂5 · accel ✗amd,npu @pranjalssh @merrymercy @houseroad — could one of you take a look and merge it if you are happy? Nothing else is waiting on our side. |
This was referenced Sep 24, 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
Motivation
Prefill attention wrappers slice Q/K/V using the runner's token count, which can truncate rows for layers that expand their attention inputs and supply a separate batch.
Modifications
Add
RadixAttention(..., use_prefill_attention_wrapper=False)to dispatch directly to the attention backend while preserving those rows and the caller's batch. The option defaults toTrue. Add one CPU regression to the existing RadixAttention suite; ordinary wrapper and LSE dispatch remain covered by the existing cases.Test plan
Accuracy Tests
python test/registered/unit/layers/test_radix_attention.pywith the checkout onPYTHONPATH: 11 passed. The new regression fails on the parent revision because the constructor option is absent.python -m pre_commit run --files python/sglang/srt/layers/radix_attention.py test/registered/unit/layers/test_radix_attention.py: passed.git diff --check: passed.Speed Tests and Profiling
Full-model serving, accuracy evaluation, and performance benchmarks were not run; local validation covers the dispatch contract and CUDA graph replay.
Original commits
7ab0e433fc1b89cb90a82ad7365a58292bcf9d67Checklist
CI States
Latest PR Test (Base): ✅ Run #35691425463
Latest PR Test (Extra): ❌ Run #35691431616
Latest PR Test (AMD ROCm 10): ❌ Run #35691425394