sgl-project/sglang · error · RuntimeError
decode_context_parallel_size ({decode_context_parallel_size}
Error message
decode_context_parallel_size ({decode_context_parallel_size}) must be >= 1 What it means
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.
Source
Thrown at python/sglang/srt/distributed/parallel_state.py:2421
# Get world size and rank. Ensure some consistencies.
assert torch.distributed.is_initialized()
backend = backend or torch.distributed.get_backend(get_world_group().device_group)
# Joiners construct their local TP/PP layout in global rank space.
world_size: int = (
tensor_model_parallel_size * pipeline_model_parallel_size
if recovered_rank
else torch.distributed.get_world_size()
)
if world_size != tensor_model_parallel_size * pipeline_model_parallel_size:
raise RuntimeError(
f"world_size ({world_size}) is not equal to "
f"tensor_model_parallel_size ({tensor_model_parallel_size}) x "
f"pipeline_model_parallel_size ({pipeline_model_parallel_size})"
)
if decode_context_parallel_size < 1:
raise RuntimeError(
f"decode_context_parallel_size ({decode_context_parallel_size}) must be >= 1"
)
if decode_context_parallel_size > 1 and not (is_hip() or is_cuda()):
raise RuntimeError(
"Decode context parallel (decode_context_parallel_size > 1) is "
"currently only supported on the AMD HIP platform or CUDA platform, but got "
f"decode_context_parallel_size ({decode_context_parallel_size}) "
"on a non-HIP or non-CUDA platform."
)
if tensor_model_parallel_size % decode_context_parallel_size != 0:
raise RuntimeError(
f"tensor_model_parallel_size ({tensor_model_parallel_size}) must be divisible by "
f"decode_context_parallel_size ({decode_context_parallel_size})"
)
# Build the tensor model-parallel groups.
num_tensor_model_parallel_groups: int = world_size // tensor_model_parallel_size
global _TPView on GitHub (pinned to 0132848349)
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
Example fix
# before --decode-context-parallel-size 0 # after --decode-context-parallel-size 1 # or omit the flag
Defensive patterns
Strategy: validation
Validate before calling
assert decode_context_parallel_size >= 1, 'decode_context_parallel_size must be >= 1'
Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- tensor_model_parallel_size ({tensor_model_parallel_size}) mu
- world_size ({world_size}) is not equal to tensor_model_paral
- Decode context parallel (decode_context_parallel_size > 1) i
- num_heads ({self.num_heads}) must be divisible by ulysses_de
- LTX2Attention requires heads divisible by tp_size, got {self
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/445bd9a7f344f088.
Report an issue: GitHub.