[flashinfer] Pass window_left at plan time for the SWA paged prefill wrapper - #31501
Merged
merrymercy merged 1 commit intoJul 18, 2026
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Contributor
Author
|
/tag-and-rerun-ci |
luccafong
marked this pull request as ready for review
July 16, 2026 23:05
luccafong
requested review from
Fridge003,
HaiShaw,
Qiaolin-Yu,
hebiao064,
ispobock and
merrymercy
as code owners
July 16, 2026 23:05
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Contributor
Author
|
/tag-and-rerun-ci |
merrymercy
approved these changes
Jul 17, 2026
Contributor
|
/tag-and-rerun-ci |
…wrapper Planning the SWA paged prefill wrapper without window_left selects the fa2 module with use_sliding_window=False, so the per-element window mask is compiled out; the window_left passed at forward() only drives the coarse per-tile KV-start skip (and on sm100 the plan/run mismatch breaks outputs broadly, not just past the window). Pass window_left at plan time on the paged-only SWA prefill path (normal extend only; ragged keeps its custom prefix mask, spec-verify keeps its tree-mask behavior), making flashinfer's plan/run consistency check genuinely hold. Add paged-mode SWA regression cases (existing window-edge cases plus a long no-prefix above-window case) that fail without the fix.
merrymercy
force-pushed
the
flashinfer-swa-paged-window-left
branch
from
July 18, 2026 05:16
d91ca12 to
c3c1b52
Compare
Contributor
|
Thank you! We observed this in Olmo3, and similar development variants as well. |
5 tasks
This was referenced Jul 23, 2026
Zhylkaaa
pushed a commit
to Zhylkaaa/sglang
that referenced
this pull request
Jul 29, 2026
jinzhenfan
pushed a commit
to jinzhenfan/sglang
that referenced
this pull request
Jul 29, 2026
5 tasks
5 tasks
Chronostasys
pushed a commit
to MindLab-Research/sglang
that referenced
this pull request
Aug 24, 2026
jakki-amd
pushed a commit
to jakki-amd/sglang
that referenced
this pull request
Sep 9, 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.
What
sglang's FlashInfer backend plans the sliding-window paged prefill wrapper without
window_left, so flashinfer selects the fa2 module withuse_sliding_window=False— the per-element left-window mask is compiled out. Thewindow_leftpassed later atforward()silently overwrites flashinfer's plan/run consistency check and only drives the coarse per-CTA-tile KV-start skip, so every token past the window attends to stale keys on SWA layers in paged-only prefill mode. On sm100 the plan/run mismatch is worse than the tile-granular leak: outputs are grossly wrong from the first positions, not just past the window.Paged-only prefill (
use_ragged=False) is reached viaSGLANG_FLASHINFER_USE_PAGED=1,--enable-deterministic-inference, piecewise CUDA-graph prefill, multimodal models (e.g. Gemma3 VLMs), and multi-item scoring — any SWA model served through one of these paths is affected.Fix: pass
window_leftfor the SWA paged wrapper at plan time — normal extend only (ragged mode keeps its exact custom prefix mask; spec-verify keeps its pre-existing tree-mask behavior). This also makes flashinfer's plan/run consistency assert genuinely hold.Verification
New regression test in
test/registered/attention/unittests/swa/test_flashinfer.py(test_projected_swa_attention_cases_paged_mode): the existing SWA window-edge cases plus a long no-prefix above-window case (extend 6/8/12, window 4), run underSGLANG_FLASHINFER_USE_PAGED=1against the exact SDPA sliding-window reference.Pre-fix check: same commands with the parent commit's
flashinfer_backend.pyswapped in (git checkout HEAD~1 -- .../flashinfer_backend.py).E2E on
google/gemma-3-1b-it(sliding_window=512), 1500-token prompt, per-position prompt logprobs vs the triton backend as exact-mask reference (GB300 / sm100):lm-eval on the same setup —
gsm8k, 5-shot, limit 200 (GB300 / sm100):Original commits
e306cd21123a53115ac81195e62CI States
Latest PR Test (Base): ✅ Run #29631972224
Latest PR Test (Extra): ❌ Run #29631972120