Skip to content
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

[QST] How to import C++ CUTLASS for pybind? #1844

Closed
haeunlee99 opened this issue Sep 28, 2024 · 2 comments
Closed

[QST] How to import C++ CUTLASS for pybind? #1844

haeunlee99 opened this issue Sep 28, 2024 · 2 comments

Comments

@haeunlee99
Copy link

haeunlee99 commented Sep 28, 2024

I want to use CUTLASS functions with pytorch tensors in python. I have before used pybind to compile CUDA programs that can be called from python. However, it seems like CUTLASS requires CMake for compilation and import (https://github.com/NVIDIA/cutlass/tree/main/examples/60_cutlass_import). I barely know CMake. Is using CMake as in the example and using CMakeExtension for setup.py (https://github.com/pybind/cmake_example/blob/master/setup.py) the only way or is there something I am missing?

I have added "--gpu-architecture=sm_90a" as nvcc flag to compile pybind just as before (by directly including source code as header file) but saw severe degration in performance. (85 TFLOPS with half precision matmul in hopper GPU.) Can wrong compilation degrade performance as well?

from setuptools import setup
from torch.utils import cpp_extension

extra_compile_args = {
"nvcc": [
"--gpu-architecture=sm_90a",
],
}

setup(
name="test_ext",
ext_modules=[
cpp_extension.CUDAExtension(
name="test_ext",
sources=["test.cu"],
extra_compile_args=extra_compile_args
)
],
cmdclass={"build_ext": cpp_extension.BuildExtension},
)

Thanks!

@jackkosaian
Copy link
Contributor

Try taking a look at the Python example 02_pytorch_extension_grouped_gemm. It emits a setup.py file that can be used with PyTorch. You can follow the example in that file.

@haeunlee99
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants