{"record":{"id":"445bd9a7f344f088","repo":"sgl-project/sglang","slug":"decode-context-parallel-size-decode-context-para","errorCode":null,"errorMessage":"decode_context_parallel_size ({decode_context_parallel_size}) must be >= 1","messagePattern":"decode_context_parallel_size \\((.+?)\\) must be >= 1","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/distributed/parallel_state.py","lineNumber":2421,"sourceCode":"    # Get world size and rank. Ensure some consistencies.\n    assert torch.distributed.is_initialized()\n    backend = backend or torch.distributed.get_backend(get_world_group().device_group)\n\n    # Joiners construct their local TP/PP layout in global rank space.\n    world_size: int = (\n        tensor_model_parallel_size * pipeline_model_parallel_size\n        if recovered_rank\n        else torch.distributed.get_world_size()\n    )\n\n    if world_size != tensor_model_parallel_size * pipeline_model_parallel_size:\n        raise RuntimeError(\n            f\"world_size ({world_size}) is not equal to \"\n            f\"tensor_model_parallel_size ({tensor_model_parallel_size}) x \"\n            f\"pipeline_model_parallel_size ({pipeline_model_parallel_size})\"\n        )\n    if decode_context_parallel_size < 1:\n        raise RuntimeError(\n            f\"decode_context_parallel_size ({decode_context_parallel_size}) must be >= 1\"\n        )\n    if decode_context_parallel_size > 1 and not (is_hip() or is_cuda()):\n        raise RuntimeError(\n            \"Decode context parallel (decode_context_parallel_size > 1) is \"\n            \"currently only supported on the AMD HIP platform or CUDA platform, but got \"\n            f\"decode_context_parallel_size ({decode_context_parallel_size}) \"\n            \"on a non-HIP or non-CUDA platform.\"\n        )\n    if tensor_model_parallel_size % decode_context_parallel_size != 0:\n        raise RuntimeError(\n            f\"tensor_model_parallel_size ({tensor_model_parallel_size}) must be divisible by \"\n            f\"decode_context_parallel_size ({decode_context_parallel_size})\"\n        )\n\n    # Build the tensor model-parallel groups.\n    num_tensor_model_parallel_groups: int = world_size // tensor_model_parallel_size\n    global _TP","sourceCodeStart":2403,"sourceCodeEnd":2439,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/distributed/parallel_state.py#L2403-L2439","documentation":"initialize_model_parallel requires decode_context_parallel_size >= 1 (it is a multiplicity factor for splitting decode attention across ranks). Values of 0 or negative are invalid and rejected before any process group is built.","triggerScenarios":"Passing decode_context_parallel_size < 1 to initialize_model_parallel — e.g. via a server arg that computed/decoded to 0 (misconfigured --decode-context-parallel-size or a bad default in a custom launch script).","commonSituations":"A wrapper script derives the value by division that rounds to 0 (e.g. tp // dp with dp > tp); explicitly setting the flag to 0 thinking it disables DCP; config typos or negative values from templated YAML.","solutions":["Set decode_context_parallel_size to 1 (the no-op default) or a valid divisor of tensor_model_parallel_size","Audit how the value is computed in your launcher/config before it reaches initialize_model_parallel","Rerun with the corrected flag, e.g. --decode-context-parallel-size 1"],"exampleFix":"# before\n--decode-context-parallel-size 0\n# after\n--decode-context-parallel-size 1  # or omit the flag","handlingStrategy":"validation","validationCode":"assert decode_context_parallel_size >= 1, 'decode_context_parallel_size must be >= 1'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat 1 as the explicit no-DCP value rather than 0","Validate derived config values (tp//dp style computations) before launch","Unit-test launcher config math"],"tags":["parallelism","decode-context-parallel","config-validation","sglang"],"backgroundTag":"parallel-config-validation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}