Skip to content

Commit

Permalink
Use local MLIR directory instead of network MLIR sources (#1498)
Browse files Browse the repository at this point in the history
**Context:** CI has network issues.

**Description of the Change:** Use the cache instead of network files.

**Benefits:** No CI network issues.

**Possible Drawbacks:** runtime now depends on LLVM Source (Not really a
drawback since it always depended on these other files)

**Related GitHub Issues:**

[sc-83639]
  • Loading branch information
erick-xanadu authored Feb 6, 2025
1 parent 67c530b commit 910ce27
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-wheel-linux-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$GITHUB_WORKSPACE/runtime-build/lib" \
-DPython_EXECUTABLE=$(which python${{ matrix.python_version }}) \
-DENABLE_OPENQASM=ON
-DENABLE_OPENQASM=ON \
-DMLIR_INCLUDE_DIRS="$GITHUB_WORKSPACE/mlir/llvm-project/mlir/include"
cmake --build $GITHUB_WORKSPACE/runtime-build --target rt_capi rtd_openqasm rtd_null_qubit
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-wheel-macos-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$GITHUB_WORKSPACE/runtime-build/lib" \
-DPython_EXECUTABLE=$(which python${{ matrix.python_version }}) \
-DENABLE_OPENQASM=ON
-DENABLE_OPENQASM=ON \
-DMLIR_INCLUDE_DIRS="$GITHUB_WORKSPACE/mlir/llvm-project/mlir/include"
cmake --build $GITHUB_WORKSPACE/runtime-build --target rt_capi rtd_openqasm rtd_null_qubit
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-wheel-macos-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$GITHUB_WORKSPACE/runtime-build/lib" \
-DPython_EXECUTABLE=$(which python${{ matrix.python_version }}) \
-DENABLE_OPENQASM=ON
-DENABLE_OPENQASM=ON \
-DMLIR_INCLUDE_DIRS="$GITHUB_WORKSPACE/mlir/llvm-project/mlir/include"
cmake --build $GITHUB_WORKSPACE/runtime-build --target rt_capi rtd_openqasm rtd_null_qubit
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/check-catalyst.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,22 @@ jobs:
sudo apt-get -y -q install ninja-build make cmake clang libomp-dev
python3 -m pip install nanobind pybind11
- name: Get Cached LLVM Source
id: cache-llvm-source
uses: actions/cache@v4
with:
path: mlir/llvm-project
key: llvm-${{ needs.constants.outputs.llvm_version }}-default-source
enableCrossOsArchive: true
fail-on-cache-miss: true

- name: Build Catalyst-Runtime
run: |
COMPILER_LAUNCHER="" \
C_COMPILER=$(which ${{ needs.constants.outputs[format('c_compiler.{0}', matrix.compiler)] }}) \
CXX_COMPILER=$(which ${{ needs.constants.outputs[format('cxx_compiler.{0}', matrix.compiler)] }}) \
RT_BUILD_DIR="$(pwd)/runtime-build" \
LLVM_DIR="$(pwd)/mlir/llvm-project" \
ENABLE_ASAN=OFF \
make runtime
Expand All @@ -63,9 +73,11 @@ jobs:
CXX_COMPILER=$(which ${{ needs.constants.outputs[format('cxx_compiler.{0}', matrix.compiler)] }}) \
RT_BUILD_DIR="$(pwd)/runtime-build" \
OQC_BUILD_DIR="$(pwd)/oqc-build" \
LLVM_DIR="$(pwd)/mlir/llvm-project" \
make oqc
OQD_BUILD_DIR="$(pwd)/oqd-build" \
LLVM_DIR="$(pwd)/mlir/llvm-project" \
make oqd
- name: Upload Catalyst-Runtime Artifact
Expand Down Expand Up @@ -680,11 +692,21 @@ jobs:
pip install numpy pybind11 amazon-braket-sdk
echo "AWS_DEFAULT_REGION=us-east-1" >> $GITHUB_ENV
- name: Get Cached LLVM Source
id: cache-llvm-source
uses: actions/cache@v4
with:
path: mlir/llvm-project
key: llvm-${{ needs.constants.outputs.llvm_version }}-default-source
enableCrossOsArchive: true
fail-on-cache-miss: true

- name: Run the main runtime test suite for coverage
run: |
C_COMPILER=$(which gcc) \
CXX_COMPILER=$(which g++) \
COMPILER_LAUNCHER="" \
LLVM_DIR="$(pwd)/mlir/llvm-project" \
make coverage-runtime
mv runtime/build_cov/coverage.info coverage-${{ github.job }}.info
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scripts/linux_arm64/rh8/build_catalyst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ cmake -S runtime -B runtime-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=runtime-build/lib \
-DPython_EXECUTABLE=${PYTHON} \
-DENABLE_OPENQASM=ON
-DENABLE_OPENQASM=ON \
-DMLIR_INCLUDE_DIRS="/catalyst/mlir/llvm-project/mlir/include"
cmake --build runtime-build --target rt_capi rtd_openqasm rtd_null_qubit

# Build OQC
Expand Down
22 changes: 1 addition & 21 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,6 @@ string(REGEX MATCH "llvm=([0-9a-f]+)" _ ${DEPENDENCY_VERSIONS})
set(LLVM_HASH ${CMAKE_MATCH_1})
message(STATUS "Detected LLVM version - ${LLVM_HASH}")

FetchContent_Declare(
MLIRRunnerUtils
URL https://raw.githubusercontent.com/llvm/llvm-project/${LLVM_HASH}/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
DOWNLOAD_NO_EXTRACT True
SOURCE_DIR mlir/ExecutionEngine
)

FetchContent_Declare(
MLIRCRunnerUtils
URL https://raw.githubusercontent.com/llvm/llvm-project/${LLVM_HASH}/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
DOWNLOAD_NO_EXTRACT True
SOURCE_DIR mlir/ExecutionEngine
)

FetchContent_Declare(
MLIRFloat16Bits
URL https://raw.githubusercontent.com/llvm/llvm-project/${LLVM_HASH}/mlir/include/mlir/ExecutionEngine/Float16bits.h
DOWNLOAD_NO_EXTRACT True
SOURCE_DIR mlir/ExecutionEngine
)

# Note on pybind11 vs python discovery order:
# If Python is looked for first, then we have to look for all the components needed by pybind11.
# In particular, if pybind11::embed is used, then we need to find both headers (Development.Module)
Expand Down Expand Up @@ -93,6 +72,7 @@ target_link_libraries(catalyst_qir_runtime INTERFACE ${devices_list} rt_capi)
target_include_directories(catalyst_qir_runtime INTERFACE
${runtime_includes}
${backend_includes}
${MLIR_INCLUDE_DIRS}
)

if(ENABLE_CODE_COVERAGE)
Expand Down
2 changes: 2 additions & 0 deletions runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CODE_COVERAGE?=OFF
BUILD_TYPE?=RelWithDebInfo
ENABLE_OPENQASM?=ON
ENABLE_ASAN?=OFF
LLVM_DIR?=$(MK_DIR)/../mlir/llvm-project/

BUILD_TARGETS := rt_capi rtd_null_qubit
TEST_TARGETS := runner_tests_qir_runtime
Expand Down Expand Up @@ -43,6 +44,7 @@ configure:
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$(RT_BUILD_DIR)/lib \
-DCMAKE_C_COMPILER=$(C_COMPILER) \
-DMLIR_INCLUDE_DIRS=$(LLVM_DIR)/mlir/include \
-DCMAKE_CXX_COMPILER=$(CXX_COMPILER) \
-DCMAKE_C_COMPILER_LAUNCHER=$(COMPILER_LAUNCHER) \
-DCMAKE_CXX_COMPILER_LAUNCHER=$(COMPILER_LAUNCHER) \
Expand Down
7 changes: 1 addition & 6 deletions runtime/lib/capi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

add_library(catalyst_qir_qis_obj OBJECT RuntimeCAPI.cpp)

# include external MLIR runner utils
FetchContent_MakeAvailable(MLIRRunnerUtils)
FetchContent_MakeAvailable(MLIRCRunnerUtils)
FetchContent_MakeAvailable(MLIRFloat16Bits)

# link to rt_backend
target_link_libraries(catalyst_qir_qis_obj ${CMAKE_DL_LIBS})

Expand All @@ -20,7 +15,7 @@ target_link_libraries(catalyst_qir_qis_obj
target_include_directories(catalyst_qir_qis_obj PUBLIC .
${CMAKE_CURRENT_SOURCE_DIR}
${runtime_includes}
${mlirrunnerutils_SOURCE_DIR}/../.. # includes are relative to mlir/ExecutionEngine
${MLIR_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/../mlir/lib/Driver # Timer.hpp
)

Expand Down

0 comments on commit 910ce27

Please sign in to comment.