Conversation
zRzRzRzRzRzRzR
left a comment
There was a problem hiding this comment.
Issue received, following and test this.
|
This PR seems to have only fixed its copy in the kpool JIT kernel. There are several other copies of the same code affect all dsa model. |
I was working on addressing issues with GLM 5.3 Flash in my SGlang build that lead to crashes directly, but was keeping the breadth smaller to minimize review burden. It sounds like you desire the full and complete fix, so let me evaluate that. Thank you for the feedback. |
1436d19 to
7ad39a0
Compare
|
@zRzRzRzRzRzRzR Updated the branch in response to the scope issue you identified.
The branch is rebased onto SGLang |
|
The fix in this PR is correct, but it costs quite a bit of performance as it stands. Model output quality before vs. after the fix doesn't seem to differ much on long text (at least when measured end-to-end, e.g. by benchmark scores such as GQPA, need more than 32K context) — an interesting finding. Maybe there's a better way to fix this? cc @JustinTong0323 |
Kernel level there is some perf regression but not obvious in e2e, so I think it shall be ok. |
|
@DarkSharpness to review :) |
I have some ideas on how to optimize this, I'll give it a shot and report back. |
|
Updated the branch with a cutoff-first oversized-bin fallback.
|
|
Measured PR head
The largest mean decrease was 0.94% and the largest median decrease was 2.03%, while the per-cell sample CVs were 3.83% to 6.31%. The current C4 panel also completed five analyzer-valid repetitions at 31.82 mean and 31.98 median fwd/s. This is a serving-level comparison rather than a kernel-isolated A/B, and it does not show a material forward-pass-rate regression with the cutoff-first patch included. |
45e4e99 to
010c3fd
Compare
Refine the exact FP32 cutoff when a coarse bin reaches its candidate capacity, then emit higher scores and cutoff ties in a final bounded row scan. Preserve normal-bin selection, page mapping and -1 padding. Cover the KPool and DeepSeek-V4 JIT paths, legacy CUDA AOT and DeepSeek-V4 AOT, including signed zero, oversized ties and idle rows. Reconcile the additive AOT tests with current main and retain its ROCm coverage. Kernel behavior matches the previously reviewed PR head. Co-authored-by: Benjamin Oldenburg <benjamin.oldenburg@ordis.co.th>
010c3fd to
759070d
Compare
|
We independently reproduced this candidate-buffer overflow on MI300X/gfx942 In our frozen runtime, exactly 319 of 567 captured score rows both overflowed This supports the failure mechanism and usefulness of the fix on gfx942. It The cutoff-first fallback described here looks like the right place to AI assistance was used to summarize our recorded experiments and prepare this |
Motivation
DSA top-k selection can drop candidates when a coarse radix bin reaches its fixed buffer capacity, selecting lower-scoring tokens before full scores are compared. This affects exact-capacity and oversized bins in KPool JIT, DeepSeek-V4 JIT v1/v2, legacy CUDA AOT and DeepSeek-V4 AOT selectors.
Modifications
Keep normal-bin selection. At the boundary, refine the exact FP32 cutoff and emit higher scores and cutoff ties in a final bounded row scan. Preserve page mapping,
-1padding and synchronization around shared-memory reuse. Retain main's additive ROCm tests. Co-authored with Benjamin Oldenburg (@bold84).Accuracy Tests
Author validation at
759070d497on mainafe90a8bc9on one RTX PRO 6000 Blackwell Max-Q (SM120): 297 tests and 38 subtests passed. Targets:test/registered/kernels/ops/attention/test_topk_v2.py,test/registered/kernel/attention/test_dsa_kpool_topk_transform.py. This run exercises source JIT selectors and does not rebuild the CUDA or ROCm AOT binaries.Author tests at
010c3fd303on maindcebe8c473passed 297 JIT tests plus 38 subtests on RTX PRO 6000 Blackwell Max-Q (SM120). This run exercised the source JIT selectors; it did not rebuild the CUDA or ROCm AOT binaries. The additional AOT results below describe an earlier source-built snapshot.Author SM120 tests of the isolated repaired snapshot passed 12 KPool tests plus 38 subtests, 16 focused JIT tests and 14 source-built CUDA AOT cases. The regressions compare selected score multisets with an exact reference, including ties, signed zero, input permutations, offsets and idle rows. ROCm AOT was not compiled or run locally.
Speed Tests and Profiling
Overflow handling adds row scans; no zero-overhead claim is made. The earlier integrated serving comparison remains in its measurement comment. It was not a kernel-isolated benchmark and was not repeated for this rebase.
Checklist
Developed with AI assistance.
CI States
Latest PR Test (Base): ❌ Run #34282238811
Latest PR Test (Extra): ❌ Run #34282238726
Latest PR Test (AMD ROCm 7.2): ❌ Run #34282238769