KEMBAR78
[dtensor] full_tensor to return synchronously by wanchaol · Pull Request #113322 · pytorch/pytorch · GitHub
Skip to content

Conversation

@wanchaol
Copy link
Collaborator

@wanchaol wanchaol commented Nov 9, 2023

Stack from ghstack (oldest at bottom):

full_tensor API should return synchronously instead of
AsyncCollectiveTensor and if the return is that, we do the wait
directly, this makes the full_tensor API be more percise

full_tensor API should return synchronously instead of
AsyncCollectiveTensor and if the return is that, we do the wait
directly, this makes the full_tensor API be more percise

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 9, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/113322

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit e098488 with merge base 84d64d7 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@wanchaol wanchaol added ciflow/trunk Trigger trunk jobs on your pull request release notes: distributed (dtensor) release notes category labels Nov 9, 2023
@wanchaol wanchaol requested a review from wconstab November 9, 2023 00:58
full_tensor API should return synchronously instead of
AsyncCollectiveTensor and if the return is that, we do the wait
directly, this makes the full_tensor API be more percise

[ghstack-poisoned]
Copy link
Contributor

@wz337 wz337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@wanchaol
Copy link
Collaborator Author

wanchaol commented Nov 9, 2023

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@facebook-github-bot facebook-github-bot deleted the gh/wanchaol/388/head branch November 13, 2023 15:25
Skylion007 pushed a commit to Skylion007/pytorch that referenced this pull request Nov 14, 2023
full_tensor API should return synchronously instead of
AsyncCollectiveTensor and if the return is that, we do the wait
directly, this makes the full_tensor API be more percise
Pull Request resolved: pytorch#113322
Approved by: https://github.com/wz337
Comment on lines +63 to +75
def forward( # type: ignore[override]
ctx,
input: "DTensor",
grad_placements: Optional[Sequence[Placement]],
async_output: bool,
):
ctx.dtensor_spec = input._spec
ctx.grad_placements = grad_placements
local_tensor = input._local_tensor
if not async_output and isinstance(local_tensor, funcol.AsyncCollectiveTensor):
# synchronously wait for any pending collectives to get the result tensor
local_tensor = local_tensor.trigger_wait()
local_tensor = local_tensor.elem # type: ignore[attr-defined]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion on this, but this might bring some perf regression because for every .to_local we are waiting. But if we think this is the defined or expected behavior, then that's fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: distributed (dtensor) release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants