{"record":{"id":"5e692fe079fa177e","repo":"sgl-project/sglang","slug":"dspark-with-dp-attention-requires-enable-dp-lm-h","errorCode":null,"errorMessage":"DSpark with dp attention requires --enable-dp-lm-head.","messagePattern":"DSpark with dp attention requires --enable-dp-lm-head\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/arg_groups/speculative_hook.py","lineNumber":358,"sourceCode":"    from sglang.srt.speculative.dspark_components.dspark_config import (\n        checkpoint_bundles_dspark_draft,\n    )\n\n    return checkpoint_bundles_dspark_draft(server_args.get_model_config().hf_config)\n\n\ndef _handle_dspark(server_args: ServerArgs) -> None:\n    cfg = resolving_view(server_args)\n    _is_npu = cfg.device.startswith(\"npu\")\n    if not cfg.device.startswith((\"cuda\", \"npu\")):\n        raise ValueError(\n            \"DSpark speculative decoding only supports CUDA or NPU device.\"\n        )\n\n    # dp_size==1 with dp_attention is a degenerate flag under DSV4 CP; skip DP-only checks.\n    if cfg.enable_dp_attention and cfg.dp_size > 1:\n        if not cfg.enable_dp_lm_head:\n            raise ValueError(\"DSpark with dp attention requires --enable-dp-lm-head.\")\n        if not _is_npu and cfg.moe_a2a_backend not in (\"none\", \"megamoe\"):\n            raise ValueError(\n                \"DSpark with dp attention supports moe_a2a_backend 'none' \"\n                \"(built-in TP MoE) or 'megamoe', got \"\n                f\"{cfg.moe_a2a_backend!r}.\"\n            )\n        if not _is_npu and cfg.moe_a2a_backend != \"none\":\n            from sglang.srt.speculative.ragged_verify import (\n                RaggedVerifyMode,\n                read_ragged_verify_mode,\n            )\n\n            if read_ragged_verify_mode() is not RaggedVerifyMode.STATIC:\n                raise ValueError(\n                    \"DSpark with dp attention + \"\n                    f\"moe_a2a_backend={cfg.moe_a2a_backend!r} requires \"\n                    \"SGLANG_RAGGED_VERIFY_MODE=static.\"\n                )","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/arg_groups/speculative_hook.py#L340-L376","documentation":"When DSpark is combined with real data-parallel attention (dp_size > 1), the lm head must be sharded in DP mode so per-DP-rank logits line up with verification. The hook requires --enable-dp-lm-head in that case.","triggerScenarios":"Launching with speculative_algorithm=DSPARK, --enable-dp-attention, --dp-size > 1, without --enable-dp-lm-head.","commonSituations":"Standard DeepSeek-style DP-attention launch (dp attention without DP lm head) reused for DSpark; dp_lm_head omitted because it's optional for non-speculative runs.","solutions":["Add --enable-dp-lm-head to the launch command","Or drop --enable-dp-attention / set dp_size=1 if DP attention is not required","Verify with dp_size==1 the check is skipped intentionally (degenerate flag) and adjust flags accordingly"],"exampleFix":"# before\n--speculative-algorithm DSPARK --enable-dp-attention --dp-size 4\n# after\n--speculative-algorithm DSPARK --enable-dp-attention --dp-size 4 --enable-dp-lm-head","handlingStrategy":"validation","validationCode":"if args.enable_dp_attention and args.dp_size > 1 and not args.enable_dp_lm_head:\n    raise SystemExit('DSPARK + dp attention requires --enable-dp-lm-head')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat dp attention + dp lm head as one unit in DSPARK launch presets"],"tags":["speculative-decoding","dspark","dp-attention","lm-head"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}