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

[fbgemm_gpu] Fix CMakeLists.txt for experimental/gemm #3592

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cmake/modules/Utilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ endmacro()

function(add_to_package)
set(flags)
set(singleValueArgs DESTINATION)
set(multiValueArgs FILES TARGETS)
set(singleValueArgs
DESTINATION # The destination directory, RELATIVE to the root of the installation package directory
)
set(multiValueArgs
FILES # The list of files to place into the DESTINATION directory
TARGETS # THe list of CMake targets whose build artifacts to place into the DESTINATION directory
)

cmake_parse_arguments(
args
Expand Down
2 changes: 1 addition & 1 deletion fbgemm_gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ endif()
################################################################################

if(NOT FBGEMM_CPU_ONLY AND NOT USE_ROCM)
# TODO: Figure out NCCL/RCCL integration with ROCm
add_subdirectory(experimental/example)
endif()

if(NOT FBGEMM_CPU_ONLY)
# Package Triton GEMM (GenAI) kernels
add_subdirectory(experimental/gemm)
endif()

Expand Down
32 changes: 15 additions & 17 deletions fbgemm_gpu/experimental/example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,33 @@
# Target Sources
################################################################################

set(experimental_example_cpp_source_files
src/cutlass_sgemm_nn.cu
src/example_ops.cpp
src/nccl_example.cpp)
file(GLOB_RECURSE experimental_example_cpp_source_files
src/*.cu
src/*.cpp)

set(experimental_example_python_source_files
example/__init__.py
example/utils.py)
file(GLOB_RECURSE experimental_example_python_source_files
example/*.py)


################################################################################
# Build Shared Library
################################################################################

gpu_cpp_library(
PREFIX
fbgemm_gpu_experimental_example_py
TYPE
SHARED
INCLUDE_DIRS
${fbgemm_sources_include_directories}
GPU_SRCS
${experimental_example_cpp_source_files})
PREFIX
fbgemm_gpu_experimental_example_py
TYPE
SHARED
INCLUDE_DIRS
${fbgemm_sources_include_directories}
GPU_SRCS
${experimental_example_cpp_source_files})


################################################################################
# Install Shared Library and Python Files
################################################################################

add_to_package(DESTINATION fbgemm_gpu/experimental/example
TARGETS fbgemm_gpu_experimental_example_py
FILES ${experimental_example_python_source_files})
TARGETS fbgemm_gpu_experimental_example_py
FILES ${experimental_example_python_source_files})
12 changes: 6 additions & 6 deletions fbgemm_gpu/experimental/gemm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
# Target Sources
################################################################################

set(experimental_triton_python_source_files
triton_gemm/__init__.py
triton_gemm/fp8_gemm.py
triton_gemm/matmul_perf_model.py)
# Python sources
file(GLOB_RECURSE experimental_triton_gemm_python_source_files
triton_gemm/*.py)


################################################################################
# Install Python Files
################################################################################

add_to_package(DESTINATION fbgemm_gpu/experimental/gemm/triton_gemm
FILES ${experimental_triton_python_source_files})
add_to_package(
DESTINATION fbgemm_gpu/experimental/gemm/triton_gemm
FILES ${experimental_triton_gemm_python_source_files})
7 changes: 3 additions & 4 deletions fbgemm_gpu/experimental/gen_ai/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ file(GLOB_RECURSE experimental_gen_ai_cpp_source_files_hip

# Python sources
file(GLOB_RECURSE experimental_gen_ai_python_source_files
RELATIVE gen_ai
*.py)
gen_ai/*.py)


################################################################################
Expand All @@ -52,7 +51,7 @@ file(GLOB_RECURSE experimental_gen_ai_python_source_files

gpu_cpp_library(
PREFIX
fbgemm_gpu_experimental_gen_ai_py
fbgemm_gpu_experimental_gen_ai
TYPE
SHARED
INCLUDE_DIRS
Expand All @@ -72,5 +71,5 @@ gpu_cpp_library(

add_to_package(
DESTINATION fbgemm_gpu/experimental/gen_ai
TARGETS fbgemm_gpu_experimental_gen_ai_py
TARGETS fbgemm_gpu_experimental_gen_ai
FILES ${experimental_gen_ai_python_source_files})
4 changes: 2 additions & 2 deletions fbgemm_gpu/experimental/gen_ai/gen_ai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
# pyre-ignore[16]
if open_source:
torch.ops.load_library(
os.path.join(os.path.dirname(__file__), "fbgemm_gpu_experimental_gen_ai_py.so")
os.path.join(os.path.dirname(__file__), "fbgemm_gpu_experimental_gen_ai.so")
)
torch.classes.load_library(
os.path.join(os.path.dirname(__file__), "fbgemm_gpu_experimental_gen_ai_py.so")
os.path.join(os.path.dirname(__file__), "fbgemm_gpu_experimental_gen_ai.so")
)
else:
torch.ops.load_library(
Expand Down
23 changes: 16 additions & 7 deletions fbgemm_gpu/fbgemm_gpu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@ def _load_library(filename: str) -> None:
"fbgemm_gpu_py",
]

fbgemm_gpu_genai_libraries = [
"experimental/gen_ai/fbgemm_gpu_experimental_gen_ai",
]

# NOTE: While FBGEMM_GPU GenAI is not available for ROCm yet, we would like to
# be able to install the existing CUDA variant of the package onto ROCm systems,
# so that we can at least use the Triton GEMM libraries from experimental/gemm.
# But loading fbgemm_gpu package will trigger load-checking the .SO file for the
# GenAI libraries, which will fail. This workaround ignores check-loading the
# .SO file for the ROCm case, so that clients can import
# fbgemm_gpu.experimental.gemm without triggering an error.
if torch.cuda.is_available() and torch.version.hip:
fbgemm_gpu_genai_libraries = []

libraries_to_load = {
"cpu": fbgemm_gpu_libraries,
"cuda": fbgemm_gpu_libraries
+ [
"experimental/gen_ai/fbgemm_gpu_experimental_gen_ai_py",
],
"genai": [
"experimental/gen_ai/fbgemm_gpu_experimental_gen_ai_py",
],
"cuda": fbgemm_gpu_libraries + fbgemm_gpu_genai_libraries,
"genai": fbgemm_gpu_genai_libraries,
"rocm": fbgemm_gpu_libraries,
}

Expand Down
Loading