-
Notifications
You must be signed in to change notification settings - Fork 794
[slimtensor] Add CUDA Storage with DeviceTraits and memory allocation #16438
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
base: gh/gasoonjia/80/base
Are you sure you want to change the base?
Conversation
This diff adds CUDA storage infrastructure to SlimTensor, enabling GPU memory allocation and management.
**Key changes:**
1. **`cuda/Guard.h`** - CUDAGuard RAII class:
- Saves current CUDA device on construction, restores on destruction
- Exception-safe device context switching
- Constructors accept device index or Device object
2. **`core/Storage.h`** - Extended for CUDA support:
- Added `DeviceTraits<DeviceType::CUDA>` specialization with:
- `allocate()` - Uses cudaMalloc with CUDAGuard for device selection
- `free()` - Uses cudaFree with warning on error
- `memcpy()` - Supports Host↔Device and Device↔Device copies
- Added `DEFAULT_CUDA_DEVICE` constant
- Updated `MaybeOwningStorage` constructor to handle CUDA devices
- Stub implementation when `CUDA_AVAILABLE` is not defined (throws error)
Differential Revision: [D89826553](https://our.internmc.facebook.com/intern/diff/D89826553/)
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/16438
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 3 New Failures, 1 Unrelated FailureAs of commit d7c581e with merge base fd6fa87 ( 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. |
This PR needs a
|
Stack from ghstack (oldest at bottom):
This diff adds CUDA storage infrastructure to SlimTensor, enabling GPU memory allocation and management.
Key changes:
cuda/Guard.h- CUDAGuard RAII class:core/Storage.h- Extended for CUDA support:DeviceTraits<DeviceType::CUDA>specialization with:allocate()- Uses cudaMalloc with CUDAGuard for device selectionfree()- Uses cudaFree with warning on errormemcpy()- Supports Host↔Device and Device↔Device copiesDEFAULT_CUDA_DEVICEconstantMaybeOwningStorageconstructor to handle CUDA devicesCUDA_AVAILABLEis not defined (throws error)Differential Revision: D89826553