-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Warn when zero.Init silently falls back to a single rank (#8084) #8089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
akshansh47
wants to merge
3
commits into
deepspeedai:master
Choose a base branch
from
akshansh47:fix/zero-init-unsharded-single-rank-warning
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+81
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
642a9d2
Warn when zero.Init silently falls back to a single rank (#8084)
akshansh47 7abdeb9
Escalate zero.Init single-rank PG contradiction from warning to error
akshansh47 3ee55b0
Merge branch 'master' into fix/zero-init-unsharded-single-rank-warning
sfc-gh-truwase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
tests/unit/runtime/zero/test_zero_init_pg_contradiction.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # DeepSpeed Team | ||
|
|
||
| # Regression coverage for #8084: zero.Init silently falls back to a single-rank (unsharded) group when a size-1 | ||
| # process group exists at zero.Init time under a multi-process launcher (e.g. `from_pretrained` before | ||
| # `deepspeed.init_distributed()`), so every rank allocates the full model and OOMs. ZeRO-3 cannot work correctly with | ||
| # a process group that contradicts the launcher world, so the detection helper must produce an error message only | ||
| # when the launcher reports a multi-process world but the resolved group collapsed to one rank. | ||
|
|
||
| import pytest | ||
|
|
||
| from deepspeed.runtime.zero.partition_parameters import _contradicting_single_rank_pg_error | ||
|
|
||
|
|
||
| def test_errors_when_launcher_multiprocess_but_group_is_single_rank(): | ||
| msg = _contradicting_single_rank_pg_error(dp_world_size=1, data_parallel_group=None, env={"WORLD_SIZE": "8"}) | ||
| assert msg is not None | ||
| assert "WORLD_SIZE=8" in msg | ||
| assert "init_distributed" in msg | ||
|
|
||
|
|
||
| def test_no_error_for_genuine_single_process(): | ||
| assert _contradicting_single_rank_pg_error(dp_world_size=1, data_parallel_group=None, | ||
| env={"WORLD_SIZE": "1"}) is None | ||
| assert _contradicting_single_rank_pg_error(dp_world_size=1, data_parallel_group=None, env={}) is None | ||
|
|
||
|
|
||
| def test_no_error_when_group_actually_shards(): | ||
| assert _contradicting_single_rank_pg_error(dp_world_size=8, data_parallel_group=None, | ||
| env={"WORLD_SIZE": "8"}) is None | ||
|
|
||
|
|
||
| def test_no_error_when_explicit_dp_group_supplied(): | ||
| # An explicitly provided size-1 data_parallel_group is treated as intentional. | ||
| sentinel_group = object() | ||
| assert _contradicting_single_rank_pg_error(dp_world_size=1, data_parallel_group=sentinel_group, | ||
| env={"WORLD_SIZE": "8"}) is None | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("bad", ["", "not-an-int", None]) | ||
| def test_malformed_world_size_does_not_raise(bad): | ||
| assert _contradicting_single_rank_pg_error(dp_world_size=1, data_parallel_group=None, | ||
| env={"WORLD_SIZE": bad}) is None | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this UT to
tests/unit/v1/zero/