{"record":{"id":"e6968f0acfa994de","repo":"sgl-project/sglang","slug":"speculative-use-rejection-sampling-is-only-suppo","errorCode":null,"errorMessage":"--speculative-use-rejection-sampling is only supported for EAGLE / EAGLE3 / NEXTN, not speculative_algorithm={}.","messagePattern":"--speculative-use-rejection-sampling is only supported for EAGLE / EAGLE3 / NEXTN, not speculative_algorithm=(.+?)\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/arg_groups/speculative_hook.py","lineNumber":773,"sourceCode":"            \"_handle_eagle_family.auto_params\",\n            speculative_num_steps=steps,\n            speculative_eagle_topk=topk,\n            speculative_num_draft_tokens=draft_tokens,\n        )\n\n    if \"trtllm_mha\" in attention_backends_of(resolved_view(server_args)):\n        if cfg.speculative_eagle_topk > 1:\n            raise ValueError(\n                \"trtllm_mha backend only supports topk = 1 for speculative decoding.\"\n            )\n\n    if cfg.speculative_use_rejection_sampling:\n        # Resolved alias by now: NEXTN -> EAGLE, Gemma4 draft -> FROZEN_KV_MTP.\n        # Only the EAGLE/EAGLE3 draft workers emit a target-vocab proposal that\n        # the rejection-sampling kernel consumes; everything else (STANDALONE,\n        # FROZEN_KV_MTP, NGRAM, DFLASH) is unsupported.\n        if cfg.speculative_algorithm not in (\"EAGLE\", \"EAGLE3\"):\n            raise NotImplementedError(\n                \"--speculative-use-rejection-sampling is only supported for \"\n                \"EAGLE / EAGLE3 / NEXTN, not \"\n                f\"speculative_algorithm={cfg.speculative_algorithm}.\"\n            )\n        if cfg.speculative_eagle_topk != 1:\n            raise ValueError(\n                \"--speculative-use-rejection-sampling requires --speculative-eagle-topk=1.\"\n            )\n        if (\n            cfg.speculative_accept_threshold_single != 1.0\n            or cfg.speculative_accept_threshold_acc != 1.0\n        ):\n            raise ValueError(\n                \"--speculative-use-rejection-sampling is incompatible with \"\n                \"--speculative-accept-threshold-single / \"\n                \"--speculative-accept-threshold-acc; rejection sampling ignores \"\n                \"the accept thresholds.\"\n            )","sourceCodeStart":755,"sourceCodeEnd":791,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/arg_groups/speculative_hook.py#L755-L791","documentation":"SGLang's --speculative-use-rejection-sampling flag routes speculative verification through a rejection-sampling kernel that only exists for the EAGLE-family draft workers (EAGLE, EAGLE3, and NEXTN which resolves to EAGLE). Only those workers emit a target-vocab proposal distribution the kernel can compare against. The server-args hook raises NotImplementedError when any other speculative algorithm (STANDALONE, FROZEN_KV_MTP, NGRAM, DFLASH) is combined with this flag.","triggerScenarios":"Launching the server with --speculative-use-rejection-sampling together with --speculative-algorithm set to NGRAM, STANDALONE, FROZEN_KV_MTP, or DFLASH. Note NEXTN and Gemma4-draft aliases are resolved before this check, so NEXTN is accepted while its resolved forms like FROZEN_KV_MTP are not.","commonSituations":"Copying an EAGLE launch command but swapping in --speculative-algorithm NGRAM or a MTP variant; enabling a new MTP-style algorithm (e.g. a frozen-KV draft model) and assuming rejection sampling carries over; upgrading SGLang where a previously accepted draft backend was renamed/reclassified.","solutions":["Set --speculative-algorithm EAGLE or EAGLE3 (NEXTN also resolves to EAGLE) if you want rejection sampling","Remove --speculative-use-rejection-sampling if you must use NGRAM/STANDALONE/FROZEN_KV_MTP/DFLASH — they fall back to the standard tree-based verify path","If you wanted NEXTN behavior, keep --speculative-algorithm NEXTN (alias resolves to EAGLE) rather than a FROZEN_KV_MTP/Gemma4 draft path"],"exampleFix":"# before\n--speculative-algorithm NGRAM --speculative-use-rejection-sampling\n# after\n--speculative-algorithm NGRAM   # rejection sampling dropped","handlingStrategy":"validation","validationCode":"from sglang.srt.arg_groups.speculative_hook import resolving_view\nalgo = resolving_view(server_args).speculative_algorithm\nif server_args.speculative_use_rejection_sampling and algo not in (\"EAGLE\", \"EAGLE3\", \"NEXTN\"):\n    # drop the flag or switch algorithm before launch\n    server_args.speculative_use_rejection_sampling = False","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep one launch script per speculative algorithm instead of mixing flags","Assert the algorithm is EAGLE/EAGLE3/NEXTN before setting --speculative-use-rejection-sampling"],"tags":["speculative-decoding","rejection-sampling","server-args","eagle"],"backgroundTag":"incompatible-launch-flags","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}