Skip to content

Allow attention layers to opt out of the prefill wrapper - #40683

Merged
xiezhq-hermann merged 1 commit into
mainfrom
oss-sync-11591
Sep 23, 2026
Merged

xiezhq-hermann merged 1 commit into
mainfrom
oss-sync-11591

Conversation

@metamergebot

@metamergebot metamergebot commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

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 to True. 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.py with the checkout on PYTHONPATH: 11 passed. The new regression fails on the parent revision because the constructor option is absent.
  • A local CUDA probe verified expanded rows, batch identity, unchanged ordinary slicing, and three bitwise-matching full CUDA graph replays through RadixAttention with a tensor-arithmetic backend.
  • 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

  • 7ab0e433fc1b89cb90a82ad7365a58292bcf9d67

Checklist

  • Format code with pre-commit.
  • Add a regression in the registered CPU suite.
  • Describe the constructor option and its default above.
  • Full-model accuracy and speed benchmarks.
  • Follow the SGLang code style guidance.

CI States

Latest PR Test (Base): ✅ Run #35691425463
Latest PR Test (Extra): ❌ Run #35691431616
Latest PR Test (AMD ROCm 10): ❌ Run #35691425394

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 metamergebot added the run-ci CI: run the baseline test suite on this PR label Sep 22, 2026
@metamergebot

Copy link
Copy Markdown
Collaborator Author

This port clears our bar on d9df428d88a04d0fa12992295a15afd5ec50eba7: every base-a and base-b job is green.
base-c and the accelerator suites are reported but not gated, because they run
on scarce hardware and upstream merges through them routinely.

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.

@xiezhq-hermann
xiezhq-hermann merged commit f2f223e into main Sep 23, 2026
271 of 311 checks passed
@xiezhq-hermann
xiezhq-hermann deleted the oss-sync-11591 branch September 23, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants