sgl-project/sglang · error · ValueError
Invalid simulate_acc_method
Error message
Invalid simulate_acc_method: {simulate_acc_method} What it means
Speculative decoding accuracy-simulation error: the configured simulate_acc_method string does not match any supported method. Supported values are defined in spec_utils (e.g. fixed-rate style methods); the invalid method name is included in the message.
Solutions
- Check the if/elif chain in spec_utils.py:sample_simulated_acc_len for accepted method strings
- Fix the typo in the simulate_acc_method config
- If you need a new method, implement the branch and add it to validation
Example fix
# before sample_simulated_acc_len(..., simulate_acc_method='unifrom') # after sample_simulated_acc_len(..., simulate_acc_method='uniform')
Defensive patterns
Strategy: validation
Validate before calling
valid_methods = {'fixed_prob', 'uniform', 'normal'} # mirror the if/elif chain in spec_utils.py
assert simulate_acc_method in valid_methods, simulate_acc_method Type guard
def is_valid_acc_method(m: str) -> bool:
return m in {'fixed_prob', 'uniform', 'normal'} Prevention
- Validate config strings against the source's supported set when adding new knobs
When it happens
Trigger: Passing simulate_acc_method other than the supported options (e.g. a typo like 'unifrom' instead of 'uniform', or a new method not implemented), via apply_dflash_simulated_acceptance or related simulated-acceptance APIs.
Common situations: Configuring DFlash simulated acceptance with a mistyped method name; version mismatch where a method was renamed/removed.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- backend must be a non-empty string
- capped layout has a row exceeding cap=
- capture layout cannot pack num_tokens=
- capture layout needs 1 <= num_slots <= num_tokens, got…
- every request must verify the anchor (verify_len >= 1), got
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/18a7926e2746e329.
Report an issue: GitHub.
Appendix: source
Thrown at python/sglang/srt/speculative/spec_utils.py:392
elif simulate_acc_method == "match-expected":
# multinomial sampling does not match the expected length
# we keep it for the sake of compatibility of existing tests
# but it's better to use "match-expected" for the cases that need to
# match the expected length, One caveat is that this will only sample
# either round down or round up of the expected length
simulate_acc_len = max(1.0, min(max_len, simulate_acc_len))
lower = int(simulate_acc_len // 1)
upper = lower + 1 if lower < max_len else lower
if lower == upper:
simulate_acc_len = lower
else:
weight_upper = simulate_acc_len - lower
weight_lower = 1.0 - weight_upper
probs = torch.tensor([weight_lower, weight_upper], device="cpu")
sampled_index = torch.multinomial(probs, num_samples=1)
simulate_acc_len = lower if sampled_index == 0 else upper
else:
raise ValueError(f"Invalid simulate_acc_method: {simulate_acc_method}")
return int(simulate_acc_len)
def generate_simulated_accept_index(
accept_index,
predict,
num_correct_drafts,
candidates,
target_predict,
bs,
spec_steps,
simulate_acc_len: float = SIMULATE_ACC_LEN,
simulate_acc_method: str = SIMULATE_ACC_METHOD,
simulate_acc_token_mode: str = SIMULATE_ACC_TOKEN_MODE,
):
use_real_draft_tokens = simulate_acc_token_mode == "real-draft-token"
assert simulate_acc_len > 0.0View on GitHub (pinned to 0132848349)