Skip to content

Commit 75d6d9f

Browse files
authored
Merge branch 'master' into fsdp-grad-clip-by-norm
2 parents 5814091 + 04e103b commit 75d6d9f

File tree

71 files changed

+1900
-289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1900
-289
lines changed

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

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -38,42 +38,29 @@ jobs:
3838
strategy:
3939
fail-fast: false
4040
matrix:
41-
include:
41+
os: [macOS-14, ubuntu-22.04, windows-2022]
42+
config:
4243
# only run PyTorch latest
43-
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
44-
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
45-
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
46-
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.2.2" }
47-
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.2.2" }
48-
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.2.2" }
49-
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.3" }
50-
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.3" }
51-
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.3" }
52-
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.4.1" }
53-
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.4.1" }
54-
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.4.1" }
55-
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.5.1" }
56-
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.5.1" }
57-
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.5.1" }
44+
- { pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
45+
- { pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.2.2" }
46+
- { pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.3" }
47+
- { pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.4.1" }
48+
- { pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.5.1" }
49+
5850
# only run PyTorch latest with Python latest, use Fabric scope to limit dependency issues
59-
- { os: "macOS-14", pkg-name: "fabric", python-version: "3.12.7", pytorch-version: "2.6" }
60-
- { os: "ubuntu-22.04", pkg-name: "fabric", python-version: "3.12.7", pytorch-version: "2.6" }
61-
- { os: "windows-2022", pkg-name: "fabric", python-version: "3.12.7", pytorch-version: "2.6" }
62-
# "oldest" versions tests, only on minimum Python
63-
- { os: "macOS-14", pkg-name: "fabric", pytorch-version: "2.1", requires: "oldest" }
64-
- { os: "ubuntu-22.04", pkg-name: "fabric", pytorch-version: "2.1", requires: "oldest" }
65-
- { os: "windows-2022", pkg-name: "fabric", pytorch-version: "2.1", requires: "oldest" }
51+
- { pkg-name: "fabric", python-version: "3.12.7", pytorch-version: "2.6" }
52+
6653
# "fabric" installs the standalone package
67-
- { os: "macOS-14", pkg-name: "fabric", python-version: "3.10", pytorch-version: "2.7" }
68-
- { os: "ubuntu-22.04", pkg-name: "fabric", python-version: "3.10", pytorch-version: "2.7" }
69-
- { os: "windows-2022", pkg-name: "fabric", python-version: "3.10", pytorch-version: "2.7" }
54+
- { pkg-name: "fabric", python-version: "3.10", pytorch-version: "2.7" }
55+
7056
# adding recently cut Torch 2.7 - FUTURE
71-
- { os: "macOS-14", pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.8" }
72-
- { os: "ubuntu-22.04", pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.8" }
73-
- { os: "windows-2022", pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.8" }
57+
- { pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.8" }
58+
59+
# "oldest" versions tests, only on minimum Python
60+
- { pkg-name: "fabric", pytorch-version: "2.1", requires: "oldest" }
7461
timeout-minutes: 25 # because of building grpcio on Mac
7562
env:
76-
PACKAGE_NAME: ${{ matrix.pkg-name }}
63+
PACKAGE_NAME: ${{ matrix.config.pkg-name }}
7764
FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
7865
PYPI_CACHE_DIR: "_pip-wheels"
7966
TORCH_URL_STABLE: "https://download.pytorch.org/whl/cpu/"
@@ -83,30 +70,30 @@ jobs:
8370
steps:
8471
- uses: actions/checkout@v5
8572

86-
- name: Set up Python ${{ matrix.python-version }}
73+
- name: Set up Python ${{ matrix.config.python-version }}
8774
uses: actions/setup-python@v5
8875
with:
89-
python-version: ${{ matrix.python-version || '3.9' }}
76+
python-version: ${{ matrix.config.python-version || '3.9' }}
9077

9178
- name: basic setup
9279
run: pip install -q -r .actions/requirements.txt
9380

9481
- name: Set min. dependencies
95-
if: ${{ matrix.requires == 'oldest' }}
82+
if: ${{ matrix.config.requires == 'oldest' }}
9683
run: |
9784
cd requirements/fabric
9885
pip install -U "lightning-utilities[cli]"
99-
python -m lightning_utilities.cli requirements set-oldest --req_files "['base.txt', 'strategies.txt']"
86+
python -m lightning_utilities.cli requirements set-oldest --req_files "['base.txt', 'strategies.txt', 'test.txt']"
10087
pip install "cython<3.0" wheel
10188
pip install "pyyaml==5.4" --no-build-isolation
10289
10390
- name: Adjust PyTorch versions in requirements files
104-
if: ${{ matrix.requires != 'oldest' }}
91+
if: ${{ matrix.config.requires != 'oldest' }}
10592
run: |
10693
pip install -q -r requirements/ci.txt
10794
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
10895
for fpath in `ls requirements/**/*.txt`; do \
109-
python ./adjust-torch-versions.py $fpath ${{ matrix.pytorch-version }}; \
96+
python ./adjust-torch-versions.py $fpath ${{ matrix.config.pytorch-version }}; \
11097
done
11198
11299
- name: pip wheels cache
@@ -121,11 +108,11 @@ jobs:
121108
- name: Expand Env. variables
122109
run: |
123110
# Switch PyTorch URL between stable and test/future
124-
python -c "print('TORCH_URL=' + str('${{env.TORCH_URL_TEST}}' if '${{ matrix.pytorch-version }}' == '2.7' else '${{env.TORCH_URL_STABLE}}'))" >> $GITHUB_ENV
111+
python -c "print('TORCH_URL=' + str('${{env.TORCH_URL_TEST}}' if '${{ matrix.config.pytorch-version }}' == '2.7' else '${{env.TORCH_URL_STABLE}}'))" >> $GITHUB_ENV
125112
# Switch coverage scope
126-
python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_fabric'))" >> $GITHUB_ENV
113+
python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.config.pkg-name}}' == 'lightning' else 'lightning_fabric'))" >> $GITHUB_ENV
127114
# if you install mono-package set dependency only for this subpackage
128-
python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.pkg-name}}' != 'lightning' else 'fabric-'))" >> $GITHUB_ENV
115+
python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.config.pkg-name}}' != 'lightning' else 'fabric-'))" >> $GITHUB_ENV
129116
- name: Append Env. vars for MacOS
130117
if: ${{ runner.os == 'macOS' }}
131118
run: |
@@ -142,7 +129,8 @@ jobs:
142129
run: |
143130
pip install -e ".[${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" \
144131
-U --upgrade-strategy=eager --prefer-binary \
145-
--extra-index-url="${TORCH_URL}" --find-links="${PYPI_CACHE_DIR}"
132+
--extra-index-url="${TORCH_URL}" \
133+
--find-links="${PYPI_CACHE_DIR}"
146134
pip list
147135
- name: Dump handy wheels
148136
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
@@ -154,7 +142,7 @@ jobs:
154142
cache-key: "pypi_wheels"
155143

156144
- name: Adjust tests
157-
if: ${{ matrix.pkg-name != 'lightning' }}
145+
if: ${{ matrix.config.pkg-name != 'lightning' }}
158146
run: |
159147
python .actions/assistant.py copy_replace_imports --source_dir="./tests" \
160148
--source_import="lightning.fabric" --target_import="lightning_fabric"
@@ -187,7 +175,7 @@ jobs:
187175
with:
188176
token: ${{ secrets.CODECOV_TOKEN }}
189177
file: tests/tests_fabric/coverage.xml
190-
flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest,python${{ matrix.python-version }}
178+
flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest,python${{ matrix.config.python-version }}
191179
name: CPU-coverage
192180
fail_ci_if_error: false
193181

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

Lines changed: 39 additions & 46 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,30 +75,34 @@ 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
9885

86+
- name: Append Env. vars for Linux
87+
if: ${{ runner.os == 'Linux' }}
88+
run: echo "GLOO_SOCKET_IFNAME=eth0" >> $GITHUB_ENV
89+
9990
- name: Set min. dependencies
100-
if: ${{ matrix.requires == 'oldest' }}
91+
if: ${{ matrix.config.requires == 'oldest' }}
10192
run: |
10293
cd requirements/pytorch
10394
pip install -U "lightning-utilities[cli]"
104-
python -m lightning_utilities.cli requirements set-oldest --req_files "['base.txt', 'extra.txt', 'strategies.txt', 'examples.txt']"
95+
python -m lightning_utilities.cli requirements set-oldest --req_files "['base.txt', 'extra.txt', 'strategies.txt', 'examples.txt', 'test.txt']"
10596
pip install "cython<3.0" wheel
10697
pip install "pyyaml==5.4" --no-build-isolation
10798
10899
- name: Adjust PyTorch versions in requirements files
109-
if: ${{ matrix.requires != 'oldest' }}
100+
if: ${{ matrix.config.requires != 'oldest' }}
110101
run: |
111102
pip install -q -r requirements/ci.txt
112103
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
113104
for fpath in `ls requirements/**/*.txt`; do \
114-
python ./adjust-torch-versions.py $fpath ${{ matrix.pytorch-version }}; \
105+
python ./adjust-torch-versions.py $fpath ${{ matrix.config.pytorch-version }}; \
115106
done
116107
cat requirements/pytorch/base.txt
117108
@@ -127,28 +118,30 @@ jobs:
127118
- name: Env. variables
128119
run: |
129120
# 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
121+
python -c "print('TORCH_URL=' + str('${{env.TORCH_URL_TEST}}' if '${{ matrix.config.pytorch-version }}' == '2.7' else '${{env.TORCH_URL_STABLE}}'))" >> $GITHUB_ENV
131122
# Switch coverage scope
132-
python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV
123+
python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.config.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV
133124
# 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
125+
python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.config.pkg-name}}' != 'lightning' else 'pytorch-'))" >> $GITHUB_ENV
135126
# 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
127+
python -c "print('USE_LIBUV=0' if '${{matrix.os}}' == 'windows-2022' and '${{matrix.config.pytorch-version}}' == '2.4' else '')" >> $GITHUB_ENV
137128
138129
- name: Install package & dependencies
139130
timeout-minutes: 20
140131
run: |
141132
pip install ".[${EXTRA_PREFIX}extra,${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" \
142133
-U --upgrade-strategy=eager --prefer-binary \
143134
-r requirements/_integrations/accelerators.txt \
144-
--extra-index-url="${TORCH_URL}" --find-links="${PYPI_CACHE_DIR}" --find-links="https://download.pytorch.org/whl/torch-tensorrt"
135+
--extra-index-url="${TORCH_URL}" \
136+
--find-links="${PYPI_CACHE_DIR}" \
137+
--find-links="https://download.pytorch.org/whl/torch-tensorrt"
145138
pip list
146139
- name: Drop LAI from extensions
147-
if: ${{ matrix.pkg-name != 'lightning' }}
140+
if: ${{ matrix.config.pkg-name != 'lightning' }}
148141
# Lightning is dependency of Habana or other accelerators/integrations so in case we test PL we need to remove it
149142
run: pip uninstall -y lightning
150143
- name: Drop PL for LAI
151-
if: ${{ matrix.pkg-name == 'lightning' }}
144+
if: ${{ matrix.config.pkg-name == 'lightning' }}
152145
run: pip uninstall -y pytorch-lightning
153146
- name: Dump handy wheels
154147
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
@@ -169,10 +162,10 @@ jobs:
169162
run: |
170163
set -e
171164
python requirements/pytorch/check-avail-extras.py
172-
python -c "from torch import __version__ as ver; assert ver.startswith('${{ matrix.pytorch-version }}'), ver"
165+
python -c "from torch import __version__ as ver; assert ver.startswith('${{ matrix.config.pytorch-version }}'), ver"
173166
174167
- name: Adjust tests / env. -> PL
175-
if: ${{ matrix.pkg-name != 'lightning' }}
168+
if: ${{ matrix.config.pkg-name != 'lightning' }}
176169
run: |
177170
python .actions/assistant.py copy_replace_imports --source_dir="./tests" \
178171
--source_import="lightning.fabric,lightning.pytorch" \
@@ -222,7 +215,7 @@ jobs:
222215
with:
223216
token: ${{ secrets.CODECOV_TOKEN }}
224217
file: tests/tests_pytorch/coverage.xml
225-
flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest-full,python${{ matrix.python-version }},pytorch${{ matrix.pytorch-version }}
218+
flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest-full,python${{ matrix.config.python-version }},pytorch${{ matrix.config.pytorch-version }}
226219
name: CPU-coverage
227220
fail_ci_if_error: false
228221

.github/workflows/docs-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ jobs:
165165
path: docs/build/html/
166166

167167
- name: Authenticate to Google Cloud
168-
uses: google-github-actions/auth@v2
168+
uses: google-github-actions/auth@v3
169169
with:
170170
credentials_json: ${{ secrets.GCS_SA_KEY }}
171171

172172
- name: Setup gcloud
173-
uses: google-github-actions/setup-gcloud@v2
173+
uses: google-github-actions/setup-gcloud@v3
174174
with:
175175
project_id: ${{ secrets.GCS_PROJECT }}
176176

0 commit comments

Comments
 (0)