Skip to content

Commit bf7a031

Browse files
authored
Install E2E dependencies for Windows (#4496)
Updating reusable actions (cache save/load, install-dependency) to work on Windows. Note there are no actual e2e tests in the workflow. Signed-off-by: Pavel Chekin <[email protected]>
1 parent f4ebd56 commit bf7a031

File tree

5 files changed

+169
-79
lines changed

5 files changed

+169
-79
lines changed

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

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ inputs:
1616
extra-cache-key:
1717
description: Cache key suffix
1818
default: ""
19+
workspace:
20+
description: Workspace directory
21+
default: ""
1922
runs:
2023
using: "composite"
2124
steps:
@@ -30,6 +33,9 @@ runs:
3033
- name: Identify Python version
3134
shell: bash
3235
run: |
36+
if [[ -f .venv/Scripts/activate ]]; then
37+
source .venv/Scripts/activate
38+
fi
3339
if [[ -z "$PYTHON_VERSION" ]]; then
3440
PYTHON_VERSION="$(python -c 'import sys; print(f"{sys.version_info[0]}.{ sys.version_info[1]}")')"
3541
echo "PYTHON_VERSION=$PYTHON_VERSION" >> "$GITHUB_ENV"
@@ -40,46 +46,93 @@ runs:
4046
run: |
4147
DEPENDENCY_CACHE_KEY="${{ inputs.package }}-$PYTHON_VERSION-$(echo ${{ steps.commit-id.outputs.commit_id }} ${{ inputs.extra-cache-key }} | sha256sum - | cut -d\ -f1)"
4248
echo "DEPENDENCY_CACHE_KEY=$DEPENDENCY_CACHE_KEY" | tee -a "$GITHUB_ENV"
49+
if [[ "${{ inputs.workspace }}" ]]; then
50+
echo "PACKAGE_PATH=${{ inputs.workspace }}/${{ inputs.package }}" | tee -a "$GITHUB_ENV"
51+
else
52+
echo "PACKAGE_PATH=${{ inputs.package }}" | tee -a "$GITHUB_ENV"
53+
fi
4354
4455
- name: Try to load package from a cache
4556
id: cache-load
4657
uses: ./.github/actions/load
4758
with:
48-
path: ${{ inputs.package }}-${{ steps.commit-id.outputs.commit_id }}
59+
path: ${{ env.PACKAGE_PATH }}
4960
key: ${{ env.DEPENDENCY_CACHE_KEY }}
5061

5162
- name: Clone package repo
52-
if: ${{ steps.cache-load.outputs.status == 'miss' }}
63+
if: steps.cache-load.outputs.status == 'miss'
5364
uses: actions/checkout@v4
5465
with:
5566
repository: ${{ inputs.repository }}
5667
ref: ${{ steps.commit-id.outputs.commit_id }}
5768
submodules: recursive
58-
path: ${{ inputs.package }}-${{ steps.commit-id.outputs.commit_id }}
69+
path: ${{ inputs.package }}
5970

60-
- name: Build package wheels
61-
if: ${{ steps.cache-load.outputs.status == 'miss' }}
71+
- name: Move package repo to the workspace
72+
if: inputs.workspace != '' && steps.cache-load.outputs.status == 'miss'
73+
shell: bash
74+
run: |
75+
rm -rf ${{ env.PACKAGE_PATH }}
76+
mv -T ${{ inputs.package }} ${{ env.PACKAGE_PATH }}
77+
78+
- name: Build package wheels (Linux)
79+
if: runner.os == 'Linux' && steps.cache-load.outputs.status == 'miss'
6280
shell: bash
6381
run: |
6482
source /opt/intel/oneapi/setvars.sh
65-
cd ${{ inputs.package }}-${{ steps.commit-id.outputs.commit_id }}
83+
84+
cd ${{ env.PACKAGE_PATH }}
6685
if [[ -f setup.py ]]; then
6786
python setup.py bdist_wheel
6887
elif [[ -f pyproject.toml ]]; then
6988
pip install build
7089
python -m build
7190
else
72-
echo "Error: setup.py and pyproject.toml not found"
91+
echo Error: setup.py and pyproject.toml not found
7392
exit 1
7493
fi
7594
76-
- name: Install package wheels
95+
- name: Build package wheels (Windows)
96+
if: runner.os == 'Windows' && steps.cache-load.outputs.status == 'miss'
97+
shell: pwsh
98+
run: |
99+
.venv\Scripts\activate.ps1
100+
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
101+
102+
bash -c "
103+
cd ${{ env.PACKAGE_PATH }}
104+
if [[ -f setup.py ]]; then
105+
python setup.py bdist_wheel
106+
elif [[ -f pyproject.toml ]]; then
107+
pip install build
108+
python -m build
109+
else
110+
echo Error: setup.py and pyproject.toml not found
111+
exit 1
112+
fi
113+
"
114+
115+
- name: Install package wheels (Linux)
116+
if: runner.os == 'Linux'
77117
shell: bash
78118
run: |
79119
source /opt/intel/oneapi/setvars.sh
80-
pip install ${{ inputs.package }}-${{ steps.commit-id.outputs.commit_id }}/dist/*.whl
120+
121+
pip install ${{ env.PACKAGE_PATH }}/dist/*.whl
81122
python -c "import ${{ inputs.package }}; print(${{ inputs.package }}.__version__)"
82123
124+
- name: Install package wheels (Windows)
125+
if: runner.os == 'Windows'
126+
shell: pwsh
127+
run: |
128+
.venv\Scripts\activate.ps1
129+
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
130+
131+
bash -c "
132+
pip install ${{ env.PACKAGE_PATH }}/dist/*.whl
133+
python -c 'import ${{ inputs.package }}; print(${{ inputs.package }}.__version__)'
134+
"
135+
83136
- name: Save package to a cache
84137
if: ${{ steps.cache-load.outputs.status == 'miss' }}
85138
uses: ./.github/actions/save

.github/actions/load/action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,23 @@ runs:
3434
id: load
3535
shell: bash
3636
run: |
37+
if [[ ! -d ${{ inputs.root }} ]]; then
38+
echo "${{ inputs.root }} does not exist, cache disabled"
39+
echo "status=miss" >> $GITHUB_OUTPUT
40+
exit 0
41+
fi
42+
3743
ITEM_PATH="${{ inputs.root }}/${{ inputs.key }}"
3844
echo "dest=$ITEM_PATH" >> $GITHUB_OUTPUT
3945
if [[ -d ${{ inputs.path }} ]]; then
4046
echo "Directory ${{ inputs.path }} already exists and will be removed"
4147
rm -rf ${{ inputs.path }}
4248
fi
49+
4350
if [[ ${{ inputs.enabled == 'true' }} && -d $ITEM_PATH ]]; then
4451
echo "Cache hit for ${{ inputs.key }}"
4552
echo "status=hit" >> $GITHUB_OUTPUT
46-
if [[ ${{ inputs.symlink }} == true ]]; then
53+
if [[ ${{ inputs.symlink }} == true && $OSTYPE != msys ]]; then
4754
mkdir -p $(dirname ${{ inputs.path }})
4855
ln -s $ITEM_PATH ${{ inputs.path }}
4956
else

.github/actions/save/action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,18 @@ runs:
2020
if: ${{ inputs.enabled == 'true' }}
2121
shell: bash
2222
run: |
23+
if [[ ! -d ${{ inputs.root }} ]]; then
24+
echo "${{ inputs.root }} does not exist, cache disabled"
25+
exit 0
26+
fi
27+
2328
TEMP_ITEM=$(mktemp -d -p ${{ inputs.root }})
24-
cp -rT ${{ inputs.path }} $TEMP_ITEM
29+
if [[ $OSTYPE == msys ]]; then
30+
# dereference symlinks on Windows
31+
cp -rLT ${{ inputs.path }} $TEMP_ITEM
32+
else
33+
cp -rT ${{ inputs.path }} $TEMP_ITEM
34+
fi
2535
# ignore error if other job created a cache with the same key already
2636
if mv -T $TEMP_ITEM ${{ inputs.dest }}; then
2737
touch ${{ inputs.dest }}.hit

.github/workflows/e2e-windows.yml

Lines changed: 82 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ run-name: ${{ inputs.run_name }}
44
on:
55
workflow_dispatch:
66
inputs:
7+
test_mode:
8+
description: accuracy or performance
9+
type: string
10+
default: accuracy
711
suite:
812
description: Test suite
913
type: choice
@@ -71,66 +75,22 @@ env:
7175
BENCHMARK_REPO: pytorch/benchmark
7276

7377
jobs:
74-
setup:
75-
name: Setup
76-
runs-on: linux
77-
outputs:
78-
suite: ${{ steps.set-matrix.outputs.suite }}
79-
mode: ${{ steps.set-matrix.outputs.mode }}
80-
dtype: ${{ steps.set-matrix.outputs.dtype }}
81-
models: ${{ steps.set-matrix.outputs.models }}
82-
timeout-minutes: 10
83-
steps:
84-
- name: Set matrix
85-
id: set-matrix
86-
run: |
87-
if [[ -z "${{ inputs.suite }}" || "${{ inputs.suite }}" == "all" ]]; then
88-
suite='["huggingface", "timm_models", "torchbench"]'
89-
else
90-
suite='["${{ inputs.suite }}"]'
91-
fi
92-
if [[ -z "${{ inputs.mode }}" || "${{ inputs.mode }}" == "all" ]]; then
93-
mode='["inference", "inference-with-freezing", "training"]'
94-
else
95-
mode='["${{ inputs.mode }}"]'
96-
fi
97-
if [[ -z "${{ inputs.dtype }}" || "${{ inputs.dtype }}" == "all" ]]; then
98-
dtype='["amp_bf16", "amp_fp16", "bfloat16", "float16", "float32"]'
99-
else
100-
dtype='["${{ inputs.dtype }}"]'
101-
fi
102-
if [[ -z "${{ inputs.models }}" ]]; then
103-
models="subset"
104-
else
105-
models="${{ inputs.models }}"
106-
fi
107-
echo "suite=$suite" >> $GITHUB_OUTPUT
108-
echo "mode=$mode" >> $GITHUB_OUTPUT
109-
echo "dtype=$dtype" >> $GITHUB_OUTPUT
110-
echo "models=$models" >> $GITHUB_OUTPUT
111-
112-
- name: Print inputs
113-
run: |
114-
cat <<EOF
115-
${{ toJSON(github.event.inputs) }}
116-
EOF
117-
118-
- name: Print setup outputs
119-
run: |
120-
cat <<EOF
121-
${{ toJSON(steps.set-matrix.outputs) }}
122-
EOF
123-
12478
tests:
12579
name: Tests
126-
needs: setup
12780
runs-on:
12881
- windows
12982
- ${{ inputs.runner_label }}
13083
timeout-minutes: 1440 # 24h
13184
strategy:
13285
fail-fast: false
13386
steps:
87+
- name: Print inputs
88+
shell: bash
89+
run: |
90+
cat <<EOF
91+
${{ toJSON(github.event.inputs) }}
92+
EOF
93+
13494
- name: Checkout repository
13595
uses: actions/checkout@v4
13696

@@ -153,12 +113,6 @@ jobs:
153113
run:
154114
python -m venv .venv
155115

156-
# https://github.com/pytorch/data/blob/e316c5ca1ab2a4f69dd6d48e8fc9c6f8d0c7c468/README.md?plain=1#L6-L15
157-
- name: Install pinned torchdata
158-
run: |
159-
.venv\Scripts\activate.ps1
160-
pip install torchdata==0.9.0
161-
162116
- name: Install PyTorch (source)
163117
run: |
164118
.venv\Scripts\activate.ps1
@@ -174,7 +128,7 @@ jobs:
174128
run: |
175129
.venv\Scripts\activate.ps1
176130
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
177-
python -c 'import torch;print(torch.__version__)' Tee-Object -Variable PYTORCH_VERSION
131+
python -c 'import torch; print(torch.__version__)' | Tee-Object -Variable PYTORCH_VERSION
178132
echo "PYTORCH_VERSION=$PYTORCH_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
179133
180134
- name: Clean up Triton cache
@@ -200,26 +154,88 @@ jobs:
200154
python -c 'import triton; print(triton.__version__)'
201155
202156
- name: Identify pinned versions
157+
shell: bash
203158
run: |
204-
cd c:/pytorch
159+
cd /c/pytorch
205160
echo "BENCHMARK_COMMIT_ID=$(<.github/ci_commit_pins/torchbench.txt)" | tee -a "$GITHUB_ENV"
206161
echo "TORCHVISION_COMMIT_ID=$(<.github/ci_commit_pins/vision.txt)" | tee -a "$GITHUB_ENV"
207162
echo "TORCHTEXT_COMMIT_ID=$(<.github/ci_commit_pins/text.txt)" | tee -a "$GITHUB_ENV"
208163
echo "TORCHAUDIO_COMMIT_ID=$(<.github/ci_commit_pins/audio.txt)" | tee -a "$GITHUB_ENV"
209164
echo "TRANSFORMERS_VERSION=$(<.ci/docker/ci_commit_pins/huggingface.txt)" | tee -a "$GITHUB_ENV"
210165
echo "TIMM_COMMIT_ID=$(<.ci/docker/ci_commit_pins/timm.txt)" | tee -a "$GITHUB_ENV"
211166
167+
- name: Install pinned torchdata
168+
run: |
169+
.venv\Scripts\activate.ps1
170+
# Pinned torchdata
171+
# https://github.com/pytorch/data/blob/e316c5ca1ab2a4f69dd6d48e8fc9c6f8d0c7c468/README.md?plain=1#L6-L15
172+
pip install pyyaml pandas scipy numpy psutil pyre_extensions torchrec torchdata==0.9.0
173+
174+
- name: Install transformers package
175+
if: inputs.suite == 'all' || inputs.suite == 'huggingface'
176+
uses: ./.github/actions/install-dependency
177+
with:
178+
package: transformers
179+
repository: huggingface/transformers
180+
ref: ${{ env.TRANSFORMERS_VERSION }}
181+
try-tag-prefix: v
182+
extra-cache-key: ${{ env.PYTORCH_VERSION }}
183+
workspace: /c/gh${{ github.run_id }}
184+
185+
- name: Install torchvision package
186+
if: inputs.suite == 'all' || inputs.suite == 'timm_models' || inputs.suite == 'torchbench'
187+
env:
188+
DISTUTILS_USE_SDK: '1'
189+
uses: ./.github/actions/install-dependency
190+
with:
191+
package: torchvision
192+
repository: pytorch/vision
193+
ref: ${{ env.TORCHVISION_COMMIT_ID }}
194+
extra-cache-key: ${{ env.PYTORCH_VERSION }}
195+
workspace: /c/gh${{ github.run_id }}
196+
197+
- name: Install torchtext package
198+
if: inputs.suite == 'all' || inputs.suite == 'torchbench'
199+
uses: ./.github/actions/install-dependency
200+
with:
201+
package: torchtext
202+
repository: pytorch/text
203+
ref: ${{ env.TORCHTEXT_COMMIT_ID }}
204+
extra-cache-key: ${{ env.PYTORCH_VERSION }}
205+
workspace: /c/gh${{ github.run_id }}
206+
207+
- name: Install torchaudio package
208+
if: inputs.suite == 'all' || inputs.suite == 'torchbench'
209+
uses: ./.github/actions/install-dependency
210+
with:
211+
package: torchaudio
212+
repository: pytorch/audio
213+
ref: ${{ env.TORCHAUDIO_COMMIT_ID }}
214+
extra-cache-key: ${{ env.PYTORCH_VERSION }}
215+
workspace: /c/gh${{ github.run_id }}
216+
217+
- name: Install timm package
218+
if: inputs.suite == 'all' || inputs.suite == 'timm_models' || inputs.suite == 'torchbench'
219+
uses: ./.github/actions/install-dependency
220+
with:
221+
package: timm
222+
repository: huggingface/pytorch-image-models
223+
ref: ${{ env.TIMM_COMMIT_ID }}
224+
extra-cache-key: ${{ env.PYTORCH_VERSION }}
225+
workspace: /c/gh${{ github.run_id }}
226+
227+
- name: Identify GPU
228+
run: |
229+
# Initializing oneAPI to enable sycl-ls, which is used in capture-hw-details.sh on Windows.
230+
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
231+
bash -c './scripts/capture-hw-details.sh | tee -a $GITHUB_ENV'
232+
212233
- name: Report environment details
213234
shell: bash
214235
run: |
215-
mkdir -p ${{ env.NEW_WORKSPACE }}\inductor_log
236+
mkdir -p /c/gh${{ github.run_id }}/inductor_log
237+
cat <<EOF | tee /c/gh${{ github.run_id }}/inductor_log/e2e.env
216238
TIMESTAMP=$(date '+%Y%m%d%H%M%S')
217-
echo "TIMESTAMP=$TIMESTAMP" >> "${GITHUB_ENV}"
218-
219-
source ./scripts/capture-hw-details.sh --quiet
220-
221-
cat <<EOF | tee ${{ env.NEW_WORKSPACE }}\inductor_log\.env
222-
TIMESTAMP=$TIMESTAMP
223239
JOB_NAME=${{ join(inputs.*, '-') }}
224240
GITHUB_RUN_ID=$GITHUB_RUN_ID
225241
GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER

scripts/install-pytorch.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ mkdir -p $BASE
144144

145145
function pytorch_wheel_exists {
146146
if [[ ! -d $PYTORCH_PROJ/dist ]]; then
147+
echo "check-wheel: $PYTORCH_PROJ/dist does not exist"
147148
return 1
148149
fi
149150
PYTHON_VERSION=$(python -c "import sys; print(f'{sys.version_info.major}{sys.version_info.minor}')")
@@ -158,10 +159,13 @@ function pytorch_wheel_exists {
158159
fi
159160
PYTORCH_WHEEL_NAME="torch-${PYTORCH_VERSION}+git${PYTORCH_COMMIT:0:7}-cp${PYTHON_VERSION}-cp${PYTHON_VERSION}-${PYTORCH_OS}_${PYTORCH_ARCH}.whl"
160161
if [[ -f $PYTORCH_PROJ/dist/$PYTORCH_WHEEL_NAME ]]; then
161-
echo "**** $PYTORCH_WHEEL_NAME exists ****"
162+
echo "check-wheel: $PYTORCH_WHEEL_NAME exists"
162163
return 0
163164
else
164-
echo "**** $PYTORCH_WHEEL_NAME does not exist ****"
165+
echo "check-wheel: $PYTORCH_WHEEL_NAME does not exist"
166+
if [[ -d $PYTORCH_PROJ/dist ]]; then
167+
echo "check-wheel: existing files:" $(cd $PYTORCH_PROJ/dist && ls)
168+
fi
165169
return 1
166170
fi
167171
}

0 commit comments

Comments
 (0)