pytorch/torch/csrc/cuda/GreenContext.cpp
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

14 lines
533 B
C++

#include <ATen/cuda/CUDAGreenContext.h>
#include <torch/csrc/jit/python/pybind_utils.h>
#include <torch/csrc/utils/pybind.h>
// Cargo culted partially from csrc/cuda/Stream.cpp
void THCPGreenContext_init(PyObject* module) {
auto m = py::handle(module).cast<py::module>();
py::class_<at::cuda::GreenContext>(m, "_CUDAGreenContext")
.def_static("create", &::at::cuda::GreenContext::create)
.def("set_context", &::at::cuda::GreenContext::setContext)
.def("pop_context", &::at::cuda::GreenContext::popContext);
}