Skip to content

[Spec] Disambiguate verified_id into bonus_token(s) / accept_tokens - #24724

Merged
hnyls2002 merged 6 commits into
mainfrom
lsyin/spec-bonus-token
May 9, 2026
Merged

hnyls2002 merged 6 commits into
mainfrom
lsyin/spec-bonus-token

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented May 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Split overloaded verified_id into two semantically distinct names per the speculative-decoding naming rule (Add speculative decoding naming convention rule #24094):
    • per-req [bs] bonus tokens -> bonus_token (scalar) / bonus_tokens (batched) — Rule 2
    • flat [sum_accepted] accepted-token tensor -> accept_tokens — Rule 3
  • Drop the prior "always singular" exception so bonus_token(s) obeys Rule 7 plural-for-non-scalar like every other spec name.

Changes

  • 16 source files renamed: EagleDraftInput.verified_id -> bonus_tokens, EagleVerifyOutput.verified_id -> accept_tokens, Triton kernel fill_new_verified_id -> fill_bonus_tokens, etc.
  • Kernel scalar locals stay singular bonus_token (Rule 7); ptr params and [bs] tensors are plural.
  • .claude/rules/speculative-naming.md: remove the singular-exception clauses in Rule 2 + Rule 7; tighten Rule 2 wording.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot added documentation Improvements or additions to documentation speculative-decoding labels May 8, 2026
@hnyls2002 hnyls2002 added run-ci CI: run the baseline test suite on this PR high priority labels May 8, 2026
@hnyls2002 hnyls2002 changed the title Rename verified_id to bonus_token / accept_tokens [Spec] Disambiguate verified_id into bonus_token(s) / accept_tokens May 8, 2026
@hnyls2002
hnyls2002 merged commit 1613bae into main May 9, 2026
197 of 222 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/spec-bonus-token branch May 9, 2026 01:24
hnyls2002 added a commit that referenced this pull request May 9, 2026
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 16, 2026
…64 an invariant

THE DEATH. 2026-08-16 00:25:07, nineteen minutes into the c4b88e1 boot under
five-lane load, all three ranks at once:

    RuntimeError: Expected 'candidates' to be of type long (torch.int64)
      tree_speculative_sampling_target_only <- eagle_sample <- verify <- run_batch

The iteration before: full token usage 0.97, a 257-token chunked prefill
admitted, 143,984 pending.

THE HYPOTHESIS WAS HALF RIGHT. Not a float tensor from a defaulted
torch.empty -- int32, deliberately:

    eagle_sample                 candidates = verify_input.draft_token.reshape(..)
    _build_trivial_verify_input  draft_token = draft_input.bonus_tokens
    verify                       bonus_tokens = torch.empty_like(accept_lens,
                                                    dtype=torch.int32)
                                 bonus_tokens = torch.empty((0,), dtype=torch.int32)

draft_token IS the candidates tensor, and one construction path hands it over
int32. int32 is CORRECT at its source -- bonus_tokens is an *input* to
build_tree_kernel_efficient on the ordinary path, never the candidates tensor.
The dtype is wrong at the door it came through, not where it was made.

WHY ONLY UNDER PRESSURE. The trivial path is taken when drafting is disabled at
high batch size, or on a phase-flip draft bootstrap -- both load states. The
ordinary path takes draft_token from build_tree_kernel_efficient, which returns
int64. A quiet instance never sees it.

LATENT, NOT INTRODUCED BY sgl-project#679, and this was checked before anything was
written. The int32 dates to upstream sgl-project#24724 (2026-05-08). The trivial path and
all three int32 constructions are byte-identical at 1d1dbf9, and no commit in
this chain touches python/sglang/srt/speculative/ at all. What sgl-project#679 changed is
SURVIVAL: the instance used to die at the allocator before it could keep taking
the trivial path at 0.97 usage. The park removed the earlier death and exposed
this one. That changes the framing, not the necessity.

THE FIX IS AT THE CONSTRUCTION SITE. A .to(long) in eagle_sample would fix this
crash and leave every other consumer free to be handed the wrong dtype.
EagleVerifyInput.__post_init__ enforces the contract for EVERY construction
path, present and future. The class already DECLARED that contract in its own
create_idle_input default (torch.empty((0,), dtype=torch.long)) -- a default is
not an invariant, and this makes it one.

The source is deliberately NOT changed: bonus_tokens must stay int32 for its
other consumers, so converting at its origin would trade this crash for a
different one.

CONVERT, DO NOT RAISE -- a serving instance degrades rather than dies, which is
the whole subject of sgl-project#679 -- and the conversion is a no-op on every compliant
path. But it is ANNOUNCED, once per offending dtype, because a fix that
silences its own trigger is how the defect returns: the next path to hand over
the wrong dtype would otherwise be absorbed without a word.

Tests: 12, extending the exhaustion work to the verify path at ~1.0 usage.
RED-FIRST against 82ba7e2: 7 fail there, including the crash reproduction
itself (int32 bonus_tokens -> int64 candidates). Covered: both bonus_tokens
branches, the float case the hypothesis proposed, value preservation across the
conversion, None, announce-once, silence on the compliant path, and three pins
that this stays a construction-site fix (post_init enforcement; the trivial path
still hands over bonus_tokens; eagle_sample still derives candidates from the
field -- if any of those move, the pin must move with them).

No regressions: 1017 pass, zero failures.

NOT BOOTED. Desk-only; READY-FOR-BOOT.
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation high priority run-ci CI: run the baseline test suite on this PR speculative-decoding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant