Skip to content

[ET Device Support] DeviceMemoryBuffer RAII class for device memory lifetime management#19567

Merged
Gasoonjia merged 2 commits into
mainfrom
gh/gasoonjia/153/orig
May 13, 2026
Merged

[ET Device Support] DeviceMemoryBuffer RAII class for device memory lifetime management#19567
Gasoonjia merged 2 commits into
mainfrom
gh/gasoonjia/153/orig

Conversation

@pytorchbot
Copy link
Copy Markdown
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #18473 by @Gasoonjia
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/153/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/153/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/152/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/153/orig
Differential Revision: D97850709
@diff-train-skip-merge

Gasoonjia added 2 commits May 13, 2026 10:12
…meta

Pull Request resolved: #18472

Enable serialzing non_const_buffer_device into into PTE file.
ghstack-source-id: 381499179
@exported-using-ghexport

Differential Revision: [D97850707](https://our.internmc.facebook.com/intern/diff/D97850707/)
…ifetime management

Pull Request resolved: #18473

Introduces DeviceMemoryBuffer, an RAII wrapper that owns a single device
memory allocation. On destruction, it automatically calls
DeviceAllocator::deallocate() to free the memory. This mirrors the role of
std::vector<uint8_t> for CPU planned buffers, but for non-cpu device memory (CUDA, etc.).

Key features:
- Static factory create(size, type, index) looks up DeviceAllocator from registry
- Move-only semantics (no copy) to enforce single ownership
- as_span() accessor wraps device pointer for use with HierarchicalAllocator
- Destructor is no-op for default-constructed or moved-from instances
ghstack-source-id: 381499182
@exported-using-ghexport

Differential Revision: [D97850709](https://our.internmc.facebook.com/intern/diff/D97850709/)
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 13, 2026

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 New Failure, 1 Pending

As of commit 7db40dd with merge base 1992bdd (image):

NEW FAILURE - The following job has failed:

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 May 13, 2026
Base automatically changed from gh/gasoonjia/152/orig to main May 13, 2026 22:32
@Gasoonjia Gasoonjia requested a review from larryliu0820 as a code owner May 13, 2026 22:32
@Gasoonjia Gasoonjia merged commit a9969eb into main May 13, 2026
173 of 175 checks passed
@Gasoonjia Gasoonjia deleted the gh/gasoonjia/153/orig branch May 13, 2026 22:34
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants