Skip to content

Commit

Permalink
Additional cache improvemnts (#1001)
Browse files Browse the repository at this point in the history
- Only pushes to main will generate a new `ccache` cache entry, while
runs on feature branches will download the latest available cache. The
`ccache` entry on main is always built from scratch. This reduces the
number of caches generated, and makes the `ccache` cache mechanism
slightly more consistent.
- Use the new `lookup-only` flag when we don't actually care about
restoring a cache entry, and only want to test if it exists. Saves time.
- Don't perform a save step when only a restore is required. This saves
time, but also eliminates some bugs like the occasional patches we apply
to dependencies being cached.
- For faster debugging of wheel actions, the cache for each dependency
is now stored immediately after a successful dependency build step,
rather than only storing the cache if all builds were successful.

[sc-70625]
  • Loading branch information
dime10 authored Aug 8, 2024
1 parent 8c570d7 commit 377388b
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 66 deletions.
50 changes: 38 additions & 12 deletions .github/workflows/build-wheel-linux-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,28 @@ jobs:
path: mlir/Enzyme

# Cache external project builds
- name: Cache LLVM Build
- name: Restore LLVM Build
id: cache-llvm-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ matrix.container_name }}-llvm-${{ needs.constants.outputs.llvm_version }}-wheel-build

- name: Cache MHLO Build
- name: Restore MHLO Build
id: cache-mhlo-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ matrix.container_name }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
lookup-only: True

- name: Cache Enzyme Build
- name: Restore Enzyme Build
id: cache-enzyme-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: enzyme-build
key: ${{ matrix.container_name }}-enzyme-${{ needs.constants.outputs.llvm_version }}-${{ needs.constants.outputs.enzyme_version }}-wheel-build
lookup-only: True

- name: Build LLD
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
Expand All @@ -150,6 +152,14 @@ jobs:
-i ${{ matrix.container_img }} \
bash /catalyst/.github/workflows/scripts/linux_arm64/rh8/build_llvm.sh $GCC_VERSION ${{ matrix.python_version.official }} ${{ matrix.python_version.subversion }} ${{ matrix.python_version.package }}
- name: Save LLVM Build
id: save-llvm-build
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: llvm-build
key: ${{ matrix.container_name }}-llvm-${{ needs.constants.outputs.llvm_version }}-wheel-build

- name: Build MHLO Dialect
if: steps.cache-mhlo-build.outputs.cache-hit != 'true'
run: |
Expand All @@ -161,6 +171,14 @@ jobs:
-i ${{ matrix.container_img }} \
bash /catalyst/.github/workflows/scripts/linux_arm64/rh8/build_mhlo.sh $GCC_VERSION ${{ matrix.python_version.official }} ${{ matrix.python_version.subversion }} ${{ matrix.python_version.package }}
- name: Save MHLO Build
id: save-mhlo-build
if: steps.cache-mhlo-build.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: mhlo-build
key: ${{ matrix.container_name }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build

- name: Build Enzyme
if: steps.cache-enzyme-build.outputs.cache-hit != 'true'
run: |
Expand All @@ -172,6 +190,14 @@ jobs:
-i ${{ matrix.container_img }} \
bash /catalyst/.github/workflows/scripts/linux_arm64/rh8/build_enzyme.sh $GCC_VERSION ${{ matrix.python_version.official }} ${{ matrix.python_version.subversion }} ${{ matrix.python_version.package }}
- name: Save Enzyme Build
id: save-enzyme-build
if: steps.cache-enzyme-build.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: enzyme-build
key: ${{ matrix.container_name }}-enzyme-${{ needs.constants.outputs.llvm_version }}-${{ needs.constants.outputs.enzyme_version }}-wheel-build

catalyst-linux-wheels-arm64:
needs: [constants, build-dependencies]
strategy:
Expand Down Expand Up @@ -201,7 +227,7 @@ jobs:

- name: Get Cached LLVM Source
id: cache-llvm-source
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: mlir/llvm-project
key: llvm-${{ needs.constants.outputs.llvm_version }}-default-source
Expand All @@ -210,15 +236,15 @@ jobs:

- name: Get Cached LLVM Build
id: cache-llvm-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ matrix.container_name }}-llvm-${{ needs.constants.outputs.llvm_version }}-wheel-build
fail-on-cache-miss: True

- name: Get Cached MHLO Source
id: cache-mhlo-source
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: mlir/mlir-hlo
key: mhlo-${{ needs.constants.outputs.mhlo_version }}-default-source
Expand All @@ -227,15 +253,15 @@ jobs:

- name: Get Cached MHLO Build
id: cache-mhlo-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ matrix.container_name }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
fail-on-cache-miss: True

- name: Get Cached Enzyme Source
id: cache-enzyme-source
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: mlir/Enzyme
key: enzyme-${{ needs.constants.outputs.enzyme_version }}-default-source
Expand All @@ -244,7 +270,7 @@ jobs:

- name: Get Cached Enzyme Build
id: cache-enzyme-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: enzyme-build
key: ${{ matrix.container_name }}-enzyme-${{ needs.constants.outputs.llvm_version }}-${{ needs.constants.outputs.enzyme_version }}-wheel-build
Expand Down
50 changes: 38 additions & 12 deletions .github/workflows/build-wheel-linux-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,28 @@ jobs:
path: mlir/Enzyme

# Cache external project builds
- name: Cache LLVM Build
- name: Restore LLVM Build
id: cache-llvm-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-${{matrix.python_version}}-wheel-build

- name: Cache MHLO Build
- name: Restore MHLO Build
id: cache-mhlo-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ matrix.container_img }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
lookup-only: True

- name: Cache Enzyme Build
- name: Restore Enzyme Build
id: cache-enzyme-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: enzyme-build
key: ${{ matrix.container_img }}-enzyme-${{ needs.constants.outputs.llvm_version }}-${{ needs.constants.outputs.enzyme_version }}-wheel-build
lookup-only: True

- name: Install dependencies (AlmaLinux)
if: |
Expand Down Expand Up @@ -187,6 +189,14 @@ jobs:
# This tests fails on CI/CD not locally.
LIT_FILTER_OUT="Bytecode" cmake --build llvm-build --target check-mlir
- name: Save LLVM Build
id: save-llvm-build
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: llvm-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-${{matrix.python_version}}-wheel-build

- name: Build MHLO Dialect
if: steps.cache-mhlo-build.outputs.cache-hit != 'true'
# building with LLD is a strong requirement for mhlo
Expand All @@ -209,6 +219,14 @@ jobs:
LIT_FILTER_OUT="chlo_legalize_to_mhlo" cmake --build mhlo-build --target check-mlir-hlo
- name: Save MHLO Build
id: save-mhlo-build
if: steps.cache-mhlo-build.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: mhlo-build
key: ${{ matrix.container_img }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build

- name: Build Enzyme
if: steps.cache-enzyme-build.outputs.cache-hit != 'true'
run: |
Expand All @@ -222,6 +240,14 @@ jobs:
cmake --build enzyme-build --target EnzymeStatic-19
- name: Save Enzyme Build
id: save-enzyme-build
if: steps.cache-enzyme-build.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: enzyme-build
key: ${{ matrix.container_img }}-enzyme-${{ needs.constants.outputs.llvm_version }}-${{ needs.constants.outputs.enzyme_version }}-wheel-build

catalyst-linux-wheels-x86-64:
needs: [constants, build-dependencies, determine_runner]
strategy:
Expand Down Expand Up @@ -255,7 +281,7 @@ jobs:
- name: Get Cached LLVM Source
id: cache-llvm-source
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: mlir/llvm-project
key: llvm-${{ needs.constants.outputs.llvm_version }}-container-source
Expand All @@ -264,15 +290,15 @@ jobs:

- name: Get Cached LLVM Build
id: cache-llvm-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-3.9-wheel-build
fail-on-cache-miss: True

- name: Get Cached MHLO Source
id: cache-mhlo-source
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: mlir/mlir-hlo
key: mhlo-${{ needs.constants.outputs.mhlo_version }}-container-source
Expand All @@ -281,15 +307,15 @@ jobs:

- name: Get Cached MHLO Build
id: cache-mhlo-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ matrix.container_img }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
fail-on-cache-miss: True

- name: Get Cached Enzyme Source
id: cache-enzyme-source
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: mlir/Enzyme
key: enzyme-${{ needs.constants.outputs.enzyme_version }}-container-source
Expand All @@ -298,7 +324,7 @@ jobs:

- name: Get Cached Enzyme Build
id: cache-enzyme-build
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: enzyme-build
key: ${{ matrix.container_img }}-enzyme-${{ needs.constants.outputs.llvm_version }}-${{ needs.constants.outputs.enzyme_version }}-wheel-build
Expand Down
Loading

0 comments on commit 377388b

Please sign in to comment.