From 5df12438fdcea6c710442824c52f01f81676f305 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Tue, 14 Jul 2026 10:17:11 -0400 Subject: [PATCH 01/20] [WIP] Add catalyst-dev install config --- mlir/CMakeLists.txt | 85 ++++++++++++++++++- mlir/cmake/modules/CMakeLists.txt | 37 +++++++- mlir/cmake/modules/CatalystConfig.cmake.in | 20 +++++ .../modules/CatalystConfig.install.cmake.in | 32 +++++++ mlir/lib/Catalyst/Analysis/CMakeLists.txt | 8 +- mlir/lib/Catalyst/Transforms/CMakeLists.txt | 8 +- mlir/lib/Gradient/Transforms/CMakeLists.txt | 8 +- mlir/lib/Ion/Transforms/CMakeLists.txt | 8 +- mlir/lib/MBQC/Transforms/CMakeLists.txt | 8 +- mlir/lib/Mitigation/Transforms/CMakeLists.txt | 8 +- mlir/lib/PBC/Transforms/CMakeLists.txt | 8 +- mlir/lib/PauliFrame/Transforms/CMakeLists.txt | 8 +- mlir/lib/QRef/Transforms/CMakeLists.txt | 8 +- .../lib/QecPhysical/Transforms/CMakeLists.txt | 8 +- mlir/lib/Quantum/Transforms/CMakeLists.txt | 13 +-- mlir/lib/RTIO/Transforms/CMakeLists.txt | 8 +- mlir/lib/Test/Transforms/CMakeLists.txt | 8 +- .../hlo-extensions/Transforms/CMakeLists.txt | 8 +- 18 files changed, 244 insertions(+), 47 deletions(-) create mode 100644 mlir/cmake/modules/CatalystConfig.install.cmake.in diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index 699423c368..3b8ab9357c 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -75,7 +75,7 @@ foreach(STABLEHLO_LIB IN LISTS STABLEHLO_LIBS) ) endforeach() -add_library(ExternalStablehloLib INTERFACE) +add_library(ExternalStablehloLib INTERFACE IMPORTED GLOBAL) foreach(STABLEHLO_LIB IN LISTS STABLEHLO_LIBS) target_link_libraries(ExternalStablehloLib INTERFACE ${STABLEHLO_LIB}) @@ -280,3 +280,86 @@ endif() if(NOT CATALYST_DOCS_ONLY) add_subdirectory(test) endif() + + +################################################################### +## Generate a Catalyst Development Package for External Projects ## +################################################################### + +include(GNUInstallDirs) + +# Re-fetch the exported targets and strip the same third-party ones the +# build-tree export already excludes (see cmake/modules/CMakeLists.txt). +get_property(CATALYST_INSTALL_TARGETS GLOBAL PROPERTY MLIR_EXPORTS) +set(TARGETS_TO_REMOVE + nlohmann_json + tomlplusplus_tomlplusplus + ion-transforms + CatalystCompilerDriver + PBCUtils + QuantumCAPI + pbc-transforms + quantum-transforms # depends on decompsolver, which depends on boost; exclude + decompsolver # depends on boost; exclude + ) +list(REMOVE_ITEM CATALYST_INSTALL_TARGETS ${TARGETS_TO_REMOVE}) + +# Static archives, shared libs, and any runtime artifacts from the dialects, +# transforms and utils. INCLUDES DESTINATION records the include path in the +# exported targets so consumers get it transitively. +# We use `COMPONENT catalyst-dev` since `add_mlir_public_c_api_library(QuantumCAPI ...) +# auto-generates its own install rule that we want to bypass. +install(TARGETS ${CATALYST_INSTALL_TARGETS} + EXPORT CatalystTargets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT catalyst-dev + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT catalyst-dev + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT catalyst-dev + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +# Uncomment the lines below to include tools in catalyst-dev. +# They are currently excluded due to their large size. +# # Tools (binaries). These are usually not in MLIR_EXPORTS, so install by name. +# if(NOT CATALYST_DOCS_ONLY) +# # Need to wrap in `if(NOT CATALYST_DOCS_ONLY)` since `add_subdirectory(tools)` +# # is also conditional on this predicate +# install(TARGETS catalyst-cli quantum-opt quantum-lsp-server +# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT catalyst-dev) +# endif() + +# Hand-written headers (*.h and the *.td that TableGen consumers may want). +install(DIRECTORY ${CATALYST_MAIN_INCLUDE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT catalyst-dev + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.td" + PATTERN "*.capi.h.inc") + +# TableGen-generated headers (*.h.inc, *.cpp.inc) AND the generated +# frontend_catalyst_version_py.h all live under the build-tree include dir. +install(DIRECTORY ${CATALYST_GEN_INCLUDE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT catalyst-dev + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.h.inc" + PATTERN "*.cpp.inc" + PATTERN "CMakeFiles" EXCLUDE) + +# Bundle the StableHLO static archives that Catalyst links against. +install(DIRECTORY "${STABLEHLO_BUILD_DIR}/lib/" + DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT catalyst-dev + FILES_MATCHING PATTERN "lib*.a") + +set(CPACK_PACKAGE_NAME "catalyst-dev") +set(CPACK_PACKAGE_VERSION "${CATALYST_PACKAGE_VERSION}") +set(CPACK_GENERATOR "TGZ") +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}_${CATALYST_PACKAGE_VERSION}") +set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) +set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY ON) # extracts into catalyst-dev-/ +set(CPACK_COMPONENTS_ALL catalyst-dev) # only catalyst-dev component +set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE) # single archive, no per-component split + +message(STATUS "Preparing CPack package ${CPACK_PACKAGE_FILE_NAME}") +include(CPack) diff --git a/mlir/cmake/modules/CMakeLists.txt b/mlir/cmake/modules/CMakeLists.txt index f2f98bb83b..c77b00a906 100644 --- a/mlir/cmake/modules/CMakeLists.txt +++ b/mlir/cmake/modules/CMakeLists.txt @@ -28,7 +28,7 @@ set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") get_property(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS) set(TARGETS_TO_REMOVE nlohmann_json tomlplusplus_tomlplusplus ion-transforms CatalystCompilerDriver PBCUtils QuantumCAPI pbc-transforms) list(REMOVE_ITEM MLIR_EXPORTS ${TARGETS_TO_REMOVE}) -export(TARGETS ${MLIR_EXPORTS} ExternalStablehloLib FILE ${catalyst_cmake_builddir}/CatalystTargets.cmake) +export(TARGETS ${MLIR_EXPORTS} FILE ${catalyst_cmake_builddir}/CatalystTargets.cmake) # Generate MlirConfig.cmake for the build tree. set(CATALYST_CONFIG_CMAKE_DIR "${catalyst_cmake_builddir}") @@ -48,3 +48,38 @@ configure_file( set(CATALYST_CONFIG_CMAKE_DIR) set(CATALYST_CONFIG_LLVM_CMAKE_DIR) set(CATALYST_CONFIG_INCLUDE_DIRS) + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +# --- version string, reused from frontend/catalyst/_version.py --- +file(READ "${PROJECT_SOURCE_DIR}/../frontend/catalyst/_version.py" _ver_py) +string(REGEX MATCH "__version__ = \"([^\"]+)\"" _m "${_ver_py}") +set(CATALYST_PACKAGE_VERSION "${CMAKE_MATCH_1}" CACHE INTERNAL "Catalyst version") + +string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" CATALYST_NUMERIC_VERSION "${CATALYST_PACKAGE_VERSION}") + +write_basic_package_version_file( + "${catalyst_cmake_builddir}/CatalystConfigVersion.cmake" + VERSION ${CATALYST_NUMERIC_VERSION} + COMPATIBILITY SameMajorVersion) + +# --- install-tree config, generated from a *separate* template --- +set(CATALYST_INSTALL_TARGETS_LIST "${MLIR_EXPORTS}") # same list, minus removals +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CatalystConfig.install.cmake.in + "${catalyst_cmake_builddir}/install/CatalystConfig.cmake" + INSTALL_DESTINATION ${CATALYST_INSTALL_PACKAGE_DIR} + PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR) + +# --- install the export set + configs --- +install(EXPORT CatalystTargets + FILE CatalystTargets.cmake + DESTINATION ${CATALYST_INSTALL_PACKAGE_DIR} + COMPONENT catalyst-dev) + +install(FILES + "${catalyst_cmake_builddir}/install/CatalystConfig.cmake" + "${catalyst_cmake_builddir}/CatalystConfigVersion.cmake" + DESTINATION ${CATALYST_INSTALL_PACKAGE_DIR} + COMPONENT catalyst-dev) diff --git a/mlir/cmake/modules/CatalystConfig.cmake.in b/mlir/cmake/modules/CatalystConfig.cmake.in index f6745ef324..daa10ccb16 100644 --- a/mlir/cmake/modules/CatalystConfig.cmake.in +++ b/mlir/cmake/modules/CatalystConfig.cmake.in @@ -22,3 +22,23 @@ set(CATALYST_INCLUDE_DIRS "@CATALYST_CONFIG_INCLUDE_DIRS@") # Provide all our library targets to users. @CATALYST_CONFIG_INCLUDE_EXPORTS@ + +# --- rebuild ExternalStablehloLib for build-tree consumers --- +set(_shlo_libs ChloCAPI ChloOps StablehloAssemblyFormat StablehloBase + StablehloBroadcastUtils StablehloBroadcastLowering StablehloCAPI + StablehloLinalgTransforms StablehloOps StablehloOptimizationPasses + StablehloPasses StablehloPassUtils StablehloRegister + StablehloTypeConversion StablehloTypeInference Version + VhloCAPI VhloOps VhloTypes) +if(NOT TARGET ExternalStablehloLib) + add_library(ExternalStablehloLib INTERFACE IMPORTED) + foreach(_l IN LISTS _shlo_libs) + if(NOT TARGET ${_l}) + add_library(${_l} STATIC IMPORTED) + set_target_properties(${_l} PROPERTIES + IMPORTED_LOCATION "@STABLEHLO_BUILD_DIR@/lib/lib${_l}.a") + endif() + set_property(TARGET ExternalStablehloLib APPEND + PROPERTY INTERFACE_LINK_LIBRARIES ${_l}) + endforeach() +endif() diff --git a/mlir/cmake/modules/CatalystConfig.install.cmake.in b/mlir/cmake/modules/CatalystConfig.install.cmake.in new file mode 100644 index 0000000000..f77f3230c7 --- /dev/null +++ b/mlir/cmake/modules/CatalystConfig.install.cmake.in @@ -0,0 +1,32 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(MLIR) + +set_and_check(CATALYST_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +set_and_check(CATALYST_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") + +# Reconstruct the bundled StableHLO interface target. +set(_shlo_libs ChloCAPI ChloOps StablehloAssemblyFormat StablehloBase + StablehloBroadcastUtils StablehloBroadcastLowering StablehloCAPI + StablehloLinalgTransforms StablehloOps StablehloOptimizationPasses + StablehloPasses StablehloPassUtils StablehloRegister + StablehloTypeConversion StablehloTypeInference Version + VhloCAPI VhloOps VhloTypes) +if(NOT TARGET ExternalStablehloLib) + add_library(ExternalStablehloLib INTERFACE IMPORTED) + foreach(_l IN LISTS _shlo_libs) + if(NOT TARGET ${_l}) + add_library(${_l} STATIC IMPORTED) + set_target_properties(${_l} PROPERTIES + IMPORTED_LOCATION "${CATALYST_LIBRARY_DIR}/lib${_l}.a") + endif() + set_property(TARGET ExternalStablehloLib APPEND + PROPERTY INTERFACE_LINK_LIBRARIES ${_l}) + endforeach() +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/CatalystTargets.cmake") + +set(CATALYST_EXPORTED_TARGETS "@CATALYST_INSTALL_TARGETS_LIST@") +check_required_components(Catalyst) diff --git a/mlir/lib/Catalyst/Analysis/CMakeLists.txt b/mlir/lib/Catalyst/Analysis/CMakeLists.txt index f8d3b47428..bdce81bf4a 100644 --- a/mlir/lib/Catalyst/Analysis/CMakeLists.txt +++ b/mlir/lib/Catalyst/Analysis/CMakeLists.txt @@ -16,6 +16,8 @@ set(LIBS add_mlir_library(${LIBRARY_NAME} STATIC ${SRC} LINK_LIBS PRIVATE ${LIBS}) target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) diff --git a/mlir/lib/Catalyst/Transforms/CMakeLists.txt b/mlir/lib/Catalyst/Transforms/CMakeLists.txt index bb794d3b4c..c9690ba27d 100644 --- a/mlir/lib/Catalyst/Transforms/CMakeLists.txt +++ b/mlir/lib/Catalyst/Transforms/CMakeLists.txt @@ -43,6 +43,8 @@ set(DEPENDS add_mlir_library(${LIBRARY_NAME} STATIC ${SRC} LINK_LIBS PRIVATE ${LIBS} DEPENDS ${DEPENDS}) target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) diff --git a/mlir/lib/Gradient/Transforms/CMakeLists.txt b/mlir/lib/Gradient/Transforms/CMakeLists.txt index 572a1217bc..9fcc61ec8f 100644 --- a/mlir/lib/Gradient/Transforms/CMakeLists.txt +++ b/mlir/lib/Gradient/Transforms/CMakeLists.txt @@ -35,6 +35,8 @@ set(DEPENDS add_mlir_library(${LIBRARY_NAME} STATIC ${SRC} LINK_LIBS PRIVATE ${LIBS} DEPENDS ${DEPENDS}) target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) diff --git a/mlir/lib/Ion/Transforms/CMakeLists.txt b/mlir/lib/Ion/Transforms/CMakeLists.txt index 59468e4a55..768af4be67 100644 --- a/mlir/lib/Ion/Transforms/CMakeLists.txt +++ b/mlir/lib/Ion/Transforms/CMakeLists.txt @@ -45,9 +45,11 @@ set(DEPENDS add_mlir_library(${LIBRARY_NAME} STATIC ${SRC} LINK_LIBS PRIVATE ${LIBS} DEPENDS ${DEPENDS}) target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) target_link_libraries(${LIBRARY_NAME} PRIVATE tomlplusplus::tomlplusplus diff --git a/mlir/lib/MBQC/Transforms/CMakeLists.txt b/mlir/lib/MBQC/Transforms/CMakeLists.txt index 9b9ea4dd8f..07d70ba648 100644 --- a/mlir/lib/MBQC/Transforms/CMakeLists.txt +++ b/mlir/lib/MBQC/Transforms/CMakeLists.txt @@ -20,6 +20,8 @@ set(DEPENDS add_mlir_library(${LIBRARY_NAME} STATIC ${SRC} LINK_LIBS PRIVATE ${LIBS} DEPENDS ${DEPENDS}) target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) diff --git a/mlir/lib/Mitigation/Transforms/CMakeLists.txt b/mlir/lib/Mitigation/Transforms/CMakeLists.txt index 2af124cd74..73d0b21595 100644 --- a/mlir/lib/Mitigation/Transforms/CMakeLists.txt +++ b/mlir/lib/Mitigation/Transforms/CMakeLists.txt @@ -21,6 +21,8 @@ set(DEPENDS add_mlir_library(${LIBRARY_NAME} STATIC ${SRC} LINK_LIBS PRIVATE ${LIBS} DEPENDS ${DEPENDS}) target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) diff --git a/mlir/lib/PBC/Transforms/CMakeLists.txt b/mlir/lib/PBC/Transforms/CMakeLists.txt index f0ec206ce3..6984088448 100644 --- a/mlir/lib/PBC/Transforms/CMakeLists.txt +++ b/mlir/lib/PBC/Transforms/CMakeLists.txt @@ -59,6 +59,8 @@ set_source_files_properties( endif() target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) diff --git a/mlir/lib/PauliFrame/Transforms/CMakeLists.txt b/mlir/lib/PauliFrame/Transforms/CMakeLists.txt index 7556802b3c..b74d7f89bd 100644 --- a/mlir/lib/PauliFrame/Transforms/CMakeLists.txt +++ b/mlir/lib/PauliFrame/Transforms/CMakeLists.txt @@ -22,6 +22,8 @@ add_mlir_library(${LIBRARY_NAME} STATIC ${SRC} LINK_LIBS PRIVATE ${LIBS} DEPENDS target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) diff --git a/mlir/lib/QRef/Transforms/CMakeLists.txt b/mlir/lib/QRef/Transforms/CMakeLists.txt index 4be9bd0d6d..a3646548af 100644 --- a/mlir/lib/QRef/Transforms/CMakeLists.txt +++ b/mlir/lib/QRef/Transforms/CMakeLists.txt @@ -22,6 +22,8 @@ add_mlir_library(${LIBRARY_NAME} STATIC ${SRC} LINK_LIBS PRIVATE ${LIBS} DEPENDS target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) diff --git a/mlir/lib/QecPhysical/Transforms/CMakeLists.txt b/mlir/lib/QecPhysical/Transforms/CMakeLists.txt index 4b7afc95cd..b28b1559f6 100644 --- a/mlir/lib/QecPhysical/Transforms/CMakeLists.txt +++ b/mlir/lib/QecPhysical/Transforms/CMakeLists.txt @@ -28,6 +28,8 @@ add_mlir_library(${LIBRARY_NAME} STATIC ) target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) diff --git a/mlir/lib/Quantum/Transforms/CMakeLists.txt b/mlir/lib/Quantum/Transforms/CMakeLists.txt index ff73879814..21a63b6cf7 100644 --- a/mlir/lib/Quantum/Transforms/CMakeLists.txt +++ b/mlir/lib/Quantum/Transforms/CMakeLists.txt @@ -61,10 +61,11 @@ add_mlir_library(${LIBRARY_NAME} STATIC ) target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include - AdjointLowering/ - GraphDecomposition/ - GraphDecomposition/DecompGraphSolver/ + $ + $ + $ + $ + $ + $ + $ ) diff --git a/mlir/lib/RTIO/Transforms/CMakeLists.txt b/mlir/lib/RTIO/Transforms/CMakeLists.txt index a2a7c4edc1..96935ccac3 100644 --- a/mlir/lib/RTIO/Transforms/CMakeLists.txt +++ b/mlir/lib/RTIO/Transforms/CMakeLists.txt @@ -22,6 +22,8 @@ set(DEPENDS add_mlir_library(${LIBRARY_NAME} STATIC ${SRC} LINK_LIBS PRIVATE ${LIBS} DEPENDS ${DEPENDS}) target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) diff --git a/mlir/lib/Test/Transforms/CMakeLists.txt b/mlir/lib/Test/Transforms/CMakeLists.txt index 7df4fc2cd5..0c18147953 100644 --- a/mlir/lib/Test/Transforms/CMakeLists.txt +++ b/mlir/lib/Test/Transforms/CMakeLists.txt @@ -6,6 +6,8 @@ add_mlir_library(MLIRCatalystTest ) target_include_directories(MLIRCatalystTest PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) diff --git a/mlir/lib/hlo-extensions/Transforms/CMakeLists.txt b/mlir/lib/hlo-extensions/Transforms/CMakeLists.txt index d483476a62..9954a152e1 100644 --- a/mlir/lib/hlo-extensions/Transforms/CMakeLists.txt +++ b/mlir/lib/hlo-extensions/Transforms/CMakeLists.txt @@ -27,6 +27,8 @@ set(DEPENDS add_mlir_library(${LIBRARY_NAME} STATIC ${SRC} LINK_LIBS PRIVATE ${LIBS} DEPENDS ${DEPENDS}) target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20) target_include_directories(${LIBRARY_NAME} PUBLIC - . - ${PROJECT_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include) + $ + $ + $ + $ +) From 61a2f9422e8abd0e650082f0b52a384fb90ce097 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Tue, 14 Jul 2026 11:04:29 -0400 Subject: [PATCH 02/20] Add catalyst-dev to nightly build workflows --- .github/workflows/build-nightly-release.yaml | 32 +++++++++++++++++++ .../workflows/build-wheel-linux-arm64.yaml | 23 +++++++++++++ .../workflows/build-wheel-linux-x86_64.yaml | 23 +++++++++++++ .../workflows/build-wheel-macos-arm64.yaml | 23 +++++++++++++ 4 files changed, 101 insertions(+) diff --git a/.github/workflows/build-nightly-release.yaml b/.github/workflows/build-nightly-release.yaml index 7bb46a22e6..d5fed5c048 100644 --- a/.github/workflows/build-nightly-release.yaml +++ b/.github/workflows/build-nightly-release.yaml @@ -43,17 +43,23 @@ jobs: name: Build on Linux x86-64 needs: [setup] uses: ./.github/workflows/build-wheel-linux-x86_64.yaml + with: + build_dev_package: true linux-aarch: if: ${{ inputs.build-linux-arm }} name: Build on Linux aarch64 needs: [setup] uses: ./.github/workflows/build-wheel-linux-arm64.yaml + with: + build_dev_package: true macos-arm: name: Build on macOS arm64 needs: [setup] uses: ./.github/workflows/build-wheel-macos-arm64.yaml + with: + build_dev_package: true upload: name: Prepare & Upload wheels to TestPyPI @@ -67,6 +73,7 @@ jobs: - name: Download wheels uses: actions/download-artifact@v4 with: + pattern: "*wheel*" merge-multiple: true path: dist @@ -86,3 +93,28 @@ jobs: repository-url: https://test.pypi.org/legacy/ packages-dir: dist verbose: true + + collect-dev-package: + name: Collect catalyst-dev archives + if: ${{ !failure() && !cancelled() }} # needed in case linux-aarch is skipped + needs: [linux-x86, macos-arm, linux-aarch] + runs-on: ubuntu-24.04 + + steps: + - name: Download catalyst-dev archives + uses: actions/download-artifact@v4 + with: + pattern: catalyst-dev* + merge-multiple: true + path: catalyst-dev + + - name: List collected archives + run: ls -lh catalyst-dev* + + - name: Upload combined catalyst-dev archives + uses: actions/upload-artifact@v4 + with: + name: catalyst-dev-archives + path: catalyst-dev/ + retention-days: 14 + if-no-files-found: error diff --git a/.github/workflows/build-wheel-linux-arm64.yaml b/.github/workflows/build-wheel-linux-arm64.yaml index ac89b251af..6f05889087 100644 --- a/.github/workflows/build-wheel-linux-arm64.yaml +++ b/.github/workflows/build-wheel-linux-arm64.yaml @@ -38,6 +38,11 @@ on: required: false default: 'main' type: string + build_dev_package: + description: 'Build and upload the catalyst-dev CPack archive' + required: false + default: false + type: boolean concurrency: group: Build Catalyst Wheel on Linux (arm64)-${{ github.ref }} @@ -373,6 +378,24 @@ jobs: cmake --build $GITHUB_WORKSPACE/quantum-build --target check-dialects catalyst-cli + # Package the Catalyst MLIR development subsystem (headers, static libs, CMake config). + # Only build once per platform (primary Python version) since the archive is Python-agnostic. + - name: Package catalyst-dev (CPack) + if: inputs.build_dev_package && matrix.python_version == needs.constants.outputs.primary_python_version + run: | + cd $GITHUB_WORKSPACE/quantum-build + cpack + + - name: Upload catalyst-dev Archive + if: inputs.build_dev_package && matrix.python_version == needs.constants.outputs.primary_python_version + uses: actions/upload-artifact@v4 + with: + name: catalyst-dev_Linux_aarch64 + path: | + ${{ github.workspace }}/quantum-build/catalyst-dev_Linux_aarch64*.tar.gz + retention-days: 14 + if-no-files-found: error + - name: Build Plugin wheel # Run only on Thursday at the given time if: env.BUILD_STANDALONE_PLUGIN == 'true' diff --git a/.github/workflows/build-wheel-linux-x86_64.yaml b/.github/workflows/build-wheel-linux-x86_64.yaml index 96298116de..39dcadc467 100644 --- a/.github/workflows/build-wheel-linux-x86_64.yaml +++ b/.github/workflows/build-wheel-linux-x86_64.yaml @@ -38,6 +38,11 @@ on: required: false default: 'main' type: string + build_dev_package: + description: 'Build and upload the catalyst-dev CPack archive' + required: false + default: false + type: boolean concurrency: group: Build Catalyst Wheel on Linux (x86_64)-${{ github.ref }} @@ -397,6 +402,24 @@ jobs: cmake --build $GITHUB_WORKSPACE/quantum-build --target check-dialects catalyst-cli + # Package the Catalyst MLIR development subsystem (headers, static libs, CMake config). + # Only build once per platform (primary Python version) since the archive is Python-agnostic. + - name: Package catalyst-dev (CPack) + if: inputs.build_dev_package && matrix.python_version == needs.constants.outputs.primary_python_version + run: | + cd $GITHUB_WORKSPACE/quantum-build + cpack + + - name: Upload catalyst-dev Archive + if: inputs.build_dev_package && matrix.python_version == needs.constants.outputs.primary_python_version + uses: actions/upload-artifact@v4 + with: + name: catalyst-dev_Linux_x86_64 + path: | + ${{ github.workspace }}/quantum-build/catalyst-dev_Linux_x86_64*.tar.gz + retention-days: 14 + if-no-files-found: error + - name: Build Plugin wheel # Run only on Thursday at the given time if: env.BUILD_STANDALONE_PLUGIN == 'true' diff --git a/.github/workflows/build-wheel-macos-arm64.yaml b/.github/workflows/build-wheel-macos-arm64.yaml index bff8bb7156..b9981fda02 100644 --- a/.github/workflows/build-wheel-macos-arm64.yaml +++ b/.github/workflows/build-wheel-macos-arm64.yaml @@ -36,6 +36,11 @@ on: required: false default: 'main' type: string + build_dev_package: + description: 'Build and upload the catalyst-dev CPack archive' + required: false + default: false + type: boolean env: MACOSX_DEPLOYMENT_TARGET: 15.0 @@ -376,6 +381,24 @@ jobs: # xcode builds significantly slower when multithreaded cmake --build $GITHUB_WORKSPACE/quantum-build --target check-dialects catalyst-cli -- -j 1 + # Package the Catalyst MLIR development subsystem (headers, static libs, CMake config). + # Only build once per platform (primary Python version) since the archive is Python-agnostic. + - name: Package catalyst-dev (CPack) + if: inputs.build_dev_package && matrix.python_version == needs.constants.outputs.primary_python_version + run: | + cd $GITHUB_WORKSPACE/quantum-build + cpack + + - name: Upload catalyst-dev Archive + if: inputs.build_dev_package && matrix.python_version == needs.constants.outputs.primary_python_version + uses: actions/upload-artifact@v4 + with: + name: catalyst-dev_macos_arm64 + path: | + ${{ github.workspace }}/quantum-build/catalyst-dev_Darwin_arm64*.tar.gz + retention-days: 14 + if-no-files-found: error + - name: Build Plugin wheel # Run only on Thursday at the given time if: env.BUILD_STANDALONE_PLUGIN == 'true' From 7bd7bb328696499c095b9d91160dd9ae91c54618 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Tue, 14 Jul 2026 11:21:53 -0400 Subject: [PATCH 03/20] Add pack-catalyst-dev Makefile rule --- mlir/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mlir/Makefile b/mlir/Makefile index d0e643ee6b..fbed76b859 100644 --- a/mlir/Makefile +++ b/mlir/Makefile @@ -49,13 +49,14 @@ help: @echo " enzyme to build Enzyme" @echo " dialects to build custom Catalyst MLIR dialects" @echo " dialect-docs to build custom Catalyst MLIR dialect documentation" + @echo " pack-catalyst-dev to build the catalyst-dev package" @echo " test to run the Catalyst MLIR dialects test suite" @echo " clean to delete all temporary, cache, and build files" @echo " format [check=1] to apply C++ formatter; use with 'check=1' to check instead of modify (requires clang-format)" @echo " format [version=?] to apply C++ formatter; use with 'version={version}' to run clang-format-{version} instead of clang-format" .PHONY: all -all: llvm stablehlo enzyme dialects dialect-docs plugin +all: llvm stablehlo enzyme dialects dialect-docs pack-catalyst-dev plugin .PHONY: llvm llvm: @@ -220,6 +221,12 @@ dialect-docs: cmake --build $(DIALECTS_DOCS_BUILD_DIR) --target mlir-doc +.PHONY: pack-catalyst-dev +pack-catalyst-dev: dialects + + @echo "build the catalyst-dev package" + cd $(DIALECTS_BUILD_DIR) && cpack + .PHONY: test test: @echo "test the Catalyst MLIR dialects test suite" From d1828b7055f6d8784dbae7370cc939cbeb73f624 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Wed, 15 Jul 2026 10:14:27 -0400 Subject: [PATCH 04/20] Uncomment tools install command And change its component to `catalyst-bin` --- mlir/CMakeLists.txt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index 3b8ab9357c..bed4ecca72 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -316,15 +316,14 @@ install(TARGETS ${CATALYST_INSTALL_TARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT catalyst-dev INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -# Uncomment the lines below to include tools in catalyst-dev. -# They are currently excluded due to their large size. -# # Tools (binaries). These are usually not in MLIR_EXPORTS, so install by name. -# if(NOT CATALYST_DOCS_ONLY) -# # Need to wrap in `if(NOT CATALYST_DOCS_ONLY)` since `add_subdirectory(tools)` -# # is also conditional on this predicate -# install(TARGETS catalyst-cli quantum-opt quantum-lsp-server -# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT catalyst-dev) -# endif() +# Tools (binaries). These are usually not in MLIR_EXPORTS, so install by name. +# NOTE: We use the catalyst-bin component for tools to exclude from catalyst-dev. +if(NOT CATALYST_DOCS_ONLY) + # Need to wrap in `if(NOT CATALYST_DOCS_ONLY)` since `add_subdirectory(tools)` + # is also conditional on this predicate + install(TARGETS catalyst-cli quantum-opt quantum-lsp-server + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT catalyst-bin) +endif() # Hand-written headers (*.h and the *.td that TableGen consumers may want). install(DIRECTORY ${CATALYST_MAIN_INCLUDE_DIR}/ From bed04125641762d1cb4c15dc226e307dc13916ec Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Wed, 22 Jul 2026 15:03:55 -0400 Subject: [PATCH 05/20] Also install LICENSE to catalyst-dev --- mlir/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index bed4ecca72..69a88b8a44 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -316,6 +316,11 @@ install(TARGETS ${CATALYST_INSTALL_TARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT catalyst-dev INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +# Install license to share/doc/Catalyst/LICENSE +install(FILES "${PROJECT_SOURCE_DIR}/../LICENSE" + DESTINATION "${CMAKE_INSTALL_DOCDIR}" + COMPONENT catalyst-dev) + # Tools (binaries). These are usually not in MLIR_EXPORTS, so install by name. # NOTE: We use the catalyst-bin component for tools to exclude from catalyst-dev. if(NOT CATALYST_DOCS_ONLY) From fd4b91feb12a5a04fe502178b4c7252a81700410 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Wed, 22 Jul 2026 15:05:05 -0400 Subject: [PATCH 06/20] Remove pack-catalyst-dev from 'make all' rule --- mlir/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlir/Makefile b/mlir/Makefile index fbed76b859..9bdd84d464 100644 --- a/mlir/Makefile +++ b/mlir/Makefile @@ -56,7 +56,7 @@ help: @echo " format [version=?] to apply C++ formatter; use with 'version={version}' to run clang-format-{version} instead of clang-format" .PHONY: all -all: llvm stablehlo enzyme dialects dialect-docs pack-catalyst-dev plugin +all: llvm stablehlo enzyme dialects dialect-docs plugin .PHONY: llvm llvm: From 988ed65468b5b6bf39926fee3bfdc6bd313c7e65 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Wed, 22 Jul 2026 15:05:38 -0400 Subject: [PATCH 07/20] Configure make rules for catalyst and mlir dev packages --- mlir/Makefile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mlir/Makefile b/mlir/Makefile index 9bdd84d464..85414f1b57 100644 --- a/mlir/Makefile +++ b/mlir/Makefile @@ -11,11 +11,17 @@ LLVM_BUILD_DIR ?= $(MK_DIR)/llvm-project/build STABLEHLO_BUILD_DIR ?= $(MK_DIR)/stablehlo/build ENZYME_BUILD_DIR ?= $(MK_DIR)/Enzyme/build RT_BUILD_DIR ?= $(MK_DIR)/../runtime/build +DIST_DIR ?= $(MK_DIR)/dist ENABLE_ASAN ?= OFF STRICT_WARNINGS ?= ON BUILD_TYPE ?= Release LLVM_EXTERNAL_LIT ?= $(LLVM_BUILD_DIR)/bin/llvm-lit LLVM_TARGETS_TO_BUILD ?= host +LLVM_INSTALL_STAGING_DIR ?= $(LLVM_BUILD_DIR)/install +LLVM_DISTRIBUTION_COMPONENTS ?= $\ + "cmake-exports;llvm-headers;llvm-libraries;$\ + mlir-cmake-exports;mlir-headers;mlir-libraries;$\ + FileCheck;llvm-tblgen;llvm-config;mlir-tblgen;not;count" ifeq ($(shell uname), Darwin) DEFAULT_ENABLE_LLD := OFF @@ -81,6 +87,9 @@ llvm: -DLLVM_ENABLE_PROJECTS="$(LLVM_PROJECTS)" \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ + -DLLVM_INSTALL_UTILS=ON \ + -DLLVM_DISTRIBUTION_COMPONENTS=$(LLVM_DISTRIBUTION_COMPONENTS) \ + -DCMAKE_INSTALL_PREFIX=$(LLVM_BUILD_DIR)/install \ -DPython_EXECUTABLE=$(PYTHON) \ -DPython3_EXECUTABLE=$(PYTHON) \ -DPython3_NumPy_INCLUDE_DIRS=$$($(PYTHON) -c "import numpy as np; print(np.get_include())") \ @@ -226,6 +235,23 @@ pack-catalyst-dev: dialects @echo "build the catalyst-dev package" cd $(DIALECTS_BUILD_DIR) && cpack + mkdir -p $(DIST_DIR) + mv $(DIALECTS_BUILD_DIR)/catalyst-dev*.tar.gz $(DIST_DIR) + +# Get the LLVM version as, e.g. 22.0.0git-8f264586 +LLVM_VERSION := $(shell $(LLVM_INSTALL_STAGING_DIR)/bin/llvm-config --version) +LLVM_COMMIT := $(shell grep llvm ../.dep-versions | awk -F '=' '{ print $$2 }' | cut -c1-8) +LLVM_VERSION_FULL := $(LLVM_VERSION)-$(LLVM_COMMIT) + +.PHONY: pack-mlir-dev +pack-mlir-dev: llvm + + @echo "build the catalyst-mlir-dev package" + cmake --build $(LLVM_BUILD_DIR) --target install-distribution + tar -czf catalyst-mlir-dev_$(shell uname -s)_$(shell uname -m)_$(LLVM_VERSION_FULL).tar.gz \ + -C $(LLVM_INSTALL_STAGING_DIR) bin lib include + mkdir -p $(DIST_DIR) + mv catalyst-mlir-dev*.tar.gz $(DIST_DIR) .PHONY: test test: From 70fcf17d0324ccd2f92a89913e5e0e0c2ccbd985 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Wed, 22 Jul 2026 15:07:13 -0400 Subject: [PATCH 08/20] Remove dev package builds from linux-arm64 workflows --- .github/workflows/build-nightly-release.yaml | 2 -- .../workflows/build-wheel-linux-arm64.yaml | 23 ------------------- 2 files changed, 25 deletions(-) diff --git a/.github/workflows/build-nightly-release.yaml b/.github/workflows/build-nightly-release.yaml index d5fed5c048..2dce29c93b 100644 --- a/.github/workflows/build-nightly-release.yaml +++ b/.github/workflows/build-nightly-release.yaml @@ -51,8 +51,6 @@ jobs: name: Build on Linux aarch64 needs: [setup] uses: ./.github/workflows/build-wheel-linux-arm64.yaml - with: - build_dev_package: true macos-arm: name: Build on macOS arm64 diff --git a/.github/workflows/build-wheel-linux-arm64.yaml b/.github/workflows/build-wheel-linux-arm64.yaml index 6f05889087..ac89b251af 100644 --- a/.github/workflows/build-wheel-linux-arm64.yaml +++ b/.github/workflows/build-wheel-linux-arm64.yaml @@ -38,11 +38,6 @@ on: required: false default: 'main' type: string - build_dev_package: - description: 'Build and upload the catalyst-dev CPack archive' - required: false - default: false - type: boolean concurrency: group: Build Catalyst Wheel on Linux (arm64)-${{ github.ref }} @@ -378,24 +373,6 @@ jobs: cmake --build $GITHUB_WORKSPACE/quantum-build --target check-dialects catalyst-cli - # Package the Catalyst MLIR development subsystem (headers, static libs, CMake config). - # Only build once per platform (primary Python version) since the archive is Python-agnostic. - - name: Package catalyst-dev (CPack) - if: inputs.build_dev_package && matrix.python_version == needs.constants.outputs.primary_python_version - run: | - cd $GITHUB_WORKSPACE/quantum-build - cpack - - - name: Upload catalyst-dev Archive - if: inputs.build_dev_package && matrix.python_version == needs.constants.outputs.primary_python_version - uses: actions/upload-artifact@v4 - with: - name: catalyst-dev_Linux_aarch64 - path: | - ${{ github.workspace }}/quantum-build/catalyst-dev_Linux_aarch64*.tar.gz - retention-days: 14 - if-no-files-found: error - - name: Build Plugin wheel # Run only on Thursday at the given time if: env.BUILD_STANDALONE_PLUGIN == 'true' From de85d243910b11edb3add1f40a5042866c057cb5 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Wed, 22 Jul 2026 15:07:41 -0400 Subject: [PATCH 09/20] Update build_dev_package description --- .github/workflows/build-wheel-linux-x86_64.yaml | 2 +- .github/workflows/build-wheel-macos-arm64.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-wheel-linux-x86_64.yaml b/.github/workflows/build-wheel-linux-x86_64.yaml index 39dcadc467..f3c6e2efae 100644 --- a/.github/workflows/build-wheel-linux-x86_64.yaml +++ b/.github/workflows/build-wheel-linux-x86_64.yaml @@ -39,7 +39,7 @@ on: default: 'main' type: string build_dev_package: - description: 'Build and upload the catalyst-dev CPack archive' + description: 'Build and upload the catalyst-dev archives' required: false default: false type: boolean diff --git a/.github/workflows/build-wheel-macos-arm64.yaml b/.github/workflows/build-wheel-macos-arm64.yaml index b9981fda02..ebcf79b9ec 100644 --- a/.github/workflows/build-wheel-macos-arm64.yaml +++ b/.github/workflows/build-wheel-macos-arm64.yaml @@ -37,7 +37,7 @@ on: default: 'main' type: string build_dev_package: - description: 'Build and upload the catalyst-dev CPack archive' + description: 'Build and upload the catalyst-dev archives' required: false default: false type: boolean From b31a62f514b1826f0ed90f1ad46ced047821a055 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Wed, 22 Jul 2026 16:50:01 -0400 Subject: [PATCH 10/20] Add help message for pack-mlir-dev Makefile rule --- mlir/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/mlir/Makefile b/mlir/Makefile index 85414f1b57..964e461eeb 100644 --- a/mlir/Makefile +++ b/mlir/Makefile @@ -56,6 +56,7 @@ help: @echo " dialects to build custom Catalyst MLIR dialects" @echo " dialect-docs to build custom Catalyst MLIR dialect documentation" @echo " pack-catalyst-dev to build the catalyst-dev package" + @echo " pack-mlir-dev to build the catalyst-mlir-dev package" @echo " test to run the Catalyst MLIR dialects test suite" @echo " clean to delete all temporary, cache, and build files" @echo " format [check=1] to apply C++ formatter; use with 'check=1' to check instead of modify (requires clang-format)" From 4c975dfd4e3f5bc73cdbba84301bd517c075865e Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Wed, 22 Jul 2026 17:00:37 -0400 Subject: [PATCH 11/20] Add changelog entry --- doc/releases/changelog-dev.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 35bb08012e..3549f1b17e 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -445,6 +445,11 @@ `-stage` naming convention used when invoking them from the command line (e.g. `quantum-compilation-stage`). [#3002](https://github.com/PennyLaneAI/catalyst/pull/3002) +* New build configurations have been added to allow building "development" packages of Catalyst and + LLVM/MLIR. These dev packages will allow Catalyst plugin developers to build against the pre-built + libraries included therein, rather than having to build Catalyst and its dependencies from source. + [#3023](https://github.com/PennyLaneAI/catalyst/pull/3023) +

