Skip to content

Conversation

manuelcandales
Copy link
Contributor

@manuelcandales manuelcandales commented Oct 22, 2025

This pull request refactors and improves the memory management and reference counting system for tensors in the Metal backend. The main change is the replacement of the previous ownership tracking (is_tensor_own_memory) with a more robust reference counting map (memory_to_n_tensor), which tracks how many tensors share a memory address and whether the memory is owned or not. Additional improvements include safer tensor deletion, proper Metal buffer deallocation, and consistent handling of tensor views and resource cleanup.

[ghstack-poisoned]
[ghstack-poisoned]
@manuelcandales
Copy link
Contributor Author

manuelcandales commented Oct 22, 2025

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 22, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure, 3 Pending, 2 Unrelated Failures

As of commit 5bd34ee with merge base 5d71c9b (image):

NEW FAILURE - The following job has failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 22, 2025
[ghstack-poisoned]
@manuelcandales manuelcandales added the release notes: none Do not include this in the release notes label Oct 22, 2025
Base automatically changed from gh/manuelcandales/145/head to main October 22, 2025 07:34
@manuelcandales manuelcandales merged commit 81a3acc into main Oct 22, 2025
153 of 158 checks passed
@manuelcandales manuelcandales deleted the gh/manuelcandales/146/head branch October 22, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants