pytorch/c10/cuda
Eddie Yan e64a814ae7 [CUDA] Add experimental green context support for SM carveout (#159104)
Low-level PyTorch APIs should be usable/stable enough at this point but we might move the underlying driver API usage a bit from here...

Built on top of @drisspg 's branch

Pull Request resolved: https://github.com/pytorch/pytorch/pull/159104
Approved by: https://github.com/ngimel, https://github.com/malfet, https://github.com/kwen2501

Co-authored-by: drisspg <drisspguessous@gmail.com>
Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
2025-10-22 21:38:52 +00:00
..
impl Improve error message for CUDAGuardImpl, MPSGuardImpl, XPUGuardImpl (#149838) 2025-03-25 07:29:53 +00:00
test [ROCm][Windows] Fix offload gpu arch list in tests (#155212) 2025-06-05 20:30:28 +00:00
BUILD.bazel
build.bzl Support expandable_segments:True in fbcode for caching allocator 2023-05-02 11:12:39 -07:00
CMakeLists.txt Use torch_compile_options for c10 libraries (#147821) 2025-03-18 01:54:23 +00:00
CUDAAlgorithm.h [c10] Use nested namespace in c10/cuda (#116464) 2023-12-27 23:14:00 +00:00
CUDAAllocatorConfig.cpp Refine Allocator Config error message friendly (#165288) 2025-10-19 15:34:17 +00:00
CUDAAllocatorConfig.h Deprecate overlapped functions in CUDAAllocatorConfig (#165289) 2025-10-19 15:34:26 +00:00
CUDACachingAllocator.cpp [ROCm] fix test_allocator_backend (#166035) 2025-10-22 03:46:23 +00:00
CUDACachingAllocator.h [Mem Snapshot] Add Metadata Field (#165490) 2025-10-17 23:46:02 +00:00
CUDADeviceAssertion.h Suppress -Wunused-function for DSA (#150735) 2025-04-07 01:47:35 +00:00
CUDADeviceAssertionHost.cpp [1/N] Remove unused header inclusion (#165763) 2025-10-18 05:23:11 +00:00
CUDADeviceAssertionHost.h [BE] fix typos in c10/ (#156078) 2025-06-18 10:24:44 +00:00
CUDAException.cpp [BE] Preserve caller source location in the error message (#162808) 2025-09-15 13:29:43 +00:00
CUDAException.h [BE] Preserve caller source location in the error message (#162808) 2025-09-15 13:29:43 +00:00
CUDAFunctions.cpp [BE] Fix '_WIN32' is not defined warning (#162516) 2025-09-10 04:21:38 +00:00
CUDAFunctions.h check if USE_ROCM is defined (#158571) 2025-07-17 19:48:26 +00:00
CUDAGraphsC10Utils.h Add DeviceAllocator as the base device allocator (#138222) 2025-08-08 17:41:10 +00:00
CUDAGuard.h Enable more readability-redundant checks (#143963) 2024-12-30 14:49:33 +00:00
CUDAMacros.h Revert "Increase C10_COMPILE_TIME_MAX_GPUS to 128 (#144138)" 2025-01-14 19:04:12 +00:00
CUDAMallocAsyncAllocator.cpp [ROCm] fix test_allocator_backend (#166035) 2025-10-22 03:46:23 +00:00
CUDAMathCompat.h [Reland] [5/N] Change static functions in headers to inline (#131010) 2024-07-18 15:53:48 +00:00
CUDAMiscFunctions.cpp [1/N] Remove unused header inclusion (#165763) 2025-10-18 05:23:11 +00:00
CUDAMiscFunctions.h Mark unused parameters in C++ code (#164912) 2025-10-09 06:23:25 +00:00
CUDAStream.cpp [1/N] Change C-style casts to static_cast or reinterpret_cast (#165750) 2025-10-20 23:27:13 +00:00
CUDAStream.h Mark unused parameters in C++ code (#164912) 2025-10-09 06:23:25 +00:00
driver_api.cpp [1/N] Remove unused header inclusion (#165763) 2025-10-18 05:23:11 +00:00
driver_api.h [CUDA] Add experimental green context support for SM carveout (#159104) 2025-10-22 21:38:52 +00:00
README.md

c10/cuda is a core library with CUDA functionality. It is distinguished from c10 in that it links against the CUDA library, but like c10 it doesn't contain any kernels, and consists solely of core functionality that is generally useful when writing CUDA code; for example, C++ wrappers for the CUDA C API.

Important notes for developers. If you want to add files or functionality to this folder, TAKE NOTE. The code in this folder is very special, because on our AMD GPU build, we transpile it into c10/hip to provide a ROCm environment. Thus, if you write:

// c10/cuda/CUDAFoo.h
namespace c10 { namespace cuda {

void my_func();

}}

this will get transpiled into:

// c10/hip/HIPFoo.h
namespace c10 { namespace hip {

void my_func();

}}

Thus, if you add new functionality to c10, you must also update C10_MAPPINGS torch/utils/hipify/cuda_to_hip_mappings.py to transpile occurrences of cuda::my_func to hip::my_func. (At the moment, we do NOT have a catch all cuda:: to hip:: namespace conversion, as not all cuda namespaces are converted to hip::, even though c10's are.)

Transpilation inside this folder is controlled by CAFFE2_SPECIFIC_MAPPINGS (oddly enough.) C10_MAPPINGS apply to ALL source files.

If you add a new directory to this folder, you MUST update both c10/cuda/CMakeLists.txt and c10/hip/CMakeLists.txt