8000 Enable lazy cloning in `Tensor.to` between CPU and MPS by kurtamohler · Pull Request #150569 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

Enable lazy cloning in Tensor.to between CPU and MPS #150569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 37 commits into
base: gh/kurtamohler/33/base
Choose a base branch
from

Conversation

kurtamohler
Copy link
Collaborator
@kurtamohler kurtamohler commented Apr 2, 2025

[ghstack-poisoned]
Copy link
pytorch-bot bot commented Apr 2, 2025

🔗 Helpful Links

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

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

❌ 5 New Failures, 1 Unrelated Failure

As of commit 8fd51f9 with merge base 56e1c23 (image):

NEW FAILURES - The following jobs have failed:

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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

kurtamohler added a commit that referenced this pull request Apr 2, 2025
ghstack-source-id: c92ef74
Pull Request resolved: #150569
@kurtamohler kurtamohler added release notes: lazy release notes category release notes: mps Release notes category and removed open source labels Apr 2, 2025
@kurtamohler
Copy link
Collaborator Author

Because of what I mentioned here, right now there is no guarantee that a COW MPS tensor will materialize when it should. I've found some places in the codebase where MPS ops cast the const data pointer to non-const and then mutate the data (for instance, any op that calls getMTLBufferStorage and then writes to the buffer). Those ops will incorrectly write to the underlying data of a COW tensor without materializing. So I think it would be best not to merge this PR until we fix the data pointer const-correctness in the MPS ops.

@kurtamohler kurtamohler marked this pull request as draft April 2, 2025 21:00
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request Apr 3, 2025
ghstack-source-id: ac5309c
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit to kurtamohler/pytorch that referenced this pull request Apr 3, 2025
kurtamohler added a commit that referenced this pull request Apr 3, 2025
ghstack-source-id: 057856d
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request Apr 4, 2025
ghstack-source-id: 902ece7
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit to kurtamohler/pytorch that referenced this pull request Apr 4, 2025
kurtamohler added a commit that referenced this pull request Apr 4, 2025
ghstack-source-id: 3cd33fa
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit to kurtamohler/pytorch that referenced this pull request Apr 4, 2025
kurtamohler added a commit that referenced this pull request Apr 4, 2025
ghstack-source-id: 6f363f6
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit to kurtamohler/pytorch that referenced this pull request Apr 4, 2025
kurtamohler added a commit that referenced this pull request Apr 4, 2025
ghstack-source-id: 20c5f02
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request Apr 4, 2025
ghstack-source-id: 83cfe9e
Pull Request resolved: #150569
kurtamohler added a commit that referenced this pull request Apr 29, 2025
ghstack-source-id: 6cccde2
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request Apr 29, 2025
ghstack-source-id: fa61099
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request Apr 30, 2025
ghstack-source-id: 65a4c5f
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request Apr 30, 2025
ghstack-source-id: ba67420
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request Apr 30, 2025
ghstack-source-id: e508c76
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request Apr 30, 2025
ghstack-source-id: 6c1a950
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request May 1, 2025
ghstack-source-id: f382e2f
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request May 1, 2025
ghstack-source-id: b2facee
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request May 1, 2025
ghstack-source-id: a6c604a
Pull Request resolved: #150569
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request May 1, 2025
ghstack-source-id: e5f0395
Pull Request resolved: #150569
@cyyever
Copy link
Collaborator
cyyever commented May 1, 2025

Is it possible to extend the support to other kinds of devices?

[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request May 1, 2025
ghstack-source-id: 0dd5075
Pull Request resolved: #150569
@kurtamohler
Copy link
Collaborator Author

Is it possible to extend the support to other kinds of devices?

In general probably not, but the answer depends on the platform. The reason this can work for CPU-MPS is that M-series Macs have a shared memory space that both the cpu and gpu can access

[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request May 2, 2025
ghstack-source-id: 738d0b6
Pull Request resolved: #150569
kurtamohler added a commit to kurtamohler/pytorch that referenced this pull request May 13, 2025
kurtamohler added a commit to kurtamohler/pytorch that referenced this pull request May 14, 2025
kurtamohler added a commit to kurtamohler/pytorch that referenced this pull request May 16, 2025
[ghstack-poisoned]
kurtamohler 7A47 added a commit that referenced this pull request May 16, 2025
ghstack-source-id: 79b47df
Pull Request resolved: #150569
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/mps Run MPS tests (subset of trunk) open source release notes: lazy release notes category release notes: mps Release notes category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0