{"record":{"id":"bc9cae371f476d0c","repo":"sgl-project/sglang","slug":"both-speculative-num-draft-tokens-and-speculat","errorCode":null,"errorMessage":"Both --speculative-num-draft-tokens and --speculative-dflash-block-size are set but they differ. For DFLASH they must match. speculative_num_draft_tokens={}, speculative_dflash_block_size={}.","messagePattern":"Both --speculative-num-draft-tokens and --speculative-dflash-block-size are set but they differ\\. For DFLASH they must match\\. speculative_num_draft_tokens=(.+?), speculative_dflash_block_size=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/arg_groups/speculative_hook.py","lineNumber":257,"sourceCode":"            \"DFLASH only supports speculative_eagle_topk == 1; overriding speculative_eagle_topk=%s to 1.\",\n            cfg.speculative_eagle_topk,\n        )\n        declare_resolution(\n            server_args,\n            \"_handle_dflash\",\n            speculative_eagle_topk=1,\n        )\n\n    if cfg.speculative_dflash_block_size is not None:\n        if int(cfg.speculative_dflash_block_size) <= 0:\n            raise ValueError(\n                \"DFLASH requires --speculative-dflash-block-size to be positive, \"\n                f\"got {cfg.speculative_dflash_block_size}.\"\n            )\n        if cfg.speculative_num_draft_tokens is not None and int(\n            cfg.speculative_num_draft_tokens\n        ) != int(cfg.speculative_dflash_block_size):\n            raise ValueError(\n                \"Both --speculative-num-draft-tokens and --speculative-dflash-block-size are set \"\n                \"but they differ. For DFLASH they must match. \"\n                f\"speculative_num_draft_tokens={cfg.speculative_num_draft_tokens}, \"\n                f\"speculative_dflash_block_size={cfg.speculative_dflash_block_size}.\"\n            )\n        declare_resolution(\n            server_args,\n            \"_handle_dflash\",\n            speculative_num_draft_tokens=int(cfg.speculative_dflash_block_size),\n        )\n\n    if cfg.speculative_num_draft_tokens is None:\n        from sglang.srt.speculative.dflash_utils import (\n            parse_dflash_draft_config,\n        )\n\n        model_override_args = json.loads(cfg.json_model_override_args)\n        inferred_block_size = None","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/arg_groups/speculative_hook.py#L239-L275","documentation":"In DFLASH, --speculative-num-draft-tokens and --speculative-dflash-block-size denote the same quantity (the draft block size), so when both are supplied they must agree. Disagreement indicates a confused config and is rejected.","triggerScenarios":"Passing both --speculative-num-draft-tokens N and --speculative-dflash-block-size M with N != M.","commonSituations":"Copying EAGLE-style flags (num-draft-tokens) onto a DFLASH command line that also sets dflash-block-size; partial migration of old launch scripts.","solutions":["Make both values equal, e.g. both 16","Remove one of the two flags and let DFLASH infer/default it","Prefer setting only --speculative-dflash-block-size for DFLASH"],"exampleFix":"# before\n--speculative-num-draft-tokens 8 --speculative-dflash-block-size 16\n# after\n--speculative-dflash-block-size 16","handlingStrategy":"validation","validationCode":"a, b = args.speculative_num_draft_tokens, args.speculative_dflash_block_size\nif a is not None and b is not None and int(a) != int(b):\n    raise SystemExit('num_draft_tokens must equal dflash_block_size')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set only --speculative-dflash-block-size for DFLASH; drop EAGLE-style token flags"],"tags":["speculative-decoding","dflash","conflicting-arguments","block-size"],"backgroundTag":"conflicting-argument-values","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}