Repository navigation
[distributed] Raise ValueError for invalid parallelism degrees - #5014
Merged
tianyu-l merged 2 commits intoOct 2, 2026
Merged
Conversation
YeonwooSung
requested review from
fegin,
tianyu-l,
wconstab and
wwwjn
as code owners
October 2, 2026 02:52
|
|
tianyu-l
approved these changes
Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ParallelismContext._validateusedassertto reject a bad parallelism recipe. That is the wrong tool for user-facing config:python -O(and-OO) stripsassert. A zero degree then hitsZeroDivisionErrorwhile auto-fillingdp_shard=-1, or the product check disappears anddp_shardis left truncated so it no longer multiplies out toworld_size.ValueErrorwhenepdoes not dividedp_shard * cp * tp. Degree checks should fail the same way.Those degree checks now raise
ValueErrorwith the same rules:dp_replicate,cp,tp,pp, andepmust be>= 1.dp_shardmust be-1or>= 1.dp_shard=-1still auto-fills asworld_size // (dp_replicate * cp * tp * pp), and the filled value must be>= 1.dp_replicate * dp_shard * cp * tp * ppmust equalworld_size.Mesh construction, the expert-parallel rule, and the world-size formula are unchanged. Expert parallel is not a factor of
world_size.Test plan
python -m pytest tests/unit_tests/cpu/test_parallelism_context.py -q --tb=linetest_validation_invalid_world_size,test_validation_zero_parallelism, andtest_validation_invalid_dp_shardexpectValueErrorand the message names the bad condition (world size mismatch, degree>= 1,dp_shard).test_auto_calculate_dp_shardstill acceptsdp_shard=-1.CI has not been run for this branch.