[Bugfix][Model Runner V2][Spec Decode] Fix int32 offset overflow in sampler kernels (#46560)

Signed-off-by: xiaojun.wei <jessiewei747@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Robert Shaw <114415538+robertgshaw2-redhat@users.noreply.github.com>
This commit is contained in:
JessieWei
2026-06-24 11:00:57 -07:00
committed by GitHub
co-authored by Claude Opus 4.8 Robert Shaw
parent 56ca5997ea
commit 3c43237233
10 changed files with 90 additions and 16 deletions
@@ -79,14 +79,14 @@ def _compute_block_stats_kernel(
BLOCK_SIZE: tl.constexpr,
HAS_DRAFT_LOGITS: tl.constexpr,
):
logit_idx = tl.program_id(0)
logit_idx = tl.program_id(0).to(tl.int64)
draft_step_idx = tl.load(expanded_local_pos_ptr + logit_idx)
if draft_step_idx >= num_speculative_steps:
# Bonus token. Max/argmax and summed exponentials are not needed.
return
req_state_idx = tl.load(expanded_idx_mapping_ptr + logit_idx)
req_state_idx = tl.load(expanded_idx_mapping_ptr + logit_idx).to(tl.int64)
temp = tl.load(temp_ptr + req_state_idx).to(tl.float32)
block_idx = tl.program_id(1)
@@ -206,8 +206,8 @@ def _rejection_kernel(
SYNTHETIC_MODE: tl.constexpr,
):
req_idx = tl.program_id(0)
req_state_idx = tl.load(idx_mapping_ptr + req_idx)
start_idx = tl.load(cu_num_logits_ptr + req_idx)
req_state_idx = tl.load(idx_mapping_ptr + req_idx).to(tl.int64)
start_idx = tl.load(cu_num_logits_ptr + req_idx).to(tl.int64)
end_idx = tl.load(cu_num_logits_ptr + req_idx + 1)
num_tokens = end_idx - start_idx
seed = tl.load(seed_ptr + req_state_idx)
@@ -349,10 +349,10 @@ def _resample_kernel(
):
req_idx = tl.program_id(0)
resample_idx = tl.load(rejected_step_ptr + req_idx)
start_idx = tl.load(cu_num_logits_ptr + req_idx)
start_idx = tl.load(cu_num_logits_ptr + req_idx).to(tl.int64)
end_idx = tl.load(cu_num_logits_ptr + req_idx + 1)
resample_token_idx = start_idx + resample_idx
req_state_idx = tl.load(expanded_idx_mapping_ptr + resample_token_idx)
req_state_idx = tl.load(expanded_idx_mapping_ptr + resample_token_idx).to(tl.int64)
temp = tl.load(temp_ptr + req_state_idx).to(tl.float32)
is_bonus = resample_token_idx == end_idx - 1