Repository navigation
Conversation
junelotus
force-pushed
the
main
branch
2 times, most recently
from
September 14, 2026 03:36
f03be24 to
62162f6
Compare
Lfan-ke
force-pushed
the
fix/grpo-int64-row-offsets
branch
from
September 27, 2026 19:54
8cec0a8 to
a7b1220
Compare
Signed-off-by: Leo Cheng (heke1228) <chengkelfan@qq.com>
Lfan-ke
force-pushed
the
fix/grpo-int64-row-offsets
branch
from
September 27, 2026 20:12
a7b1220 to
9eeaa90
Compare
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.
Problem
grpo_kernelandgrpo_bwd_kerneladdress the logits withpid * V, wherepidcomes fromtl.program_idand is int32. The product wraps onceBL * Vexceeds 2^31, so the kernels read — and in the backward pass write — outside the tensors. The launch isgrid = (BL,)withBL, V = new_logits.shape, so nothing else bounds it.The threshold is reachable in ordinary use. With a 128k vocabulary it is crossed at 16744 tokens, and
grpo_loss_triton_optimizedalready defaultsmax_completion_lengthto 8192.Fix
Promote
pidto int64 in both kernels, so every derived offset is 64-bit. This is the same fix already applied topermute_bwd_kernelin #172.Also corrected the import in
benchmarks/grpo.py, which named the packagedlblas.kernelinstead ofdlblas.kernelsand therefore could never run.Verification
The overflow itself needs ~8.6 TB of logits to reproduce with real tensors, so the address arithmetic was reproduced on its own, with the same expression the kernel uses (RTX 3050, triton 3.7.1):
A negative offset is an out-of-bounds access; in
grpo_bwd_kernelit is an out-of-bounds store.No behaviour change below the threshold —
tests/kernels/test_grpo_loss_logits.pygives a bit-identical loss before and after: