{"record":{"id":"393f0aae4681fa03","repo":"sgl-project/sglang","slug":"deepseekv4-cp-supports-moe-a2a-backend-in-support","errorCode":null,"errorMessage":"DeepSeekV4 CP supports moe_a2a_backend in {supported_a2a_backends}, got {cfg.moe_a2a_backend!r}.","messagePattern":"DeepSeekV4 CP supports moe_a2a_backend in (.+?), got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/arg_groups/deepseek_v4_hook.py","lineNumber":209,"sourceCode":"    declare_resolution(\n        server_args,\n        \"validate_deepseek_v4_cp\",\n        moe_dense_tp_size=1,\n    )\n    declare_resolution(\n        server_args,\n        \"validate_deepseek_v4_cp\",\n        attn_cp_size=cfg.tp_size // cfg.dp_size,\n    )\n    assert (\n        cfg.dp_size == 1\n    ), \"For round-robin split mode, dp attention is not supported.\"\n    assert (\n        cfg.tp_size <= 8\n    ), \"Context parallel only supports single machine (tp_size <= 8). Cross-machine CP has precision issues.\"\n    supported_a2a_backends = (\"none\", \"deepep\", \"megamoe\", \"mori\")\n    if cfg.moe_a2a_backend not in supported_a2a_backends:\n        raise ValueError(\n            f\"DeepSeekV4 CP supports moe_a2a_backend in {supported_a2a_backends}, \"\n            f\"got {cfg.moe_a2a_backend!r}.\"\n        )\n    logger.warning(\n        \"Disabling SGLANG_OPT_FLASHMLA_SPARSE_PREFILL because DeepSeekV4 \"\n        \"context parallelism is enabled.\"\n    )\n    envs.SGLANG_OPT_FLASHMLA_SPARSE_PREFILL.set(False)\n    logger.warning(\n        f\"Enable Context Parallel for DeepSeekV4, \"\n        f\"dp_size={cfg.dp_size}, moe_dense_tp_size={cfg.moe_dense_tp_size}, \"\n        f\"attn_cp_size={cfg.attn_cp_size}, ep_size={cfg.ep_size}, tp_size={cfg.tp_size}\"\n    )\n","sourceCodeStart":191,"sourceCodeEnd":223,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/arg_groups/deepseek_v4_hook.py#L191-L223","documentation":"When DeepSeek V4 runs with prefill context parallelism, the MoE all-to-all backend must be one of none, deepep, megamoe, or mori because only these backends have correct collective/precision behavior under CP for this model. Any other moe_a2a_backend is rejected.","triggerScenarios":"DeepSeek V4 + enable_prefill_cp with cfg.moe_a2a_backend outside (\"none\", \"deepep\", \"megamoe\", \"mori\") — e.g. \"flashinfer_tkv\" or another a2a backend — during _handle_model_specific_adjustments.","commonSituations":"Reusing an a2a backend tuned for a different model/cluster, or a launcher template that sets --moe-a2a-backend unconditionally; also defaulting to a backend not yet ported to CP paths.","solutions":["Set --moe-a2a-backend to one of none, deepep, megamoe, or mori","Remove the explicit --moe-a2a-backend flag to use the default","If you need a specific backend, disable --enable-prefill-cp"],"exampleFix":"# before\n--enable-prefill-cp --moe-a2a-backend some_backend\n# after\n--enable-prefill-cp --moe-a2a-backend deepep","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"none\", \"deepep\", \"megamoe\", \"mori\"}\nif getattr(cfg, 'enable_prefill_cp', False) and cfg.moe_a2a_backend not in SUPPORTED:\n    server_args.moe_a2a_backend = 'deepep'","typeGuard":null,"tryCatchPattern":"except ValueError as e:\n    if 'moe_a2a_backend' in str(e): server_args.moe_a2a_backend = 'deepep'\n    else: raise","preventionTips":["Keep DeepSeek V4 CP launch templates with an explicit supported --moe-a2a-backend","Validate the tuple in config-management code before server start"],"tags":["deepseek","moe","a2a-backend","context-parallel","sglang"],"backgroundTag":"unsupported-backend-combination","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}