Skip to content

Conversation

pytorchbot
Copy link
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #14901 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/46/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/46/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/45/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/46/orig
Differential Revision: D84126481
@diff-train-skip-merge

This diff moves the `cuda/runtime/shim` directory to `cuda/runtime` to make the utility functions sharable among all runtime infrastructure.

Differential Revision: [D84169267](https://our.internmc.facebook.com/intern/diff/D84169267/)

ghstack-source-id: 314867735
Pull Request resolved: #14900
### Introduce CudaGuard and CudaStreamGuard

This diff introduces `CudaGuard` and `CudaStreamGuard` in the Executorch CUDA runtime. These classes provide a convenient way to manage CUDA device and stream selection.

#### Changes

*   Added `CudaGuard` and `CudaStreamGuard` classes in `fbcode/executorch/backends/cuda/runtime/guard.h`.
*   Implemented `CudaGuard` and `CudaStreamGuard` in `fbcode/executorch/backends/cuda/runtime/guard.cpp`.
*   Added unit tests for `CudaStreamGuard` in `fbcode/executorch/backends/cuda/runtime/tests/test_cuda_stream_guard.cpp`.
*   Updated `TARGETS` file to include the new files.

#### Purpose

The `CudaGuard` class provides a way to select a CUDA device and ensure that it is properly released when the guard goes out of scope. The `CudaStreamGuard` class provides a way to select a CUDA stream and ensure that it is properly synchronized when the guard goes out of scope.


#### Usage
They will be further used and controled by their shim layer functions.

Differential Revision: [D84126481](https://our.internmc.facebook.com/intern/diff/D84126481/)

ghstack-source-id: 314867936
Pull Request resolved: #14901
Copy link

pytorch-bot bot commented Oct 8, 2025

🔗 Helpful Links

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

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

⏳ No Failures, 119 Pending

As of commit 0a7ac54 with merge base fb87fa6 (image):
💚 Looks good so far! There are no failures yet. 💚

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 8, 2025
Base automatically changed from gh/gasoonjia/45/orig to main October 8, 2025 20:26
@Gasoonjia Gasoonjia merged commit 0142a1a into main Oct 8, 2025
128 of 131 checks passed
@Gasoonjia Gasoonjia deleted the gh/gasoonjia/46/orig branch October 8, 2025 20:26
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