[zero] Run ZeRO-3's rank-agreement checks and barriers over the partition group #9076
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #9076"
general
weight: 0.35
LiRunGuo
ZeRO-3's rank-agreement checks and init barriers ran over the world. They now run over the parameters' partition group, so a ZeRO-3 engine can train on a subset of the ranks while the other ranks hold no engine. With the default group the same ranks take part as before.
This is the first commit of #9074, sent on its own because it does not depend on RFC #9026 and is small (52 lines added and 19 removed in
deepspeed/, 21 of the added lines from the third commit, which answers the review), plus a regression test as a second commit (85 lines intests/unit/v1/zero/test_zero.py).What breaks on master. Give
deepspeed.initializeanmpuwhose data-parallel group is a subset of the world, for example ranks 1-2 of three, and leave rank 0 without an engine (a trainer next to inference-only ranks, or two trainer layouts in the same processes):DeepSpeedZeroOptimizer_Stage3._setup_for_real_optimizercallsdist.barrier()over the world, twice, and_create_fp16_partitions_with_defragmentationonce more. The trainer ranks wait for rank 0, which never calls it.assert_ints_same_as_other_ranksbroadcasts from global rank 0 over the world (assert_lst_len_same_as_other_ranks,get_lst_from_rank0). It is called when a trace is recorded (PartitionedParameterCoordinator), in the coalesced all-gather (Init._all_gather) and, withenable_sanity_checks, in the gradient reduction. Rank 0 is outside the group and never sends.Root cause. These calls predate engines over a subgroup: the data path of ZeRO-3 already uses the partition group (
all_gather,reduce_scatterand the parameter broadcasts all pass it), and only the checks and barriers around it still assumed the world.The change
zero/utils.py:assert_ints_same_as_other_ranks,assert_lst_len_same_as_other_ranksandget_lst_from_rank0take an optionalgroupand broadcast from the group's first rank.group=Noneis the old behaviour, so other callers are unaffected.stage3.py: the three barriers passself.dp_process_group; the gradient bucket's sanity check passes the bucket's partition group, the group that reduces it (third commit, from the review).partition_parameters.py: the two checks in_all_gatherpass the parameters'ds_process_group.partitioned_param_coordinator.py: takesprocess_group(defaultNone) and passes it to its three trace checks.parameter_offload.pyhands it the parameters' partition group when they all share one, andNone(the world, as before) otherwise or when that group is the world. Not the optimizer'sdp_process_group: a model partitioned byzero.Initbefore AutoTP keeps the world as its partition group while the optimizer works over a smaller one, and the check has to cover the ranks of the all-gathers (third commit, from the review).Validation
One node with 4× RTX 3090 (24 GB), driver 595.58.03, torch 2.13.0+cu130, NCCL 2.29.7.
Regression test
TestZero3OverSubgroup(intests/unit/v1/zero/test_zero.py): a world of three, ZeRO-3 over ranks 1-2 through anmpu, rank 0 without an engine. Three SGD steps are compared with plain torch SGD on the same model and batch. SGD withgradient_clippingset to 0, so that the comparison sees the scale of the averaged gradient (an engine clips to norm 1.0 by default, and Adam hides a constant scale).| Tree | Tests (
python -m pytest -q -rfEs, fromtests/) | Result || --- | --- | --- |
| master + the test commit |
unit/v1/zero/test_zero.py::TestZero3OverSubgroup| does not finish; killed after 5 minutes || this PR, GPU (NCCL) | same | 1 passed in 9.4 s |
| this PR, CPU (gloo,
DS_ACCELERATOR=cpu) | same | 1 passed in 30 s || this PR, GPU |
unit/v1/zero/test_zero.py,unit/v1/zero/test_zero_init_pg_contradiction.py,unit/runtime/zero/test_zero_context.py| 137 passed, 1 skipped (marked "not working" on master) |I did not look at where the run on master blocks; the first world barrier in
_setup_for_real_optimizeris the first call rank 0 never answers.The third commit (the two review findings), on one node with 4× H100 (94 GB), driver 580.105.08, torch 2.13.0+cu130, NCCL 2.29.7:
| Tree | Tests | Result |
| --- | --- | --- |
| this PR, GPU (NCCL) |
unit/v1/zero/test_zero.py::TestZero3OverSubgroup| 1 passed || this PR, CPU (gloo,
DS_ACCELERATOR=cpu) | same | 1 passed || this PR, GPU |
unit/v1/zero/test_zero.py,unit/v1/zero/test_zero_init_pg_contradiction.py,unit/runtime/zero/test_zero_context.py| 137 passed, 1 skipped || this PR, GPU |
unit/checkpoint/test_zero_affine.py(withTestAutoTPStorageMaps: TP2 × DP2, includingzero.Initbefore AutoTP),unit/v1/moe/test_moe.py(expert and dense parameters in different partition groups) | 70 passed || the first two commits, GPU | same | 70 passed |
Compatibility
dp_process_groupholds every rank, so the same ranks take part in every barrier and check as before. The ZeRO test files above run at the default group.enable_sanity_checks, several nodes.save_checkpointand_commit_decoupled_checkpointinengine.pystill calldist.barrier()over the world, so a subgroup engine cannot save a checkpoint while the other ranks stay out. That is a separate change.AI assistance: AI assistance was used. The code, the test and this description were drafted with an AI coding agent (Claude Code). The submitter reviewed every changed line and ran the tests above.
cc @Achyuthan-S @jinyouzhi