{"record":{"id":"db5e8e90c8a93636","repo":"sgl-project/sglang","slug":"decode-context-parallel-decode-context-parallel-s","errorCode":null,"errorMessage":"Decode context parallel (decode_context_parallel_size > 1) is currently only supported on the AMD HIP platform or CUDA platform, but got decode_context_parallel_size ({decode_context_parallel_size}) on a non-HIP or non-CUDA platform.","messagePattern":"Decode context parallel \\(decode_context_parallel_size > 1\\) is currently only supported on the AMD HIP platform or CUDA platform, but got decode_context_parallel_size \\((.+?)\\) on a non-HIP or non-CUDA platform\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/distributed/parallel_state.py","lineNumber":2425,"sourceCode":"    # 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\n    assert _TP is None, \"tensor model parallel group is already initialized\"\n    group_ranks = []\n    for tp_group_idx in range(num_tensor_model_parallel_groups):\n        ranks = list(","sourceCodeStart":2407,"sourceCodeEnd":2443,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/distributed/parallel_state.py#L2407-L2443","documentation":"Decode context parallelism (decode_context_parallel_size > 1) splits decode-phase attention across ranks and its kernels are only implemented for AMD HIP and CUDA platforms. initialize_model_parallel rejects DCP > 1 on any other platform (e.g. CPU or other accelerators).","triggerScenarios":"Calling initialize_model_parallel with decode_context_parallel_size > 1 while is_hip() and is_cuda() are both false — i.e. running on a non-CUDA/non-HIP device or torch build.","commonSituations":"Reusing a DCP-enabled launch config on CPU/other-accelerator machines (CI, dev laptops); running a CPU-only torch build (torch.version.cuda is None makes is_cuda() false) on GPU hardware by accident.","solutions":["Install/use a CUDA or ROCm build of PyTorch and GPU hardware so is_cuda()/is_hip() is true","If on unsupported hardware, set decode_context_parallel_size back to 1","Verify platform detection: python -c 'import torch; print(torch.cuda.is_available(), torch.version.hip)'"],"exampleFix":"# before (CPU-only torch)\n--decode-context-parallel-size 2\n# after: install CUDA torch and keep the flag, or run without DCP\npip install torch --index-url https://download.pytorch.org/whl/cu121\n# or\n--decode-context-parallel-size 1","handlingStrategy":"validation","validationCode":"from sglang.srt.utils import is_cuda, is_hip\nif dcp_size > 1:\n    assert is_cuda() or is_hip(), 'DCP>1 requires CUDA or HIP platform'","typeGuard":"def dcp_supported() -> bool:\n    from sglang.srt.utils import is_cuda, is_hip\n    return is_cuda() or is_hip()","tryCatchPattern":null,"preventionTips":["Confirm torch.version.cuda/hip before enabling DCP","Keep DCP flags out of CPU CI configs","Install GPU torch builds on GPU nodes"],"tags":["parallelism","decode-context-parallel","platform-support","cuda","rocm","sglang"],"backgroundTag":"unsupported-hardware-backend","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}