You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(qsa): clamp the compress gather to the rows this forward has - #38346
Related to the IMA error described in #37633.
In the indexer every group spanscompress_ratio rows, so a padded entry gathers rows 0..ratio-1 of token_k.
A forward that carries fewer than compress_ratio(4) token rows — the 1..3 token chunk that ends a request under chunked prefill — therefore reads past token_k.
The read almost always lands in neighbouring allocated memory and is absorbed silently, it faults only when it happens to cross an unmapped page.
Modifications
Clamp the gather row index to the rows this forward actually has:
This is exact rather than a mask over the symptom: padded entries write the
reserved slot 0 and their gathered values are discarded, and real entries are
provably in range, so the clamp cannot change any real computation.
Independent confirmation on ROCm — 1× MI355X, rocm/sgl-dev:v0.5.19-rocm724-mi35x-20260909, Qwen/Qwen3.8-Flash-Next-FP8, TP1.
Without this change, any /generate prefill that adds 1–3 tokens aborts the HSA queue deterministically (HSA_STATUS_ERROR_EXCEPTION 0x1016, scheduler SIGABRT) — the out-of-bounds read is not absorbed on ROCm. Minimal reproducer:
input_ids=[1000,1001,1002]
Instrumenting the gather shows exactly the padded entry described here, on every full-attention layer: token_k rows=3 groups=1 member_rows=[0] group_locs.max=3.
With this one-line clamp applied: the reproducer passes, 1,500 varied-length requests (5 seeds, three of which crashed within 6–98 requests before) and a 300-prompt ShareGPT run complete with no faults.
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but "Fixes #37633" is likely overstated. The crashing batch there was a single request with 64 new tokens, which doesn't hit the <4-row trigger, and the reporter later attributed it to an overlap-scheduler race. Suggest "Related to #37633" so it isn't auto-closed.
LGTM, but "Fixes #37633" is likely overstated. The crashing batch there was a single request with 64 new tokens, which doesn't hit the <4-row trigger, and the reporter later attributed it to an overlap-scheduler race. Suggest "Related to #37633" so it isn't auto-closed.
@YAMY1234 You're right. What we fixed only shares the same IMA stack trace as #37633 —
it isn't necessarily the same root cause. I'll fix the comment above.
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
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
Related to the IMA error described in #37633.
In the indexer every group spans
compress_ratiorows, so a padded entry gathers rows0..ratio-1oftoken_k.A forward that carries fewer than
compress_ratio(4)token rows — the 1..3 token chunk that ends a request under chunked prefill — therefore reads pasttoken_k.The read almost always lands in neighbouring allocated memory and is absorbed silently, it faults only when it happens to cross an unmapped page.
Modifications
Clamp the gather row index to the rows this forward actually has:
This is exact rather than a mask over the symptom: padded entries write the
reserved slot 0 and their gathered values are discarded, and real entries are
provably in range, so the clamp cannot change any real computation.
Accuracy Tests
Speed Tests and Profiling
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #34582374121
Latest PR Test (Extra): ❌ Run #34582373804
Latest PR Test (AMD ROCm 10): ❌ Run #34582374085