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

Provide CMake-driver for building libcustom_calls #1345

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3fa41d0
Begin scaffolding for libcustom_call in cmake
mlxd Nov 29, 2024
969240d
Ensure nested cmakes use project scoping
mlxd Nov 29, 2024
2a1b6cc
Remove python driven build for libcustom_calls.so
mlxd Nov 29, 2024
58c27f7
Fix frontend build structure
mlxd Nov 29, 2024
ed676eb
Update Lapack submodule build setup
mlxd Nov 29, 2024
0e1fb47
Build libcustom_calls as a standalone shared lib
mlxd Nov 29, 2024
1e55e5e
Tidy lapack submodule
mlxd Nov 29, 2024
1af2b86
Remove libcustom_calls from setup.py and simplify
mlxd Nov 29, 2024
e3adebf
Update docstring for cmake builder
mlxd Dec 6, 2024
c0fca1f
Merge branch 'main' into cmakeify_frontend
mlxd Dec 6, 2024
5df5dd9
Fix black format
mlxd Dec 6, 2024
45d8aca
Merge branch 'cmakeify_frontend' of github.com:PennyLaneAI/catalyst i…
mlxd Dec 6, 2024
5f9c3ac
Trigger wheel builds
mlxd Dec 6, 2024
5aa20b0
Ensure libcustom follows OS native library naming
mlxd Dec 9, 2024
a31e53f
Merge branch 'main' into cmakeify_frontend
mlxd Dec 9, 2024
d5b6e4b
Fix missing path in setup
mlxd Dec 10, 2024
0ae1613
Merge branch 'main' into cmakeify_frontend
mlxd Dec 10, 2024
fe27420
Merge branch 'main' into cmakeify_frontend
mlxd Dec 10, 2024
67874e7
Force macos wheel builds to ignore universal
mlxd Dec 11, 2024
f5c28d4
Merge branch 'cmakeify_frontend' of github.com:PennyLaneAI/catalyst i…
mlxd Dec 11, 2024
8520a69
Merge branch 'main' into cmakeify_frontend
mlxd Dec 11, 2024
c68f237
Update setup.py
mlxd Dec 11, 2024
bd3d195
Update setup.py
mlxd Dec 11, 2024
4557ed9
Update setup.py
mlxd Dec 11, 2024
33ea71e
Update frontend/catalyst/utils/CMakeLists.txt
mlxd Dec 11, 2024
7b4a034
Update frontend/catalyst/utils/jax_cpu_lapack_kernels/CMakeLists.txt
mlxd Dec 11, 2024
9aee105
remove unneeded branching
mlxd Dec 11, 2024
b73ffde
Remove shared-lib specifics from builder
mlxd Dec 11, 2024
32ceb39
Remove CMake BLAS override option for custom calls lib
mlxd Dec 11, 2024
3f2b6b9
Rename to .so for now
mlxd Dec 11, 2024
bc8c51d
Merge branch 'main' into cmakeify_frontend
mlxd Dec 11, 2024
cc3e77a
Fix cmake target name
mlxd Dec 11, 2024
b6441c3
Merge branch 'cmakeify_frontend' of github.com:PennyLaneAI/catalyst i…
mlxd Dec 11, 2024
9386d07
Force builder to use MacOS 13 as min wheel version
mlxd Dec 13, 2024
8580971
Fix missing list
mlxd Dec 13, 2024
599d987
Force set min mac version for wheel naming
mlxd Dec 13, 2024
7350689
Merge branch 'main' into cmakeify_frontend
mlxd Dec 13, 2024
10e33d3
Add missing platform tag
mlxd Dec 13, 2024
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
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.20)
project(catalyst)

set(LOGO [=[
░█▀▀░█▀█░▀█▀░█▀█░█░░░█░█░█▀▀░▀█▀
░█░░░█▀█░░█░░█▀█░█░░░░█░░▀▀█░░█░
░▀▀▀░▀░▀░░▀░░▀░▀░▀▀▀░░▀░░▀▀▀░░▀░
mlxd marked this conversation as resolved.
Show resolved Hide resolved
]=])
message(${LOGO})

