{"record":{"id":"18a7926e2746e329","repo":"sgl-project/sglang","slug":"invalid-simulate-acc-method-simulate-acc-method","errorCode":null,"errorMessage":"Invalid simulate_acc_method: {simulate_acc_method}","messagePattern":"Invalid simulate_acc_method: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/speculative/spec_utils.py","lineNumber":392,"sourceCode":"    elif simulate_acc_method == \"match-expected\":\n        # multinomial sampling does not match the expected length\n        # we keep it for the sake of compatibility of existing tests\n        # but it's better to use \"match-expected\" for the cases that need to\n        # match the expected length, One caveat is that this will only sample\n        # either round down or round up of the expected length\n        simulate_acc_len = max(1.0, min(max_len, simulate_acc_len))\n        lower = int(simulate_acc_len // 1)\n        upper = lower + 1 if lower < max_len else lower\n        if lower == upper:\n            simulate_acc_len = lower\n        else:\n            weight_upper = simulate_acc_len - lower\n            weight_lower = 1.0 - weight_upper\n            probs = torch.tensor([weight_lower, weight_upper], device=\"cpu\")\n            sampled_index = torch.multinomial(probs, num_samples=1)\n            simulate_acc_len = lower if sampled_index == 0 else upper\n    else:\n        raise ValueError(f\"Invalid simulate_acc_method: {simulate_acc_method}\")\n    return int(simulate_acc_len)\n\n\ndef generate_simulated_accept_index(\n    accept_index,\n    predict,\n    num_correct_drafts,\n    candidates,\n    target_predict,\n    bs,\n    spec_steps,\n    simulate_acc_len: float = SIMULATE_ACC_LEN,\n    simulate_acc_method: str = SIMULATE_ACC_METHOD,\n    simulate_acc_token_mode: str = SIMULATE_ACC_TOKEN_MODE,\n):\n    use_real_draft_tokens = simulate_acc_token_mode == \"real-draft-token\"\n\n    assert simulate_acc_len > 0.0","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/speculative/spec_utils.py#L374-L410","documentation":"sample_simulated_acc_len supports a fixed set of simulate_acc_method values (its if/elif chain). An unrecognized method string reaches the else branch and raises ValueError.","triggerScenarios":"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.","commonSituations":"Configuring DFlash simulated acceptance with a mistyped method name; version mismatch where a method was renamed/removed.","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"],"exampleFix":"# before\nsample_simulated_acc_len(..., simulate_acc_method='unifrom')\n# after\nsample_simulated_acc_len(..., simulate_acc_method='uniform')","handlingStrategy":"validation","validationCode":"valid_methods = {'fixed_prob', 'uniform', 'normal'}  # mirror the if/elif chain in spec_utils.py\nassert simulate_acc_method in valid_methods, simulate_acc_method","typeGuard":"def is_valid_acc_method(m: str) -> bool:\n    return m in {'fixed_prob', 'uniform', 'normal'}","tryCatchPattern":null,"preventionTips":["Validate config strings against the source's supported set when adding new knobs"],"tags":["speculative-decoding","validation","configuration"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}