fix(qsa): preserve fast_topk candidates across buffer overflow - #6
Merged
Merged
Conversation
Adapt exact full-row radix refinement from sgl-project/sglang#38144 (Leslie360/sglang e9ba4f06996deb7d7d6fdedd340940a99b258e8c). Add focused capacity-boundary, repeated-overflow and graph replay coverage.
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
When more than 4096 different scores occupy the coarse threshold bucket, JIT fast_topk drops uncached candidates and their histogram contributions. QSA prefill and the independent decode call use this JIT path for block top-k 512, so selection can silently return incorrect scores.
Modifications
Validation
Scope and remaining risks
This fixes the Python-shipped JIT kernel only. Deterministic QSA already uses full stable sorting. QSA qsa_fast_topk routes non-512 supported CUDA k to installed sgl_kernel.fast_topk_v2: the AOT source still has the same risk and this PR does not update or rebuild its installed wheel. JIT dsa/kpool_topk_transform.cuh is separately reachable through fast_kpool_topk_transform_fused and also remains unchanged. Upstream #37893, head f36a7588361ec92351e40e3fb59d56f560ad792b, addresses those two paths with a different cached-tail design; porting it needs separate build and GPU qualification.
Run in a compatible source environment:
CI States
Latest PR Test (Base): ❌ Run #37185123993
Latest PR Test (Extra): ❌ Run #37185123889
Latest PR Test (AMD ROCm 10): ❌ Run #37185124005