add_subdirectory(frontend)
add_subdirectory(mlir)
add_subdirectory(runtime)
2 changes: 2 additions & 0 deletions frontend/catalyst/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
project(catalyst_frontend)

add_subdirectory(utils)
12 changes: 12 additions & 0 deletions frontend/catalyst/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
project(catalyst_frontend_utils)
dime10 marked this conversation as resolved.
Show resolved Hide resolved

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Expand Down Expand Up @@ -44,3 +46,13 @@ target_include_directories(wrapper PRIVATE ${NUMPY_INCLUDE_DIR})
# Use suffix ".so" rather than ".abi3.so" for library file using Stable ABI
# This is necessary for compatibility with setuptools build extensions
set_target_properties(wrapper PROPERTIES SUFFIX ".so")


add_subdirectory(jax_cpu_lapack_kernels)

add_library(custom_calls SHARED
${PROJECT_SOURCE_DIR}/libcustom_calls.cpp
)
target_link_libraries(custom_calls PRIVATE catalyst_lapack_kernels)
#target_include_directories(custom_calls PRIVATE ${NUMPY_INCLUDE_DIR})

13 changes: 13 additions & 0 deletions frontend/catalyst/utils/jax_cpu_lapack_kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
project(catalyst_jax_lapack)

add_library(catalyst_lapack_kernels STATIC
${PROJECT_SOURCE_DIR}/lapack_kernels.cpp
${PROJECT_SOURCE_DIR}/lapack_kernels_using_lapack.cpp
)

set_property(TARGET catalyst_lapack_kernels PROPERTY POSITION_INDEPENDENT_CODE ON)

target_include_directories(catalyst_lapack_kernels PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
37 changes: 3 additions & 34 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,43 +268,12 @@ def run(self):
check=False,
)


# Compile the library of custom calls in the frontend
if system_platform == "Linux":
custom_calls_extension = Extension(
"catalyst.utils.libcustom_calls",
sources=[
"frontend/catalyst/utils/libcustom_calls.cpp",
"frontend/catalyst/utils/jax_cpu_lapack_kernels/lapack_kernels.cpp",
"frontend/catalyst/utils/jax_cpu_lapack_kernels/lapack_kernels_using_lapack.cpp",
],
extra_compile_args=["-std=c++17"],
)
cmdclass = {"build_ext": CustomBuildExtLinux}

elif system_platform == "Darwin":
variables = sysconfig.get_config_vars()
# Here we need to switch the deault to MacOs dynamic lib
variables["LDSHARED"] = variables["LDSHARED"].replace("-bundle", "-dynamiclib")
if sysconfig.get_config_var("LDCXXSHARED"):
variables["LDCXXSHARED"] = variables["LDCXXSHARED"].replace("-bundle", "-dynamiclib")
custom_calls_extension = Extension(
"catalyst.utils.libcustom_calls",
sources=[
"frontend/catalyst/utils/libcustom_calls.cpp",
"frontend/catalyst/utils/jax_cpu_lapack_kernels/lapack_kernels.cpp",
"frontend/catalyst/utils/jax_cpu_lapack_kernels/lapack_kernels_using_lapack.cpp",
],
extra_compile_args=["-std=c++17"],
)
cmdclass = {"build_ext": CustomBuildExtMacos}


project_root_dir = os.path.abspath(os.path.dirname(__file__))
frontend_dir = os.path.join(project_root_dir, "frontend")

ext_modules = [
custom_calls_extension,
#custom_calls_extension,
CMakeExtension("catalyst.utils.libcustom_calls", sourcedir=frontend_dir),
mlxd marked this conversation as resolved.
Show resolved Hide resolved
CMakeExtension("catalyst.utils.wrapper", sourcedir=frontend_dir),
]

Expand All @@ -331,6 +300,6 @@ def run(self):
package_dir={"": "frontend"},
include_package_data=True,
ext_modules=ext_modules,
cmdclass=cmdclass,
#cmdclass=cmdclass,
**description,
)
Loading