{"record":{"id":"6fbbc2a22b7ee5a2","repo":"sgl-project/sglang","slug":"dspark-speculative-num-draft-tokens-must-equal-gam","errorCode":null,"errorMessage":"DSpark speculative_num_draft_tokens must equal gamma + 1 (= {} for gamma={}), but got speculative_num_draft_tokens={}.","messagePattern":"DSpark speculative_num_draft_tokens must equal gamma \\+ 1 \\(= (.+?) for gamma=(.+?)\\), but got speculative_num_draft_tokens=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/arg_groups/speculative_hook.py","lineNumber":494,"sourceCode":"            )\n        gamma = int(cfg.speculative_dspark_block_size)\n    else:\n        if draft_config is not None:\n            gamma = draft_config.resolve_gamma(default=None)\n        if gamma is None and cfg.speculative_num_draft_tokens is None:\n            gamma = DEFAULT_DSPARK_GAMMA\n            logger.warning(\n                \"DSpark gamma is not set; defaulting to %d.\",\n                gamma,\n            )\n\n    if gamma is not None:\n        verify_window = int(gamma) + 1\n        if (\n            cfg.speculative_num_draft_tokens is not None\n            and int(cfg.speculative_num_draft_tokens) != verify_window\n        ):\n            raise ValueError(\n                \"DSpark speculative_num_draft_tokens must equal gamma + 1 \"\n                f\"(= {verify_window} for gamma={gamma}), but got \"\n                f\"speculative_num_draft_tokens={cfg.speculative_num_draft_tokens}.\"\n            )\n        declare_resolution(\n            server_args,\n            \"_handle_dspark\",\n            speculative_num_draft_tokens=verify_window,\n        )\n\n    if cfg.speculative_num_draft_tokens is None:\n        raise ValueError(\n            \"DSpark could not resolve speculative_num_draft_tokens; set \"\n            \"--speculative-dspark-block-size (= gamma).\"\n        )\n    if int(cfg.speculative_num_draft_tokens) < 2:\n        raise ValueError(\n            \"DSpark speculative_num_draft_tokens must be >= 2 (= gamma + 1), \"","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/arg_groups/speculative_hook.py#L476-L512","documentation":"DSpark requires speculative_num_draft_tokens to equal gamma + 1, where gamma is --speculative-dspark-block-size. If the user sets num_draft_tokens to any other value, the invariant is violated and rejected.","triggerScenarios":"Passing both --speculative-dspark-block-size G and --speculative-num-draft-tokens N where N != G + 1.","commonSituations":"Reusing EAGLE-style flags where num_draft_tokens = steps*topk + 1 and can exceed gamma+1; stale num_draft_tokens after changing block size.","solutions":["Remove --speculative-num-draft-tokens and let DSpark default it to gamma+1","Or set it explicitly to gamma + 1 (e.g. block size 4 -> 5)","Keep a single source of truth: only set --speculative-dspark-block-size"],"exampleFix":"# before\n--speculative-dspark-block-size 4 --speculative-num-draft-tokens 8\n# after\n--speculative-dspark-block-size 4 --speculative-num-draft-tokens 5","handlingStrategy":"validation","validationCode":"g = args.speculative_dspark_block_size\nif g is not None and args.speculative_num_draft_tokens is not None:\n    if int(args.speculative_num_draft_tokens) != int(g) + 1:\n        raise SystemExit('num_draft_tokens must be gamma + 1')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only set --speculative-dspark-block-size; let num_draft_tokens default"],"tags":["speculative-decoding","dspark","conflicting-arguments","num-draft-tokens"],"backgroundTag":"conflicting-argument-values","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}