Fix TP warnings: torch 2.13 collective renames + init_process_group device_id - #197
Open
vasilevklart wants to merge 1 commit into
Open
Fix TP warnings: torch 2.13 collective renames + init_process_group device_id#197vasilevklart wants to merge 1 commit into
vasilevklart wants to merge 1 commit into
Conversation
torch 2.13 deprecated all_gather_into_tensor / reduce_scatter_tensor in favor of all_gather_single / reduce_scatter_single; resolve the names once at module level with a getattr fallback so the torch>=2.9.1 floor keeps working. Also pass device_id to init_process_group so barrier() no longer warns about guessing the device. Closes mstar-project#166
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.
Closes #166.
What
Two warning sources in
mstar/distributed/communication.pyon every TP/SP run:all_gather_into_tensor→all_gather_single— and the old name emits aFutureWarningon each call. The same rename batch also hitreduce_scatter_tensor→reduce_scatter_single(used byCommGroup.reduce_scatter), which Minor: Warnings related to TP #166 doesn't mention, so this PR covers both.init_process_groupwas called withoutdevice_id, so everybarrier()warns that it has to guess the device from the current context.How
getattr(dist, "<new name>", <old name>)—pyproject.tomlallows torch back to 2.9.1, where the new names don't exist. The new APIs are exact signature drop-ins for the old ones.device_id=torch.device("cuda", self.global_rank)toinit_process_group— the same rank→device mappinginit_distalready applies viatorch.cuda.set_device. Side effect worth noting: NCCL now sets up communicators eagerly at startup instead of lazily at the first collective.Testing
The renames are validated by driving the real
CommGroupmethods on a 2-rank CPUgloogroup (torch 2.13.0):CommGroup.all_gather/reduce_scatteremit both FutureWarnings; after, they are silent.torch.equal) between the deprecated and replacement APIs on both ranks, for both collectives.getattrfallback engages (deprecation warnings reappear, as expected on old torch) and results stay correct.ruff check .passes.No CUDA machine was available for this change, so the
device_id/barrier half is verified by inspection only (the ordinal matches the existingset_devicecall); a smoke run on a GPU box with TP ≥ 2 would be a welcome double-check.