{"record":{"id":"b5f46174d9adceab","repo":"sgl-project/sglang","slug":"dspark-speculative-num-draft-tokens-must-be-2","errorCode":null,"errorMessage":"DSpark speculative_num_draft_tokens must be >= 2 (= gamma + 1), got {}.","messagePattern":"DSpark speculative_num_draft_tokens must be >= 2 \\(= gamma \\+ 1\\), got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/arg_groups/speculative_hook.py","lineNumber":511,"sourceCode":"        ):\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), \"\n            f\"got {cfg.speculative_num_draft_tokens}.\"\n        )\n\n    if cfg.max_running_requests is None:\n        declare_resolution(\n            server_args,\n            \"_handle_dspark\",\n            max_running_requests=48,\n        )\n        logger.warning(\n            \"Max running requests is reset to 48 for speculative decoding. You can override this by explicitly setting --max-running-requests.\"\n        )\n\n    if cfg.enable_mixed_chunk:\n        declare_resolution(\n            server_args,\n            \"_handle_dspark\",","sourceCodeStart":493,"sourceCodeEnd":529,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/arg_groups/speculative_hook.py#L493-L529","documentation":"DSpark verification needs at least one draft token plus the bonus token, so speculative_num_draft_tokens must be >= 2. Values below 2 degenerate to non-speculative decoding and are rejected.","triggerScenarios":"Passing --speculative-num-draft-tokens 1 (or 0) on a DSpark launch, or a draft config that resolves a window < 2.","commonSituations":"Users lowering draft token count to reduce memory; misunderstanding that 1 means 'no speculation' rather than minimal speculation.","solutions":["Set --speculative-num-draft-tokens >= 2 (ideally gamma+1 matching block size)","Set --speculative-dspark-block-size >= 1 so the window defaults to >= 2","Disable speculative decoding entirely if minimal speculation was the goal"],"exampleFix":"# before\n--speculative-num-draft-tokens 1\n# after\n--speculative-num-draft-tokens 5 --speculative-dspark-block-size 4","handlingStrategy":"validation","validationCode":"if args.speculative_algorithm == 'DSPARK' and int(args.speculative_num_draft_tokens or 0) < 2:\n    raise SystemExit('num_draft_tokens must be >= 2 (gamma + 1)')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember num_draft_tokens includes the bonus token; minimum meaningful value is 2"],"tags":["speculative-decoding","dspark","num-draft-tokens","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}