Documentation 📝

* A broken link was removed in the [Compiler Core](https://docs.pennylane.ai/projects/catalyst/en/stable/modules/mlir.html) documentation page. The link referred to where precompiled decomposition rules were implemented, which has since been refactored. From 387e1e34d4b5f23274c3990a6f064a1ca2023991 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Thu, 23 Jul 2026 09:49:38 -0400 Subject: [PATCH 12/20] Remove collect-dev-package action from build-nightly-release Not needed, it was just downloading and re-uploading the package --- .github/workflows/build-nightly-release.yaml | 25 -------------------- 1 file changed, 25 deletions(-) diff --git a/.github/workflows/build-nightly-release.yaml b/.github/workflows/build-nightly-release.yaml index 2dce29c93b..5017d96691 100644 --- a/.github/workflows/build-nightly-release.yaml +++ b/.github/workflows/build-nightly-release.yaml @@ -91,28 +91,3 @@ jobs: repository-url: https://test.pypi.org/legacy/ packages-dir: dist verbose: true - - collect-dev-package: - name: Collect catalyst-dev archives - if: ${{ !failure() && !cancelled() }} # needed in case linux-aarch is skipped - needs: [linux-x86, macos-arm, linux-aarch] - runs-on: ubuntu-24.04 - - steps: - - name: Download catalyst-dev archives - uses: actions/download-artifact@v4 - with: - pattern: catalyst-dev* - merge-multiple: true - path: catalyst-dev - - - name: List collected archives - run: ls -lh catalyst-dev* - - - name: Upload combined catalyst-dev archives - uses: actions/upload-artifact@v4 - with: - name: catalyst-dev-archives - path: catalyst-dev/ - retention-days: 14 - if-no-files-found: error From 316aca03e63065908ca735d0f78af0af77d93a5a Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Thu, 23 Jul 2026 10:01:52 -0400 Subject: [PATCH 13/20] Use LLVM_INSTALL_STAGING_DIR for CMAKE_INSTALL_PREFIX --- mlir/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlir/Makefile b/mlir/Makefile index 964e461eeb..1bf24546c0 100644 --- a/mlir/Makefile +++ b/mlir/Makefile @@ -90,7 +90,7 @@ llvm: -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ -DLLVM_INSTALL_UTILS=ON \ -DLLVM_DISTRIBUTION_COMPONENTS=$(LLVM_DISTRIBUTION_COMPONENTS) \ - -DCMAKE_INSTALL_PREFIX=$(LLVM_BUILD_DIR)/install \ + -DCMAKE_INSTALL_PREFIX=$(LLVM_INSTALL_STAGING_DIR) \ -DPython_EXECUTABLE=$(PYTHON) \ -DPython3_EXECUTABLE=$(PYTHON) \ -DPython3_NumPy_INCLUDE_DIRS=$$($(PYTHON) -c "import numpy as np; print(np.get_include())") \ From 5665e2945b907f62c10d9499566894a4fe53e6ab Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Thu, 23 Jul 2026 13:55:12 -0400 Subject: [PATCH 14/20] [no ci] Add CPACK_PACKAGE_VENDOR and CPACK_RESOURCE_FILE_LICENSE --- mlir/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index 69a88b8a44..32fb77cd06 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -358,6 +358,8 @@ install(DIRECTORY "${STABLEHLO_BUILD_DIR}/lib/" set(CPACK_PACKAGE_NAME "catalyst-dev") set(CPACK_PACKAGE_VERSION "${CATALYST_PACKAGE_VERSION}") +set(CPACK_PACKAGE_VENDOR "Xanadu Quantum Technologies Inc.") +set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE") set(CPACK_GENERATOR "TGZ") set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}_${CATALYST_PACKAGE_VERSION}") set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) From cc7bcdda0e52eef356885a8a0963fb46df14e157 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Thu, 23 Jul 2026 15:05:23 -0400 Subject: [PATCH 15/20] [no ci] Remove changelog entry --- doc/releases/changelog-dev.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 3549f1b17e..35bb08012e 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -445,11 +445,6 @@ `-stage` naming convention used when invoking them from the command line (e.g. `quantum-compilation-stage`). [#3002](https://github.com/PennyLaneAI/catalyst/pull/3002) -* New build configurations have been added to allow building "development" packages of Catalyst and - LLVM/MLIR. These dev packages will allow Catalyst plugin developers to build against the pre-built - libraries included therein, rather than having to build Catalyst and its dependencies from source. - [#3023](https://github.com/PennyLaneAI/catalyst/pull/3023) -

Documentation 📝

* A broken link was removed in the [Compiler Core](https://docs.pennylane.ai/projects/catalyst/en/stable/modules/mlir.html) documentation page. The link referred to where precompiled decomposition rules were implemented, which has since been refactored. From be3ebce9ff4d1699aadc1b8e3568c1fdfe86119e Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Thu, 23 Jul 2026 15:22:20 -0400 Subject: [PATCH 16/20] Move `set(_shlo_libs)` into `if(NOT TARGET ExternalStablehloLib)` guard --- mlir/cmake/modules/CatalystConfig.cmake.in | 8 +++++--- mlir/cmake/modules/CatalystConfig.install.cmake.in | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mlir/cmake/modules/CatalystConfig.cmake.in b/mlir/cmake/modules/CatalystConfig.cmake.in index daa10ccb16..cc91747c88 100644 --- a/mlir/cmake/modules/CatalystConfig.cmake.in +++ b/mlir/cmake/modules/CatalystConfig.cmake.in @@ -24,14 +24,16 @@ set(CATALYST_INCLUDE_DIRS "@CATALYST_CONFIG_INCLUDE_DIRS@") @CATALYST_CONFIG_INCLUDE_EXPORTS@ # --- rebuild ExternalStablehloLib for build-tree consumers --- -set(_shlo_libs ChloCAPI ChloOps StablehloAssemblyFormat StablehloBase +if(NOT TARGET ExternalStablehloLib) + add_library(ExternalStablehloLib INTERFACE IMPORTED) + + set(_shlo_libs ChloCAPI ChloOps StablehloAssemblyFormat StablehloBase StablehloBroadcastUtils StablehloBroadcastLowering StablehloCAPI StablehloLinalgTransforms StablehloOps StablehloOptimizationPasses StablehloPasses StablehloPassUtils StablehloRegister StablehloTypeConversion StablehloTypeInference Version VhloCAPI VhloOps VhloTypes) -if(NOT TARGET ExternalStablehloLib) - add_library(ExternalStablehloLib INTERFACE IMPORTED) + foreach(_l IN LISTS _shlo_libs) if(NOT TARGET ${_l}) add_library(${_l} STATIC IMPORTED) diff --git a/mlir/cmake/modules/CatalystConfig.install.cmake.in b/mlir/cmake/modules/CatalystConfig.install.cmake.in index f77f3230c7..4779313b3c 100644 --- a/mlir/cmake/modules/CatalystConfig.install.cmake.in +++ b/mlir/cmake/modules/CatalystConfig.install.cmake.in @@ -7,14 +7,16 @@ set_and_check(CATALYST_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") set_and_check(CATALYST_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") # Reconstruct the bundled StableHLO interface target. -set(_shlo_libs ChloCAPI ChloOps StablehloAssemblyFormat StablehloBase +if(NOT TARGET ExternalStablehloLib) + add_library(ExternalStablehloLib INTERFACE IMPORTED) + + set(_shlo_libs ChloCAPI ChloOps StablehloAssemblyFormat StablehloBase StablehloBroadcastUtils StablehloBroadcastLowering StablehloCAPI StablehloLinalgTransforms StablehloOps StablehloOptimizationPasses StablehloPasses StablehloPassUtils StablehloRegister StablehloTypeConversion StablehloTypeInference Version VhloCAPI VhloOps VhloTypes) -if(NOT TARGET ExternalStablehloLib) - add_library(ExternalStablehloLib INTERFACE IMPORTED) + foreach(_l IN LISTS _shlo_libs) if(NOT TARGET ${_l}) add_library(${_l} STATIC IMPORTED) From 981c13701d47742365b833b9d0e7a8fc0b666cc6 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Thu, 23 Jul 2026 15:49:32 -0400 Subject: [PATCH 17/20] Read Catalyst version using Python Rather than parsing from Python source file with regex. --- mlir/cmake/modules/CMakeLists.txt | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/mlir/cmake/modules/CMakeLists.txt b/mlir/cmake/modules/CMakeLists.txt index c77b00a906..c3fac05a45 100644 --- a/mlir/cmake/modules/CMakeLists.txt +++ b/mlir/cmake/modules/CMakeLists.txt @@ -53,9 +53,30 @@ include(GNUInstallDirs) include(CMakePackageConfigHelpers) # --- version string, reused from frontend/catalyst/_version.py --- -file(READ "${PROJECT_SOURCE_DIR}/../frontend/catalyst/_version.py" _ver_py) -string(REGEX MATCH "__version__ = \"([^\"]+)\"" _m "${_ver_py}") -set(CATALYST_PACKAGE_VERSION "${CMAKE_MATCH_1}" CACHE INTERNAL "Catalyst version") +find_package(Python3 REQUIRED COMPONENTS Interpreter) + +execute_process( + COMMAND + ${Python3_EXECUTABLE} -c + "import sys; \ + sys.path.append('${PROJECT_SOURCE_DIR}/../frontend/catalyst'); \ + from _version import __version__; \ + print(__version__)" + OUTPUT_VARIABLE CATALYST_PACKAGE_VERSION + ERROR_VARIABLE PARSE_CATALYST_VERSION_ERRORS + RESULT_VARIABLE PARSE_CATALYST_VERSION_RETURN_CODE + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +if(NOT PARSE_CATALYST_VERSION_RETURN_CODE EQUAL 0) + message(FATAL_ERROR + "Failed to read Catalyst package version from file \ + ${PROJECT_SOURCE_DIR}/../frontend/catalyst/_version.py: \ + ${PARSE_CATALYST_VERSION_ERRORS}" + ) +endif() + +message(STATUS "Found Catalyst package version: ${CATALYST_PACKAGE_VERSION}") string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" CATALYST_NUMERIC_VERSION "${CATALYST_PACKAGE_VERSION}") From 836f57bd435b23ed70f21440f7a633a46db330e9 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Thu, 23 Jul 2026 17:05:47 -0400 Subject: [PATCH 18/20] Add workflow pack-mlir-dev.yaml --- .github/workflows/pack-mlir-dev.yaml | 158 +++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 .github/workflows/pack-mlir-dev.yaml diff --git a/.github/workflows/pack-mlir-dev.yaml b/.github/workflows/pack-mlir-dev.yaml new file mode 100644 index 0000000000..6fe29e5ade --- /dev/null +++ b/.github/workflows/pack-mlir-dev.yaml @@ -0,0 +1,158 @@ +name: Package catalyst-mlir-dev (manual) + +# Manual-only: no schedule, no push/PR triggers. Runs solely via the +# "Run workflow" button in the Actions tab (or `gh workflow run`). +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + linux-x86-64: + strategy: + fail-fast: false + matrix: + python_version: ["3.12"] + container_img: ["manylinux_2_28_x86_64"] + + name: Pack catalyst-mlir-dev (Linux x86_64) + runs-on: ubuntu-24.04 + container: quay.io/pypa/${{ matrix.container_img }} + + steps: + - name: Checkout Catalyst repo + uses: actions/checkout@v4 + + - name: Install dependencies (AlmaLinux) + run: | + # Reduce wait time for repos not responding + cat /etc/dnf.conf | sed "s/\[main\]/\[main\]\ntimeout=5/g" > /etc/dnf.conf + dnf update -y && dnf install -y openmpi-devel libzstd-devel gcc-toolset-13 + # Update env vars valid for all tasks of this job + echo '/opt/rh/gcc-toolset-13/root/usr/bin' >> $GITHUB_PATH + + - name: Install Dependencies (Python) + run: | + python${{ matrix.python_version }} -m pip install numpy "nanobind<2.13" pybind11 PyYAML cmake ninja + # Add cmake and ninja to the PATH env var + PYTHON_BINS=$(find /opt/_internal/cpython-${{ matrix.python_version }}.*/bin -maxdepth 1 -type d | tr '\n' ':' | sed 's/:$//') + echo $PYTHON_BINS >> $GITHUB_PATH + + - name: Read pinned LLVM version + id: llvm + run: echo "version=$(grep llvm .dep-versions | awk -F '=' '{ print $2 }')" >> $GITHUB_OUTPUT + + - name: Get Cached LLVM Source + id: cache-llvm-source + uses: actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/mlir/llvm-project + key: llvm-${{ steps.llvm.outputs.version }}-container-source + enableCrossOsArchive: True + fail-on-cache-miss: True + + - name: Get Cached LLVM Build + id: cache-llvm-build + uses: actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/llvm-build + key: ${{ matrix.container_img }}-llvm-${{ steps.llvm.outputs.version }}-${{ matrix.python_version }}-wheel-build + fail-on-cache-miss: True + + - name: Build and pack catalyst-mlir-dev + run: | + LLVM_BUILD_DIR="$GITHUB_WORKSPACE/llvm-build" \ + make -C mlir pack-mlir-dev + + - name: Locate the archive + id: archive + run: | + path=$(find $GITHUB_WORKSPACE/mlir -name 'catalyst-mlir-dev*.tar.gz' | head -n1) + echo "path=$path" >> $GITHUB_OUTPUT + echo "name=$(basename "$path")" >> $GITHUB_OUTPUT + ls -lh "$path" + + - name: Upload catalyst-mlir-dev archive + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.archive.outputs.name }} + path: ${{ steps.archive.outputs.path }} + retention-days: 14 + if-no-files-found: error + + macos-arm64: + strategy: + fail-fast: false + matrix: + python_version: ["3.12"] + + name: Pack catalyst-mlir-dev (macOS arm64) + runs-on: macos-15 + + steps: + - name: Checkout Catalyst repo + uses: actions/checkout@v4 + + - name: Setup Python version + # There are multiple Python versions installed on the GitHub image, 3.12 - 3.14 is already + # available under /Library/Frameworks/Python.framework/Versions/, but homebrew also provides + # 3.12 - 3.14. Make sure to consistently use the system versions. + run: | + echo /Library/Frameworks/Python.framework/Versions/${{ matrix.python_version }}/bin >> $GITHUB_PATH + + # CMake four has dropped compatibility for CMake 3.5, which is the minimum specified by the + # LAPACKE reference implementation. TODO: Look into how to upgrade beyond this limit. + - name: Install Dependencies (Python) + run: | + python${{ matrix.python_version }} -m pip install numpy "nanobind<2.13" pybind11 PyYAML ninja delocate + python${{ matrix.python_version }} -m pip install cmake'<4' + + - name: Read pinned LLVM version + id: llvm + run: echo "version=$(grep llvm .dep-versions | awk -F '=' '{ print $2 }')" >> $GITHUB_OUTPUT + + - name: Get Cached LLVM Source + id: cache-llvm-source + uses: actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/mlir/llvm-project + key: llvm-${{ steps.llvm.outputs.version }}-default-source + enableCrossOsArchive: True + fail-on-cache-miss: True + + - name: Get Cached LLVM Build + id: cache-llvm-build + uses: actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/llvm-build + key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ steps.llvm.outputs.version }}-${{ matrix.python_version }}-wheel-build + fail-on-cache-miss: True + + - name: Clone LLVM submodule at pinned commit + uses: actions/checkout@v4 + with: + repository: llvm/llvm-project + ref: ${{ steps.llvm.outputs.version }} + path: mlir/llvm-project + + - name: Build and pack catalyst-mlir-dev + run: | + LLVM_BUILD_DIR="$GITHUB_WORKSPACE/llvm-build" \ + make -C mlir pack-mlir-dev + + - name: Locate the archive + id: archive + run: | + path=$(find $GITHUB_WORKSPACE/mlir -name 'catalyst-mlir-dev*.tar.gz' | head -n1) + echo "path=$path" >> $GITHUB_OUTPUT + echo "name=$(basename "$path")" >> $GITHUB_OUTPUT + ls -lh "$path" + + - name: Upload catalyst-mlir-dev archive + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.archive.outputs.name }} + path: ${{ steps.archive.outputs.path }} + retention-days: 14 + if-no-files-found: error From 92c90fb3385028cfb8170614188440ee0e2a8bbd Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Fri, 24 Jul 2026 10:35:47 -0400 Subject: [PATCH 19/20] Remove nanobind upper bound from workflows --- .github/workflows/pack-mlir-dev.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pack-mlir-dev.yaml b/.github/workflows/pack-mlir-dev.yaml index 6fe29e5ade..5664be1c6a 100644 --- a/.github/workflows/pack-mlir-dev.yaml +++ b/.github/workflows/pack-mlir-dev.yaml @@ -34,7 +34,7 @@ jobs: - name: Install Dependencies (Python) run: | - python${{ matrix.python_version }} -m pip install numpy "nanobind<2.13" pybind11 PyYAML cmake ninja + python${{ matrix.python_version }} -m pip install numpy nanobind pybind11 PyYAML cmake ninja # Add cmake and ninja to the PATH env var PYTHON_BINS=$(find /opt/_internal/cpython-${{ matrix.python_version }}.*/bin -maxdepth 1 -type d | tr '\n' ':' | sed 's/:$//') echo $PYTHON_BINS >> $GITHUB_PATH @@ -105,7 +105,7 @@ jobs: # LAPACKE reference implementation. TODO: Look into how to upgrade beyond this limit. - name: Install Dependencies (Python) run: | - python${{ matrix.python_version }} -m pip install numpy "nanobind<2.13" pybind11 PyYAML ninja delocate + python${{ matrix.python_version }} -m pip install numpy nanobind pybind11 PyYAML ninja delocate python${{ matrix.python_version }} -m pip install cmake'<4' - name: Read pinned LLVM version From 0f073cbeee72a6c5825fd8165bf594474922c634 Mon Sep 17 00:00:00 2001 From: Joey Carter Date: Fri, 24 Jul 2026 10:36:08 -0400 Subject: [PATCH 20/20] Manually package archive in workflow rather than using make rule The make rule depends on `make llvm` and risks rebuilding llvm from source if CMake cache is off. --- .github/workflows/pack-mlir-dev.yaml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pack-mlir-dev.yaml b/.github/workflows/pack-mlir-dev.yaml index 5664be1c6a..76b9d0e548 100644 --- a/.github/workflows/pack-mlir-dev.yaml +++ b/.github/workflows/pack-mlir-dev.yaml @@ -62,13 +62,20 @@ jobs: - name: Build and pack catalyst-mlir-dev run: | - LLVM_BUILD_DIR="$GITHUB_WORKSPACE/llvm-build" \ - make -C mlir pack-mlir-dev + LLVM_BUILD_DIR="${GITHUB_WORKSPACE}/llvm-build" \ + LLVM_INSTALL_STAGING_DIR="${LLVM_BUILD_DIR}/install" \ + DESTDIR=${LLVM_INSTALL_STAGING_DIR} cmake --build ${LLVM_BUILD_DIR} --target install-distribution + + LLVM_VERSION=$(${LLVM_INSTALL_STAGING_DIR}/bin/llvm-config --version) \ + LLVM_COMMIT=$(grep llvm ${GITHUB_WORKSPACE}/.dep-versions | awk -F '=' '{ print $$2 }' | cut -c1-8) \ + LLVM_VERSION_FULL="${LLVM_VERSION}-${LLVM_COMMIT}" + tar -czf catalyst-mlir-dev_$(uname -s)_$(uname -m)_${LLVM_VERSION_FULL}.tar.gz + -C ${LLVM_INSTALL_STAGING_DIR} bin lib include - name: Locate the archive id: archive run: | - path=$(find $GITHUB_WORKSPACE/mlir -name 'catalyst-mlir-dev*.tar.gz' | head -n1) + path=$(find $GITHUB_WORKSPACE -name 'catalyst-mlir-dev*.tar.gz' | head -n1) echo "path=$path" >> $GITHUB_OUTPUT echo "name=$(basename "$path")" >> $GITHUB_OUTPUT ls -lh "$path" @@ -138,13 +145,20 @@ jobs: - name: Build and pack catalyst-mlir-dev run: | - LLVM_BUILD_DIR="$GITHUB_WORKSPACE/llvm-build" \ - make -C mlir pack-mlir-dev + LLVM_BUILD_DIR="${GITHUB_WORKSPACE}/llvm-build" \ + LLVM_INSTALL_STAGING_DIR="${LLVM_BUILD_DIR}/install" \ + DESTDIR=${LLVM_INSTALL_STAGING_DIR} cmake --build ${LLVM_BUILD_DIR} --target install-distribution + + LLVM_VERSION=$(${LLVM_INSTALL_STAGING_DIR}/bin/llvm-config --version) \ + LLVM_COMMIT=$(grep llvm ${GITHUB_WORKSPACE}/.dep-versions | awk -F '=' '{ print $$2 }' | cut -c1-8) \ + LLVM_VERSION_FULL="${LLVM_VERSION}-${LLVM_COMMIT}" + tar -czf catalyst-mlir-dev_$(uname -s)_$(uname -m)_${LLVM_VERSION_FULL}.tar.gz + -C ${LLVM_INSTALL_STAGING_DIR} bin lib include - name: Locate the archive id: archive run: | - path=$(find $GITHUB_WORKSPACE/mlir -name 'catalyst-mlir-dev*.tar.gz' | head -n1) + path=$(find $GITHUB_WORKSPACE -name 'catalyst-mlir-dev*.tar.gz' | head -n1) echo "path=$path" >> $GITHUB_OUTPUT echo "name=$(basename "$path")" >> $GITHUB_OUTPUT ls -lh "$path"