Repository navigation
Fix padded positions in breakable CUDA Graph attention - #33253
Merged
YAMY1234 merged 3 commits intoAug 5, 2026
Merged
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
YAMY1234
marked this pull request as ready for review
August 2, 2026 07:47
YAMY1234
requested review from
Fridge003,
Ying1123 and
merrymercy
as code owners
August 2, 2026 07:47
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
YAMY1234
requested review from
BBuf,
Edwardf0t1,
HaiShaw,
ch-wan and
ispobock
as code owners
August 2, 2026 07:47
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 3, 2026
…ne structurally immune (pinned), even-modulo lane silently dropped the write mask on CUDA (4/6 real rows into foreign slots measured) -> mask decision now raises, narrow/restore helpers cover positions with out_cache_loc, AST ratchet added. Diverges from upstream sgl-project#33253 by design.
Collaborator
Author
|
/tag-and-rerun-ci |
_unified_attention_with_output_impl now narrows forward_batch.positions alongside out_cache_loc, but the shared _new_impl_context fake did not define positions, so the three impl tests raised AttributeError.
YAMY1234
force-pushed
the
agent/fix-bcg-padded-positions
branch
from
August 4, 2026 17:59
c364ce8 to
0b61d89
Compare
19 of 39 tasks
Collaborator
Author
|
|
5 tasks done
saturn-acc
pushed a commit
to saturn-acc/sglang
that referenced
this pull request
Aug 16, 2026
…3253) TestBreakableCUDAGraphBasic and all NVIDIA CI tests pass.
Atituiset
pushed a commit
to Atituiset/sglang
that referenced
this pull request
Sep 10, 2026
…3253) TestBreakableCUDAGraphBasic and all NVIDIA CI tests pass.
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
Breakable CUDA Graph pads token buffers to a captured bucket. The attention wrapper already narrows Q/K/V and cache locations to the real token count, but it still passes padded
positionsto the backend. Decode context parallelism (DCP) uses these positions to determine key-value (KV) ownership, so virtual padded tokens can compete with real tokens for the same physical KV slots and silently corrupt the cache.Modifications
forward_batch.positionsto the real query-token count together without_cache_locfor the attention call.ForwardBatchafter the call.Accuracy Tests
The targeted GPU regression was run before and after the change:
TestBreakableCUDAGraphBasicsuite passed (9 passed).An end-to-end matched A/B used Qwen3.5-397B-A17B FP8 with TP16/DCP4, FP8 KV cache, Breakable CUDA Graph prefill, full decode CUDA Graph, GSM8K-128, 8-shot prompting, temperature 0, and
max_tokens=16384. The validation stack included #32795 and #32858; the only runtime-code difference between before and after was this PR's four-line positions fix.All four runs completed 128/128 requests with HTTP 200 and no non-200 responses.
Speed Tests and Profiling
Not benchmarked. This correctness fix does not change kernels or CUDA Graph configuration; it creates a tensor view and restores the original reference around the existing attention call.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ✅ Run #30979497752
Latest PR Test (Extra): ❌ Run #30979497576