KEMBAR78
Let `tensor_a.new_tensor()` be on `tensor_a.device` by default by oraluben · Pull Request #144958 · pytorch/pytorch · GitHub
Skip to content

Conversation

oraluben
Copy link
Contributor

@oraluben oraluben commented Jan 16, 2025

Fixes #144957
Closes #73838 cc @albanD @ezyang

Currently, tensor_a.new_tensor() will return a on-cpu tensor no matter where is tensor_a. This differs from the document and is a side-effect of #41984.

See #144957 how current logic breaks dynamo.

This PR restore the documented behavior and add tests for new_tensor.

@pytorch-bot
Copy link

pytorch-bot bot commented Jan 16, 2025

🔗 Helpful Links

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

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

✅ You can merge normally! (2 Unrelated Failures)

As of commit 8868a78 with merge base d2a77f4 (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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

@oraluben
Copy link
Contributor Author

@pytorchbot label "topic: bc breaking"

@pytorch-bot pytorch-bot bot added the topic: bc breaking topic category label Jan 16, 2025
@oraluben oraluben force-pushed the tensor-new_tensor-device branch from 00bcb32 to 101652b Compare January 16, 2025 10:47
@mikaylagawarecki mikaylagawarecki added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jan 22, 2025
Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

Nice catch

@ezyang
Copy link
Contributor

ezyang commented Jan 24, 2025

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jan 24, 2025
@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 24, 2025 17:27 Inactive
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 24, 2025 17:27 Inactive
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 24, 2025 17:27 Inactive
@ezyang ezyang added the module: python frontend For issues relating to PyTorch's Python frontend label Jan 24, 2025
@ezyang
Copy link
Contributor

ezyang commented Jan 24, 2025

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

@ezyang ezyang added the release notes: python_frontend python frontend release notes category label Jan 24, 2025
@ezyang
Copy link
Contributor

ezyang commented Jan 24, 2025

@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

@oraluben oraluben deleted the tensor-new_tensor-device branch January 25, 2025 09:33
nWEIdia pushed a commit to nWEIdia/pytorch that referenced this pull request Jan 27, 2025
…ch#144958)

Fixes pytorch#144957
Closes pytorch#73838 cc @albanD @ezyang

Currently, `tensor_a.new_tensor()` will return a on-cpu tensor no matter where is `tensor_a`. This differs from the document and is a side-effect of pytorch#41984.

See pytorch#144957 how current logic breaks dynamo.

This PR restore the documented behavior and add tests for `new_tensor`.

Pull Request resolved: pytorch#144958
Approved by: https://github.com/ezyang
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 module: python frontend For issues relating to PyTorch's Python frontend open source release notes: python_frontend python frontend release notes category topic: bc breaking topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

5 participants