sgl-project/sglang · error · ValueError
Invalid decoupled draft scheduler rid: {rid}
Error message
Invalid decoupled draft scheduler rid: {rid} What it means
Decoupled draft/verifier request ids are encoded as '<rank>:<request_id>' (parsed by parse_draft_scheduler_rid). If the string has no separator, an empty request_id, or a rank part that is not an integer, parsing falls through and raises this ValueError.
Source
Thrown at python/sglang/srt/speculative/decoupled_spec_io.py:40
src_verifier_rank: int
request_id: str
def build_draft_scheduler_rid(draft_key: DraftReqKey) -> str:
return f"draft:{int(draft_key.src_verifier_rank)}:{draft_key.request_id}"
def parse_draft_scheduler_rid(rid: str) -> DraftReqKey:
if rid.startswith("draft:"):
encoded = rid[len("draft:") :]
rank_text, sep, request_id = encoded.partition(":")
if sep and request_id:
return DraftReqKey(
src_verifier_rank=int(rank_text),
request_id=request_id,
)
raise ValueError(f"Invalid decoupled draft scheduler rid: {rid}")
@dataclass
class DraftSync:
"""Open or re-open a drafter request from a verifier-owned prefix.
The verifier is the source of truth for committed tokens. DraftSync gives
the drafter the prompt and already committed output prefix that it must
align to before it can emit draft tail tokens.
"""
request_id: str
src_verifier_rank: int
dst_drafter_rank: int
prompt_token_ids: list[int] = field(default_factory=list)
committed_outputs: list[int] = field(default_factory=list)
@propertyView on GitHub (pinned to 0132848349)
Solutions
- Construct the rid with the provided encoder (DraftReqKey -> its to_rid/format method) instead of string concatenation
- Ensure the format is f"{rank}:{request_id}" with an int rank and non-empty request_id
- If request_id may contain ':', split on the first colon only (partition)
Example fix
# before
rid = request_id # missing rank prefix
key = parse_draft_scheduler_rid(rid)
# after
rid = f"{key.src_verifier_rank}:{key.request_id}"
key = parse_draft_scheduler_rid(rid) Defensive patterns
Strategy: type-guard
Validate before calling
import re
RID_RE = re.compile(r"^(\d+):(.+)$")
assert RID_RE.match(rid), f"malformed rid: {rid!r}" Type guard
def is_valid_draft_rid(rid: str) -> bool:
rank, sep, req = rid.partition(":")
return bool(sep and req and rank.isdigit()) Try / catch
try:
key = parse_draft_scheduler_rid(rid)
except ValueError:
log.warning("dropping malformed rid %r", rid); return None Prevention
- Only build rids via the DraftReqKey encoder, never string concatenation
- Split on the first colon so request ids containing ':' survive round-trips
When it happens
Trigger: Passing a raw request id without the 'rank:' prefix, an id like '0:' with empty request text, or ':req'/'abc:req' where int(rank_text) fails; exercised by test_parse_invalid_rid_raises and the colon round-trip tests.
Common situations: Hand-building rids instead of using DraftReqKey.format/encode; rank serialized as a non-numeric value; request_id that itself contains colons parsed from the wrong (leftmost vs rightmost) split.
Related errors
- --decoupled-spec-bind-endpoint, --decoupled-spec-connect-end
- External ngram corpus path does not exist: {path}
- VerifyCommit committed_tokens must be non-empty: request_id=
- v_cache must be provided
- q can only be None when only_qv=True
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/5ea33a0baca65dfa.
Report an issue: GitHub.