Skip to content

Fix speculative replay masks in mixed top-k and scoring batches - #104

Merged
kailash109 merged 1 commit into
spindle-sglang-v0.5.23from
codex/speculative-mask-topk-ties
Nov 19, 2026
Merged

kailash109 merged 1 commit into
spindle-sglang-v0.5.23from
codex/speculative-mask-topk-ties

Conversation

@kailash109

Copy link
Copy Markdown

Summary

A speculative batch containing both a bounded top-k request and a whole-vocabulary scoring request fell back to dense top-k renormalization. Cutoff ties could leave more than K nonzero probabilities on the bounded row, while sampling-mask capture exported only K and reported OK. The exported replay probabilities then summed to less than one.

Keep bounded rows on exact-K filtering even in mixed batches, while preserving unrestricted rows' full-vocabulary policy. Verification and capture use the same policy builder. Cache the bounded top-k upper bound in SamplingBatchInfo to avoid a new device-to-host synchronization during overlap scheduling; preserve it through filtering and merging. Capture inspects one extra support column and reports OVERFLOW if truncation would lose positive mass, including when full-support logprobs were not requested. Greedy capture remains a point mass.

Validation

  • B300, SGLang v0.5.23 runtime at e003cf9 with these source changes: 104 tests passed, 25 subtests passed. Covers sampling-batch metadata, speculative replay capture, UNO sparse verification, and the existing torch top-k upper-bound path.
  • Cutoff ties at 64/65/68/72 tokens, mixed replay/scoring rows in either order, top-p, greedy capture, missing legacy metadata, and the overlap path with Tensor.item forbidden.
  • Real CUDA top-p/kernel checks verify bounded support at most 64, captured mass 1.0, unchanged unrestricted-row probabilities, and explicit overflow for deliberately oversized support.
  • Pre-commit checks pass for all changed files.

This is policy/kernel validation without loading a full DeepSeek model or rerunning a training workload. Generated results and logs are not committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant