Skip to content

Commit 7cab56d

Browse files
authored
Use PyTorch cache key in extra-cache-key action field for dependency installation (#5318)
Now the PyTorch dependency cache depends on the PyTorch cache itself, not just its version, which should fix the situation when an old/incompatible cache is used. This should fix `RuntimeError: operator torchvision::nms does not exist` error. E2E accuracy CI: https://github.com/intel/intel-xpu-backend-for-triton/actions/runs/18529650669 (`Install torchvision package` step works now) Signed-off-by: Anatoly Myachev <[email protected]>
1 parent 2421984 commit 7cab56d

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
cache:
2323
description: Cache enabled or disabled
2424
default: enabled
25+
outputs:
26+
pytorch_cache_key:
27+
description: "PyTorch cache key"
28+
value: ${{ steps.generate-pytorch-cache-key.outputs.pytorch_cache_key }}
2529
runs:
2630
using: "composite"
2731
steps:
@@ -70,22 +74,24 @@ runs:
7074
sudo ln -sfT ${{ inputs.oneapi }} /opt/intel/oneapi
7175
7276
- name: Generate PyTorch cache key
77+
id: generate-pytorch-cache-key
7378
shell: bash
79+
env:
80+
# Increase this value to reset cache
81+
CACHE_NUMBER: 18
7482
run: |
7583
ONEAPI_LINK=$(readlink /opt/intel/oneapi || true)
7684
ONEAPI_KEY=$(sha256sum /opt/intel/installed.txt 2> /dev/null | cut -d\ -f1 || true)
7785
PYTORCH_CACHE_KEY=$(echo $PYTHON_VERSION $PYTORCH_COMMIT_ID ${{ hashFiles('scripts/patch-pytorch.sh') }} ${{ inputs.mode }}${ONEAPI_KEY}${ONEAPI_LINK} | sha256sum - | cut -d\ -f1)
7886
echo "PYTORCH_CACHE_KEY=$PYTORCH_CACHE_KEY" | tee -a "$GITHUB_ENV"
87+
echo "pytorch_cache_key=pytorch-$PYTORCH_CACHE_KEY-$CACHE_NUMBER" >> "$GITHUB_OUTPUT"
7988
8089
- name: Load PyTorch from a cache
8190
id: pytorch-cache
8291
uses: ./.github/actions/load
83-
env:
84-
# Increase this value to reset cache
85-
CACHE_NUMBER: 18
8692
with:
8793
path: pytorch
88-
key: pytorch-$PYTORCH_CACHE_KEY-$CACHE_NUMBER
94+
key: ${{ steps.generate-pytorch-cache-key.outputs.pytorch_cache_key }}
8995
enabled: ${{ inputs.cache == 'enabled' }}
9096

9197
- name: Clone PyTorch repository

.github/workflows/e2e-reusable.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ jobs:
9292
pip install wheel 'cmake<4.0.0'
9393
9494
- name: Setup PyTorch
95+
id: setup-pytorch
9596
uses: ./.github/actions/setup-pytorch
9697
with:
9798
ref: ${{ inputs.pytorch_ref }}
@@ -151,7 +152,7 @@ jobs:
151152
package: torchvision
152153
repository: pytorch/vision
153154
ref: ${{ env.TORCHVISION_COMMIT_ID }}
154-
extra-cache-key: ${{ env.PYTORCH_VERSION }}
155+
extra-cache-key: ${{ steps.setup-pytorch.outputs.pytorch_cache_key }}
155156

156157
- name: Install torchaudio package
157158
if: ${{ inputs.suite == 'torchbench' }}
@@ -160,7 +161,7 @@ jobs:
160161
package: torchaudio
161162
repository: pytorch/audio
162163
ref: ${{ env.TORCHAUDIO_COMMIT_ID }}
163-
extra-cache-key: ${{ env.PYTORCH_VERSION }}
164+
extra-cache-key: ${{ steps.setup-pytorch.outputs.pytorch_cache_key }}
164165

165166
- name: Install timm package
166167
if: ${{ inputs.suite == 'timm_models' || inputs.suite == 'torchbench' }}
@@ -169,7 +170,7 @@ jobs:
169170
package: timm
170171
repository: huggingface/pytorch-image-models
171172
ref: ${{ env.TIMM_COMMIT_ID }}
172-
extra-cache-key: ${{ env.PYTORCH_VERSION }}
173+
extra-cache-key: ${{ steps.setup-pytorch.outputs.pytorch_cache_key }}
173174

174175
- name: Clone pytorch benchmark
175176
if: ${{ inputs.suite == 'torchbench' }}

.github/workflows/nightly-wheels.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
pip install wheel cmake
5858
5959
- name: Setup PyTorch
60+
id: setup-pytorch
6061
uses: ./.github/actions/setup-pytorch
6162

6263
- name: Identify pinned versions
@@ -83,23 +84,23 @@ jobs:
8384
package: torchvision
8485
repository: pytorch/vision
8586
ref: ${{ env.TORCHVISION_COMMIT_ID }}
86-
extra-cache-key: ${{ env.PYTORCH_VERSION }}
87+
extra-cache-key: ${{ steps.setup-pytorch.outputs.pytorch_cache_key }}
8788

8889
- name: Install torchaudio package
8990
uses: ./.github/actions/install-dependency
9091
with:
9192
package: torchaudio
9293
repository: pytorch/audio
9394
ref: ${{ env.TORCHAUDIO_COMMIT_ID }}
94-
extra-cache-key: ${{ env.PYTORCH_VERSION }}
95+
extra-cache-key: ${{ steps.setup-pytorch.outputs.pytorch_cache_key }}
9596

9697
- name: Install timm package
9798
uses: ./.github/actions/install-dependency
9899
with:
99100
package: timm
100101
repository: huggingface/pytorch-image-models
101102
ref: ${{ env.TIMM_COMMIT_ID }}
102-
extra-cache-key: ${{ env.PYTORCH_VERSION }}
103+
extra-cache-key: ${{ steps.setup-pytorch.outputs.pytorch_cache_key }}
103104

104105
- name: Install transformers package
105106
run: |

0 commit comments

Comments
 (0)