Fix shape metadata when copying tensors across devices - #4245
Open
MrCapricornLiu wants to merge 1 commit into
Open
Fix shape metadata when copying tensors across devices#4245MrCapricornLiu wants to merge 1 commit into
MrCapricornLiu wants to merge 1 commit into
Conversation
Signed-off-by: Chenghao Liu <chliu@stu.pku.edu.cn>
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.
copy_tensor_to_devices, used by pipeline inference withgather_output=True, reduces a shape buffer whose unused entries and non-source ranks are uninitialized. Those values can become dimensions or an invalid dtype. Filtering metadata withnonzero()also loses zero-sized axes, and the receiver passes a tensor wheretorch.zerosexpects a size tuple.Initialize the metadata buffer to zero, prefix the dimensions with their count and dtype, and construct receiver tensors from the decoded size tuple. The existing collective and dtype mapping are retained.
Tests cover deterministic uninitialized-memory filling, scalars, empty dimensions, three dtypes, and either the first or last rank as source. All 12 metadata subcases fail on the original code and pass with the fix; the utilities module reports 46 passed and 5 skipped. The distributed operations script passes on eight H800 GPUs, and an eight-stage
prepare_pippy(gather_output=True)model matches the unpartitioned reference on every rank. Ruff lint/format and pre-commit pass. XLA and multi-node inference were not tested.