Skip to content

Conversation

@Gasoonjia
Copy link
Contributor

Summary:

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

gasoonjia and others added 2 commits October 7, 2025 21:39
Summary:
### 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
@pytorch-bot
Copy link

pytorch-bot bot commented Oct 8, 2025

🔗 Helpful Links

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

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:

⏳ No Failures, 113 Pending

As of commit 681c859 with merge base bba9d26 (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
@github-actions
Copy link

github-actions bot commented Oct 8, 2025

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

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

@Gasoonjia Gasoonjia closed this Oct 8, 2025
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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant