Repository navigation
AutoTP: send CPU copies in the first-batch consistency check - #8845
Draft
pengdurice wants to merge 1 commit into
Draft
pengdurice wants to merge 1 commit into
pengdurice wants to merge 1 commit into
Conversation
Signed-off-by: pengdurice <pengduhit@gmail.com>
This branch has not been deployed
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.
AutoTP: send CPU copies in the first-batch consistency check
Summary
With AutoTP, the engine checks the first batch: tensor-parallel rank 0 sends its inputs to the other ranks of its TP
group with
broadcast_object_list(check_dataloader_inputs_same_across_ranksinengine.py), and each peer comparesthem with its own. The inputs are accelerator tensors, so they are pickled with their device. Each peer unpickles
them onto rank 0's device and opens a context there, which stays for the life of the process.
On MiniMax-M3 with AutoTP 4 on 4 nodes, every TP rank 0 GPU showed 3 other processes holding 524 MiB each:
1.5 GiB of that GPU lost, and those GPUs were the ones that ran out of memory.
The fix sends CPU copies. The peers' comparison already moves both sides to its own device
(
compare_tensors_in_structures), so the check itself is unchanged.Used in large-scale training
The same change (the same line) was in the DeepSpeed study trees of these MiniMax-M3 runs: all 60 layers (426B) built
from the config (random weights), 4 nodes x 8 H200, AutoTP 4 x AutoEP 8, ZeRO-3, bf16, together with the ZeRO-3
master-copy fix (a separate PR).
Duplicate check
Searched open pull requests on 2026-10-15 ("AutoTP", "dataloader check", "broadcast_object_list", "CUDA context"): none
changes this check.
The change
deepspeed/runtime/engine.py, the source rank's object becomestorch.utils._pytree.tree_map(lambda x: x.cpu() if torch.is_tensor(x) else x, args)(5 lines added, 1 removed,including a 2-line comment).
Tests
TestTpDataloaderCheckSendsCpuCopies(2 ranks, AutoTP 2,tests/unit/v1/autotp/test_autotp_training.py; everyweight left unsharded with
partition_type: "skip", as inTestTpDataloaderCorrectness): wrapsdeepspeed.comm.broadcast_object_listafterdeepspeed.initialize, runs the first forward, and requires every tensorthe source rank sends to be on the CPU; the existing
TestTpDataloaderCorrectnesschecks that inconsistent batchesare still caught.
Hardware: 1 node of 8 H200 (driver 580.126.09), torch 2.8.0+cu126, pytest 9.1.1.
pre-commit run --filespasses on both changed files.Compatibility
.cpu(); not runAI assistance
This change, its test and this description were prepared with AI assistance (Claude).