Skip to content

Commit 6abfacb

Browse files
authored
Reduce cache usage in workflows (#3053)
Fixes #3052.
1 parent 178d49d commit 6abfacb

File tree

8 files changed

+18
-90
lines changed

8 files changed

+18
-90
lines changed

.github/actions/install-wheels/action.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,7 @@ runs:
4040
echo "${{ inputs.workflow }}: $run_id"
4141
echo "run_id=$run_id" >> $GITHUB_OUTPUT
4242
43-
- name: Load wheels from cache
44-
id: wheels-cache
45-
uses: ./.github/actions/load
46-
env:
47-
# Increase this value to reset cache
48-
CACHE_NUMBER: "1"
49-
with:
50-
path: ~/wheels
51-
key: wheels-py${{ inputs.python_version }}-${{ steps.run_id.outputs.run_id }}-$CACHE_NUMBER
52-
5343
- name: Download wheels from specified workflow run artifacts
54-
if: ${{ steps.wheels-cache.outputs.status == 'miss' }}
5544
shell: bash
5645
env:
5746
GH_TOKEN: ${{ inputs.gh_token }}
@@ -70,10 +59,3 @@ runs:
7059
shopt -s extglob
7160
cd ~/wheels/*-py${{ inputs.python_version }}*
7261
${{ inputs.install_cmd }} ${{ inputs.wheels_pattern }}
73-
74-
- name: Save wheels to cache
75-
if: ${{ steps.wheels-cache.outputs.status == 'miss' }}
76-
uses: ./.github/actions/save
77-
with:
78-
path: ${{ steps.wheels-cache.outputs.path }}
79-
dest: ${{ steps.wheels-cache.outputs.dest }}

.github/actions/load/action.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: load
22
description: Load a directory from a cache based on a shared directory
33
inputs:
44
root:
5-
description:
5+
description: Directory for cache
66
default: /cache
77
path:
88
description: A directory to load from a cache
@@ -12,8 +12,10 @@ inputs:
1212
required: true
1313
symlink:
1414
description: Create a symlink instead of copying from cache
15-
type: bool
16-
default: true
15+
default: "true"
16+
enabled:
17+
description: Enable cache
18+
default: "true"
1719
outputs:
1820
path:
1921
description: A directory to save to a cache
@@ -24,6 +26,7 @@ outputs:
2426
dest:
2527
description: Directory in cache
2628
value: ${{ steps.load.outputs.dest }}
29+
2730
runs:
2831
using: "composite"
2932
steps:
@@ -37,7 +40,7 @@ runs:
3740
echo "Directory ${{ inputs.path }} exists and will not be restored from cache"
3841
exit 1
3942
fi
40-
if [[ -d $ITEM_PATH ]]; then
43+
if [[ ${{ inputs.enabled == 'true' }} && -d $ITEM_PATH ]]; then
4144
echo "Cache hit for ${{ inputs.key }}"
4245
echo "status=hit" >> $GITHUB_OUTPUT
4346
if [[ ${{ inputs.symlink }} == true ]]; then

.github/actions/save/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@ name: save
22
description: Save a directory to a cache based on a shared directory
33
inputs:
44
root:
5-
description:
5+
description: Directory for cache
66
default: /cache
77
path:
88
description: Directory to save to a cache
99
required: true
1010
dest:
1111
description: Directory in cache
1212
required: true
13+
enabled:
14+
description: Enable cache
15+
default: "true"
1316
runs:
1417
using: "composite"
1518
steps:
1619
- name: Save ${{ inputs.path }} to cache
20+
if: ${{ inputs.enabled == 'true' }}
1721
shell: bash
1822
run: |
1923
TEMP_ITEM=$(mktemp -d -p ${{ inputs.root }})

.github/actions/setup-pytorch/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ inputs:
1919
mode:
2020
description: Source or wheels
2121
default: source
22+
cache:
23+
description: Cache enabled or disabled
24+
default: enabled
2225
runs:
2326
using: "composite"
2427
steps:
@@ -83,6 +86,7 @@ runs:
8386
with:
8487
path: pytorch
8588
key: pytorch-$PYTORCH_CACHE_KEY-$CACHE_NUMBER
89+
enabled: ${{ inputs.cache == 'enabled' }}
8690

8791
- name: Clone PyTorch repository
8892
if: ${{ steps.pytorch-cache.outputs.status == 'miss' }}
@@ -138,3 +142,4 @@ runs:
138142
with:
139143
path: ${{ steps.pytorch-cache.outputs.path }}
140144
dest: ${{ steps.pytorch-cache.outputs.dest }}
145+
enabled: ${{ inputs.cache == 'enabled' }}

.github/workflows/conda-test-reusable.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,6 @@ jobs:
7878
- name: Checkout repository
7979
uses: actions/checkout@v4
8080

81-
- name: Load conda cache
82-
id: conda-cache
83-
uses: ./.github/actions/load
84-
env:
85-
CACHE_NUMBER: 7
86-
with:
87-
path: $HOME/miniforge3/envs/triton
88-
key: conda-${{ inputs.env_manager }}-py${{ matrix.python }}-${{ hashFiles('scripts/triton.yml', 'python/pyproject.toml', 'python/setup.py') }}-${{ env.CACHE_NUMBER }}
89-
9081
- name: Install Manager Environment
9182
shell: bash --noprofile --norc -eo pipefail {0}
9283
run: |
@@ -143,13 +134,6 @@ jobs:
143134
run: |
144135
${{ env.TRITON_TEST_CMD }} --inductor --skip-pip-install
145136
146-
- name: Save conda cache
147-
if: steps.conda-cache.outputs.status == 'miss'
148-
uses: ./.github/actions/save
149-
with:
150-
path: ${{ steps.conda-cache.outputs.path }}
151-
dest: ${{ steps.conda-cache.outputs.dest }}
152-
153137
- name: Pass rate
154138
run: |
155139
pip install defusedxml

.github/workflows/inductor-tests-reusable.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ jobs:
4949
- name: Checkout repository
5050
uses: actions/checkout@v4
5151

52-
- name: Load pip cache
53-
id: pip-cache
54-
uses: ./.github/actions/load
55-
with:
56-
path: $HOME/.cache/pip
57-
# pip cache per commit id just to minimize network traffic
58-
key: pip-$PYTHON_VERSION-$GITHUB_SHA
59-
6052
- name: Install Python
6153
uses: actions/setup-python@v5
6254
with:
@@ -66,6 +58,7 @@ jobs:
6658
uses: ./.github/actions/setup-pytorch
6759
with:
6860
ref: ${{ inputs.pytorch_ref }}
61+
cache: disabled
6962

7063
- name: Setup Triton
7164
uses: ./.github/actions/setup-triton
@@ -126,10 +119,3 @@ jobs:
126119
name: logs-${{ env.PYTHON_VERSION }}
127120
path: pytorch/test/test-reports
128121
include-hidden-files: true
129-
130-
- name: Save pip cache
131-
if: ${{ steps.pip-cache.outputs.status == 'miss' }}
132-
uses: ./.github/actions/save
133-
with:
134-
path: ${{ steps.pip-cache.outputs.path }}
135-
dest: ${{ steps.pip-cache.outputs.dest }}

.github/workflows/nightly-wheels.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,34 +70,13 @@ jobs:
7070
run: |
7171
echo "TRITON_COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_ENV
7272
73-
- name: Generate Triton cache key
74-
id: triton-key
75-
run: |
76-
COMPOSITE_KEY=$(echo ${{ matrix.python }} $PYTORCH_VERSION $TRITON_COMMIT_ID | sha256sum - | cut -d\ -f1)
77-
echo "key=triton-$COMPOSITE_KEY" >> $GITHUB_OUTPUT
78-
79-
- name: Load Triton wheels from a cache
80-
id: triton-cache
81-
uses: ./.github/actions/load
82-
with:
83-
path: python/dist
84-
key: ${{ steps.triton-key.outputs.key }}
85-
8673
- name: Build Triton wheels
87-
if: ${{ steps.triton-cache.outputs.status == 'miss' }}
8874
uses: ./.github/actions/setup-triton
8975
with:
9076
command: >
9177
DEBUG=1
9278
python setup.py bdist_wheel && pip install dist/*.whl
9379
94-
- name: Save Triton wheels to a cache
95-
if: ${{ steps.triton-cache.outputs.status == 'miss' }}
96-
uses: ./.github/actions/save
97-
with:
98-
path: ${{ steps.triton-cache.outputs.path }}
99-
dest: ${{ steps.triton-cache.outputs.dest }}
100-
10180
- name: Install torchvision package
10281
uses: ./.github/actions/install-dependency
10382
with:

.github/workflows/triton-benchmarks.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@ jobs:
8282
- name: Checkout repository
8383
uses: actions/checkout@v4
8484

85-
- name: Load pip cache
86-
id: pip-cache
87-
uses: ./.github/actions/load
88-
with:
89-
path: $HOME/.cache/pip
90-
# pip cache per commit id just to minimize network traffic
91-
key: pip-$PYTHON_VERSION-$GITHUB_SHA
92-
9385
- name: Install Python
9486
if: ${{ !(inputs.use_pyenv_python || false) }}
9587
uses: actions/setup-python@v5
@@ -273,13 +265,6 @@ jobs:
273265
cd benchmarks/micro_benchmarks
274266
python run_benchmarks.py --reports $REPORTS
275267
276-
- name: Save pip cache
277-
if: ${{ steps.pip-cache.outputs.status == 'miss' }}
278-
uses: ./.github/actions/save
279-
with:
280-
path: ${{ steps.pip-cache.outputs.path }}
281-
dest: ${{ steps.pip-cache.outputs.dest }}
282-
283268
- name: Upload benchmark reports
284269
if: ${{ steps.install.outcome == 'success' && !cancelled() }}
285270
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)