Refactor transport local copy #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Check Catalyst GPU | |
| # Runs the runtime transport tests on a GPU host. Modeled after | |
| # https://github.com/PennyLaneAI/pennylane/blob/main/.github/workflows/tests-gpu.yml | |
| # so pull requests are gated by the ``gpu`` label to keep GPU runner time cheap. | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - "runtime/lib/transport/**" | |
| - "runtime/include/Transport*" | |
| - "runtime/tests/Test_Transport*" | |
| - "mlir/lib/Transport/**" | |
| - "mlir/include/Transport/**" | |
| - "frontend/catalyst/backline.py" | |
| - ".github/workflows/check-catalyst-gpu.yaml" | |
| pull_request: | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - ready_for_review | |
| - labeled | |
| paths: | |
| - "runtime/lib/transport/**" | |
| - "runtime/include/Transport*" | |
| - "runtime/tests/Test_Transport*" | |
| - "mlir/lib/Transport/**" | |
| - "mlir/include/Transport/**" | |
| - "frontend/catalyst/backline.py" | |
| - ".github/workflows/check-catalyst-gpu.yaml" | |
| merge_group: | |
| types: | |
| - checks_requested | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: check-catalyst-gpu-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| constants: | |
| name: Set build matrix | |
| uses: ./.github/workflows/constants.yaml | |
| gpu-transport-tests: | |
| name: Runtime transport tests (GPU) | |
| needs: [constants] | |
| runs-on: | |
| - single-gpu-x64 | |
| # Push and merge_group always run; PRs need a non-draft open state and the ``gpu`` label. | |
| if: >- | |
| ${{ | |
| github.event_name == 'push' || | |
| github.event_name == 'merge_group' || | |
| github.event_name == 'workflow_dispatch' || | |
| ( | |
| github.event_name == 'pull_request' && | |
| github.event.pull_request.draft == false && | |
| contains(github.event.pull_request.labels.*.name, 'gpu') && | |
| github.event.pull_request.state == 'open' | |
| ) | |
| }} | |
| steps: | |
| - name: Update PATH and LD_LIBRARY_PATH for CUDA | |
| run: | | |
| echo "/usr/local/cuda/bin" >> $GITHUB_PATH | |
| echo "LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV | |
| - name: Checkout Catalyst repo | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| id: setup_python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ needs.constants.outputs.primary_python_version }} | |
| # The runner is pseudo-ephemeral, so any Python installs go into a per-run venv that we | |
| # clean up in the final step. Matches the pennylane tests-gpu.yml convention. | |
| - name: Set up Python virtual environment | |
| id: setup_venv | |
| env: | |
| VENV_NAME: ${{ github.workspace }}/venv_${{ steps.setup_python.outputs.python-version }}_${{ github.sha }} | |
| run: | | |
| rm -rf venv_* | |
| python -m venv "${VENV_NAME}" | |
| echo "${VENV_NAME}/bin" >> $GITHUB_PATH | |
| echo "venv_name=${VENV_NAME}" >> $GITHUB_OUTPUT | |
| - name: Install Python build dependencies | |
| run: | | |
| python -m pip install --upgrade pip wheel | |
| python -m pip install "cmake>=3.26" ninja "nanobind<2.13" pybind11 numpy PyYAML | |
| cmake --version | |
| - name: Cache 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 | |
| - name: Clone LLVM submodule | |
| if: steps.cache-llvm-source.outputs.cache-hit != 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: llvm/llvm-project | |
| ref: ${{ needs.constants.outputs.llvm_version }} | |
| path: mlir/llvm-project | |
| - name: Set up ccache for the runtime rebuild | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| key: ${{ github.workflow }}-${{ runner.os }}-runtime | |
| max-size: "500M" | |
| # The runtime configure + build only needs LLVM source headers (MLIR_INCLUDE_DIRS | |
| # -> mlir/llvm-project/mlir/include, header-only via rt_capi). No built-LLVM | |
| # artifacts are consumed as long as ENABLE_EXECUTOR stays OFF, which it does here. | |
| # LLVM_BUILD_DIR points at a non-existent path on purpose; nothing reads from it. | |
| - name: Build Catalyst runtime with transport enabled | |
| run: | | |
| COMPILER_LAUNCHER=ccache \ | |
| C_COMPILER=$(which gcc) \ | |
| CXX_COMPILER=$(which g++) \ | |
| RT_BUILD_DIR="$(pwd)/runtime-build" \ | |
| LLVM_DIR="$(pwd)/mlir/llvm-project" \ | |
| LLVM_BUILD_DIR="$(pwd)/llvm-build" \ | |
| ENABLE_TRANSPORT=ON \ | |
| make runtime | |
| - name: Build the memcpy test binary | |
| run: | | |
| cmake --build "$(pwd)/runtime-build" --target runner_tests_transport_memcpy -j | |
| - name: Run memcpy transport tests | |
| run: | | |
| "$(pwd)/runtime-build/tests/runner_tests_transport_memcpy" | |
| - name: Cleanup virtual environment | |
| if: always() | |
| run: | | |
| rm -rf "${{ steps.setup_venv.outputs.venv_name }}" |