{"record":{"id":"ff1f6c98d1be2305","repo":"sgl-project/sglang","slug":"speculative-draft-window-size-must-be-specu","errorCode":null,"errorMessage":"--speculative-draft-window-size must be >= --speculative-num-draft-tokens (block_size). window_size={}, block_size={}.","messagePattern":"--speculative-draft-window-size must be >= --speculative-num-draft-tokens \\(block_size\\)\\. window_size=(.+?), block_size=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/arg_groups/speculative_hook.py","lineNumber":310,"sourceCode":"                e,\n            )\n\n        if inferred_block_size is None:\n            inferred_block_size = 16\n            logger.warning(\n                \"speculative_num_draft_tokens is not set; defaulting to %d for DFLASH.\",\n                inferred_block_size,\n            )\n        declare_resolution(\n            server_args,\n            \"_handle_dflash\",\n            speculative_num_draft_tokens=inferred_block_size,\n        )\n\n    if cfg.speculative_draft_window_size is not None:\n        draft_tokens = int(cfg.speculative_num_draft_tokens)\n        if cfg.speculative_draft_window_size < draft_tokens:\n            raise ValueError(\n                \"--speculative-draft-window-size must be >= \"\n                \"--speculative-num-draft-tokens (block_size). \"\n                f\"window_size={cfg.speculative_draft_window_size}, block_size={draft_tokens}.\"\n            )\n\n    _resolve_dflash_draft_attention_backend(server_args)\n\n    if cfg.max_running_requests is None:\n        declare_resolution(\n            server_args,\n            \"_handle_dflash\",\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:","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/arg_groups/speculative_hook.py#L292-L328","documentation":"DFLASH's draft window must be at least as large as the draft block (num draft tokens), otherwise there is no room to draft even one block. The hook validates speculative_draft_window_size >= speculative_num_draft_tokens.","triggerScenarios":"Passing --speculative-draft-window-size smaller than the resolved --speculative-num-draft-tokens (block size).","commonSituations":"Tuning window size down for memory savings while keeping a larger block size; stale window value after increasing block size.","solutions":["Set --speculative-draft-window-size >= block size (e.g. block 16 -> window >= 16)","Omit --speculative-draft-window-size to use the default","If memory-constrained, lower both window and block size together"],"exampleFix":"# before\n--speculative-dflash-block-size 32 --speculative-draft-window-size 16\n# after\n--speculative-dflash-block-size 32 --speculative-draft-window-size 32","handlingStrategy":"validation","validationCode":"if args.speculative_draft_window_size is not None:\n    block = int(args.speculative_num_draft_tokens or 0)\n    if args.speculative_draft_window_size < block:\n        raise SystemExit('window_size must be >= block size')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive window size from block size in scripts (window = max(window, block))"],"tags":["speculative-decoding","dflash","window-size","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}