sgl-project/sglang · critical · RuntimeError
world_size ({world_size}) is less than tensor_parallel_degre
Error message
world_size ({world_size}) is less than tensor_parallel_degree ({tensor_parallel_degree}) x pipeline_parallel_degree ({pipeline_parallel_degree}) xsequence_parallel_degree ({sequence_parallel_degree}) xclassifier_free_guidance_degree ({classifier_free_guidance_degree}) xdata_parallel_degree ({data_parallel_size}) What it means
Raised by initialize_model_parallel when the total requested parallelism (tensor x pipeline x sequence x classifier-free-guidance x data parallel degrees) exceeds the initialized world_size. The product of all parallel degrees must fit within the number of distributed ranks.
Source
Thrown at python/sglang/multimodal_gen/runtime/distributed/parallel_state.py:443
if backend is None:
from sglang.multimodal_gen.runtime.platforms import current_platform
backend = current_platform.get_torch_distributed_backend_str()
# Get world size and rank. Ensure some consistencies.
assert torch.distributed.is_initialized()
world_size: int = torch.distributed.get_world_size()
backend = backend or torch.distributed.get_backend(get_world_group().device_group)
dit_parallel_size = (
data_parallel_size
* classifier_free_guidance_degree
* sequence_parallel_degree
* pipeline_parallel_degree
* tensor_parallel_degree
)
if world_size < dit_parallel_size:
raise RuntimeError(
f"world_size ({world_size}) is less than "
f"tensor_parallel_degree ({tensor_parallel_degree}) x "
f"pipeline_parallel_degree ({pipeline_parallel_degree}) x"
f"sequence_parallel_degree ({sequence_parallel_degree}) x"
f"classifier_free_guidance_degree "
f"({classifier_free_guidance_degree}) x"
f"data_parallel_degree ({data_parallel_size})"
)
rank_generator: RankGenerator = RankGenerator(
tensor_parallel_degree,
sequence_parallel_degree,
pipeline_parallel_degree,
classifier_free_guidance_degree,
data_parallel_size,
"tp-sp-pp-cfg-dp",
)
global _DPView on GitHub (pinned to 0132848349)
Solutions
- Reduce the parallel degrees (tp/pp/sp/cfg) so their product times data_parallel_size is <= world_size
- Or increase world_size (more ranks/GPUs) to at least the product of the degrees
- Verify data_parallel_size is not implicitly inflating the requirement; often world_size/tp should equal dp, not require dp extra ranks
Example fix
# before --tensor-parallel-degree 8 --data-parallel-size 2 # world_size=8 # after --tensor-parallel-degree 4 --data-parallel-size 2 # 4*2=8 <= 8
Defensive patterns
Strategy: validation
Validate before calling
def check_degrees(world_size, tp, pp, sp, cfg, dp):
need = tp * pp * sp * cfg * dp
assert world_size >= need, f"need {need} ranks, have {world_size}"
return True Prevention
- Derive one degree from the others (e.g. dp = world_size // (tp*pp)) instead of over-specifying
- Add a startup assertion on the degree product before launching distributed init
- Validate config in CI against the actual GPU count
When it happens
Trigger: Calling maybe_init_distributed_environment_and_model_parallel with e.g. tp=8, pp=2 on a world_size of 8, or setting data_parallel_size such that tp*pp*sp*cfg*dp > world_size.
Common situations: Misconfigured CLI/server args (e.g. --tp 8 on 4 GPUs), forgetting that data_parallel_size multiplies the constraint, or changing GPU count without updating parallel degrees in config files.
Related errors
- Invalid {tp_size=}. Expected tp_size >= 1.
- The size of ({name}) is ({self.name_to_size[name]}), but you
- --enable-strict-thinking requires a grammar backend that sup
- Invalid grammar backend: {name}
- launch_local_runtime requires --dp-size 1; got dp_size={get_
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/798e1b5d3c8bc5d4.
Report an issue: GitHub.