-
Notifications
You must be signed in to change notification settings - Fork 262
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
[RFC] Redesigned CMake build infrastructure for C++ API #944
base: main
Are you sure you want to change the base?
Conversation
927f643
to
2fa7a24
Compare
5159f40
to
2335b2f
Compare
2335b2f
to
10d67e1
Compare
Hi @diptorupd thanks for the work, I'll review this PR. |
@yzh119 Thank you. I will resolve the conflicts. I will also push some additional changes I have been doing to handle issues I discovered during local testing. |
495cbb7
to
e0bf809
Compare
I have rebased my changes onto |
Overview
This PR improves the CMake build system for the C++ API of flashinfer, making it more modular, easier to configure, and overall easier to integrate into downstream projects. The changes introduce a proper component-based installation for different usage scenarios for the C++ API, adds CMake-based dependency management, and generally offers a cleaner build organization.
Key Changes
Directory Structure Changes
The C++ sources, tests, and benchmarks are now reorganized inside a
libflashinfer
directory.BEFORE
flashinfer/
├── CMakeLists.txt
├── include/
│ └── flashinfer/
└── src/
AFTER
flashinfer/
├── CMakeLists.txt
├── cmake/
│ └── utils/
│ │ └── ConfigureTargets.cmake
│ ├── Config.cmake.in
│ ├── Dependencies.cmake
│ ├── Options.cmake
├── libflashinfer/
│ ├── CMakeLists.txt
│ ├── include/
│ │ └── flashinfer/
│ │ ├── attention/
│ │ └── distributed/
│ │ └── gemm/
│ ├── tests/
│ │ ├── CMakeLists.txt # Consistent test configuration
│ │ └── fp8/ # FP8-specific tests
│ ├── utils/
│ │ └── fp8/ # FP8 utility files
│ └── benchmarks/
│ ├── CMakeLists.txt # Standardized benchmark setup
│ └── fp8/ # FP8-specific benchmarks
High-level CMake changes
find_package(flashinfer)
in their CMake scripts.CMake configuration and build improvements
The C++ API is broken down into multiple components: Headers, Kernels, TVMBinding, Distributed.
Components can be configured and built separately
cmake .. -GNinja -DFLASHINFER_CUDA_ARCHITECTURES=80 -DFLASHINFER_BUILD_KERNELS=ON -DFLASHINFER_UNITTESTS=ON -DFLASHINFER_CXX_BENCHMARKS=ON -DFLASHINFER_CUTLASS_DIR=../3rdparty/cutlass -DCMAKE_INSTALL_PREFIX=~/devel/install
cmake --build . --target install
Added CMake targets to generate sources based on the same logic as in the current
setup.py
. Generated sources are now placed under theCMAKE_CURRENT_BINARY_DIR
cmake --build . --target generate_kernels
These changes are primarily meant to streamline the changes to add new CMake config options for a proposed HIP back end. However, it is foreseeable to build upon these changes to convert the build system to a fully unified CMake-based using
scikit-build
and use a single configuration system for both C++ and Python APIs. In my experience, using a unified system makes it easier to package and do integration testing.