Skip to content

Commit f8d700b

Browse files
matsumotosanBorda
authored andcommitted
Simplify workflow matrix (#21132)
* simplify * add config field (cherry picked from commit db77fa7)
1 parent 7160273 commit f8d700b

File tree

1 file changed

+29
-42
lines changed

1 file changed

+29
-42
lines changed

.github/workflows/ci-tests-pytorch.yml

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,42 +42,29 @@ jobs:
4242
strategy:
4343
fail-fast: false
4444
matrix:
45-
include:
45+
os: [macOS-14, ubuntu-22.04, windows-2022]
46+
config:
4647
# only run PyTorch latest
47-
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
48-
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
49-
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
50-
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.2.2" }
51-
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.2.2" }
52-
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.2.2" }
53-
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.3" }
54-
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.3" }
55-
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.3" }
56-
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.4.1" }
57-
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.4.1" }
58-
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.4.1" }
59-
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.5.1" }
60-
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.5.1" }
61-
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.5.1" }
48+
- { pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
49+
- { pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.2.2" }
50+
- { pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.3" }
51+
- { pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.4.1" }
52+
- { pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.5.1" }
53+
6254
# only run PyTorch latest with Python latest, use PyTorch scope to limit dependency issues
63-
- { os: "macOS-14", pkg-name: "pytorch", python-version: "3.12.7", pytorch-version: "2.6" }
64-
- { os: "ubuntu-22.04", pkg-name: "pytorch", python-version: "3.12.7", pytorch-version: "2.6" }
65-
- { os: "windows-2022", pkg-name: "pytorch", python-version: "3.12.7", pytorch-version: "2.6" }
66-
# "oldest" versions tests, only on minimum Python
67-
- { os: "macOS-14", pkg-name: "pytorch", pytorch-version: "2.1", requires: "oldest" }
68-
- { os: "ubuntu-22.04", pkg-name: "pytorch", pytorch-version: "2.1", requires: "oldest" }
69-
- { os: "windows-2022", pkg-name: "pytorch", pytorch-version: "2.1", requires: "oldest" }
55+
- { pkg-name: "pytorch", python-version: "3.12.7", pytorch-version: "2.6" }
56+
7057
# "pytorch" installs the standalone package
71-
- { os: "macOS-14", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "2.7" }
72-
- { os: "ubuntu-22.04", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "2.7" }
73-
- { os: "windows-2022", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "2.7" }
58+
- { pkg-name: "pytorch", python-version: "3.10", pytorch-version: "2.7" }
59+
7460
# adding recently cut Torch 2.7 - FUTURE
75-
- { os: "macOS-14", pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.8" }
76-
- { os: "ubuntu-22.04", pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.8" }
77-
- { os: "windows-2022", pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.8" }
61+
- { pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.8" }
62+
63+
# "oldest" versions tests, only on minimum Python
64+
- { pkg-name: "pytorch", pytorch-version: "2.1", requires: "oldest" }
7865
timeout-minutes: 50
7966
env:
80-
PACKAGE_NAME: ${{ matrix.pkg-name }}
67+
PACKAGE_NAME: ${{ matrix.config.pkg-name }}
8168
TORCH_URL: "https://download.pytorch.org/whl/cpu/"
8269
TORCH_URL_STABLE: "https://download.pytorch.org/whl/cpu/"
8370
TORCH_URL_TEST: "https://download.pytorch.org/whl/test/cpu/"
@@ -88,10 +75,10 @@ jobs:
8875
steps:
8976
- uses: actions/checkout@v5
9077

91-
- name: Set up Python ${{ matrix.python-version }}
78+
- name: Set up Python ${{ matrix.config.python-version }}
9279
uses: actions/setup-python@v5
9380
with:
94-
python-version: ${{ matrix.python-version || '3.9' }}
81+
python-version: ${{ matrix.config.python-version || '3.9' }}
9582

9683
- name: basic setup
9784
run: pip install -q -r .actions/requirements.txt
@@ -111,7 +98,7 @@ jobs:
11198
pip install -q -r requirements/ci.txt
11299
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
113100
for fpath in `ls requirements/**/*.txt`; do \
114-
python ./adjust-torch-versions.py $fpath ${{ matrix.pytorch-version }}; \
101+
python ./adjust-torch-versions.py $fpath ${{ matrix.config.pytorch-version }}; \
115102
done
116103
cat requirements/pytorch/base.txt
117104
@@ -127,13 +114,13 @@ jobs:
127114
- name: Env. variables
128115
run: |
129116
# Switch PyTorch URL between stable and test/future
130-
python -c "print('TORCH_URL=' + str('${{env.TORCH_URL_TEST}}' if '${{ matrix.pytorch-version }}' == '2.7' else '${{env.TORCH_URL_STABLE}}'))" >> $GITHUB_ENV
117+
python -c "print('TORCH_URL=' + str('${{env.TORCH_URL_TEST}}' if '${{ matrix.config.pytorch-version }}' == '2.7' else '${{env.TORCH_URL_STABLE}}'))" >> $GITHUB_ENV
131118
# Switch coverage scope
132-
python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV
119+
python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.config.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV
133120
# if you install mono-package set dependency only for this subpackage
134-
python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.pkg-name}}' != 'lightning' else 'pytorch-'))" >> $GITHUB_ENV
121+
python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.config.pkg-name}}' != 'lightning' else 'pytorch-'))" >> $GITHUB_ENV
135122
# Avoid issue on Windows with PyTorch 2.4: "RuntimeError: use_libuv was requested but PyTorch was build without libuv support"
136-
python -c "print('USE_LIBUV=0' if '${{matrix.os}}' == 'windows-2022' and '${{matrix.pytorch-version}}' == '2.4' else '')" >> $GITHUB_ENV
123+
python -c "print('USE_LIBUV=0' if '${{matrix.os}}' == 'windows-2022' and '${{matrix.config.pytorch-version}}' == '2.4' else '')" >> $GITHUB_ENV
137124
138125
- name: Install package & dependencies
139126
timeout-minutes: 20
@@ -145,11 +132,11 @@ jobs:
145132
--find-links="${PYPI_CACHE_DIR}"
146133
pip list
147134
- name: Drop LAI from extensions
148-
if: ${{ matrix.pkg-name != 'lightning' }}
135+
if: ${{ matrix.config.pkg-name != 'lightning' }}
149136
# Lightning is dependency of Habana or other accelerators/integrations so in case we test PL we need to remove it
150137
run: pip uninstall -y lightning
151138
- name: Drop PL for LAI
152-
if: ${{ matrix.pkg-name == 'lightning' }}
139+
if: ${{ matrix.config.pkg-name == 'lightning' }}
153140
run: pip uninstall -y pytorch-lightning
154141
- name: Dump handy wheels
155142
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
@@ -170,10 +157,10 @@ jobs:
170157
run: |
171158
set -e
172159
python requirements/pytorch/check-avail-extras.py
173-
python -c "from torch import __version__ as ver; assert ver.startswith('${{ matrix.pytorch-version }}'), ver"
160+
python -c "from torch import __version__ as ver; assert ver.startswith('${{ matrix.config.pytorch-version }}'), ver"
174161
175162
- name: Adjust tests / env. -> PL
176-
if: ${{ matrix.pkg-name != 'lightning' }}
163+
if: ${{ matrix.config.pkg-name != 'lightning' }}
177164
run: |
178165
python .actions/assistant.py copy_replace_imports --source_dir="./tests" \
179166
--source_import="lightning.fabric,lightning.pytorch" \
@@ -223,7 +210,7 @@ jobs:
223210
with:
224211
token: ${{ secrets.CODECOV_TOKEN }}
225212
file: tests/tests_pytorch/coverage.xml
226-
flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest-full,python${{ matrix.python-version }},pytorch${{ matrix.pytorch-version }}
213+
flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest-full,python${{ matrix.config.python-version }},pytorch${{ matrix.config.pytorch-version }}
227214
name: CPU-coverage
228215
fail_ci_if_error: false
229216

0 commit comments

Comments
 (0)