Skip to content

Commit a3183ba

Browse files
authored
Merge branch 'master' into weights-only-compatibility
2 parents a5d6da3 + 77f9811 commit a3183ba

File tree

37 files changed

+681
-170
lines changed

37 files changed

+681
-170
lines changed

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

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -62,49 +62,57 @@ jobs:
6262
env:
6363
PACKAGE_NAME: ${{ matrix.config.pkg-name }}
6464
FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
65-
PYPI_CACHE_DIR: "_pip-wheels"
6665
TORCH_URL_STABLE: "https://download.pytorch.org/whl/cpu/"
6766
TORCH_URL_TEST: "https://download.pytorch.org/whl/test/cpu/"
6867
# TODO: Remove this - Enable running MPS tests on this platform
6968
DISABLE_MPS: ${{ matrix.os == 'macOS-14' && '1' || '0' }}
7069
steps:
7170
- uses: actions/checkout@v5
7271

73-
- name: Set up Python ${{ matrix.config.python-version }}
74-
uses: actions/setup-python@v5
72+
- name: Install uv and set Python version
73+
uses: astral-sh/setup-uv@v6
7574
with:
7675
python-version: ${{ matrix.config.python-version || '3.9' }}
76+
# TODO: Avoid activating environment like this
77+
# see: https://github.com/astral-sh/setup-uv/tree/v6/?tab=readme-ov-file#activate-environment
78+
activate-environment: true
79+
enable-cache: true
7780

78-
- name: basic setup
79-
run: pip install -q -r .actions/requirements.txt
81+
- name: Basic setup
82+
run: uv pip install -q -r .actions/requirements.txt
83+
84+
- name: Append Env. vars for Linux
85+
if: ${{ runner.os == 'Linux' }}
86+
run: echo "GLOO_SOCKET_IFNAME=eth0" >> $GITHUB_ENV
87+
88+
- name: Append Env. vars for MacOS
89+
if: ${{ runner.os == 'macOS' }}
90+
run: echo "GLOO_SOCKET_IFNAME=lo0" >> $GITHUB_ENV
91+
92+
- name: Append Env. vars for Windows
93+
if: ${{ runner.os == 'windows' }}
94+
run: |
95+
# Avoid issue on Windows with PyTorch 2.4: "RuntimeError: use_libuv was requested but PyTorch was build without libuv support"
96+
echo "USE_LIBUV=0" >> $GITHUB_ENV
8097
8198
- name: Set min. dependencies
8299
if: ${{ matrix.config.requires == 'oldest' }}
83100
run: |
84101
cd requirements/fabric
85-
pip install -U "lightning-utilities[cli]"
102+
uv pip install -U "lightning-utilities[cli]"
86103
python -m lightning_utilities.cli requirements set-oldest --req_files "['base.txt', 'strategies.txt', 'test.txt']"
87-
pip install "cython<3.0" wheel
88-
pip install "pyyaml==5.4" --no-build-isolation
104+
uv pip install "cython<3.0" wheel
105+
uv pip install "pyyaml==5.4" --no-build-isolation
89106
90107
- name: Adjust PyTorch versions in requirements files
91108
if: ${{ matrix.config.requires != 'oldest' }}
92109
run: |
93-
pip install -q -r requirements/ci.txt
110+
uv pip install -q -r requirements/ci.txt
94111
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
95112
for fpath in `ls requirements/**/*.txt`; do \
96113
python ./adjust-torch-versions.py $fpath ${{ matrix.config.pytorch-version }}; \
97114
done
98115
99-
- name: pip wheels cache
100-
uses: actions/cache/restore@v4
101-
with:
102-
path: ${{ env.PYPI_CACHE_DIR }}
103-
key: pypi_wheels
104-
- run: |
105-
mkdir -p $PYPI_CACHE_DIR
106-
ls -lh $PYPI_CACHE_DIR
107-
108116
- name: Expand Env. variables
109117
run: |
110118
# Switch PyTorch URL between stable and test/future
@@ -113,25 +121,15 @@ jobs:
113121
python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.config.pkg-name}}' == 'lightning' else 'lightning_fabric'))" >> $GITHUB_ENV
114122
# if you install mono-package set dependency only for this subpackage
115123
python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.config.pkg-name}}' != 'lightning' else 'fabric-'))" >> $GITHUB_ENV
116-
- name: Append Env. vars for MacOS
117-
if: ${{ runner.os == 'macOS' }}
118-
run: |
119-
# trying to avoid "gloo" issue with SIGABRT
120-
echo "GLOO_SOCKET_IFNAME=lo0" >> $GITHUB_ENV
121-
- name: Append Env. vars for Windows
122-
if: ${{ runner.os == 'windows' }}
123-
run: |
124-
# Avoid issue on Windows with PyTorch 2.4: "RuntimeError: use_libuv was requested but PyTorch was build without libuv support"
125-
echo "USE_LIBUV=0" >> $GITHUB_ENV
126124
127125
- name: Install package & dependencies
128126
timeout-minutes: 20
129127
run: |
130-
pip install -e ".[${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" \
131-
-U --upgrade-strategy=eager --prefer-binary \
132-
--extra-index-url="${TORCH_URL}" \
133-
--find-links="${PYPI_CACHE_DIR}"
134-
pip list
128+
uv pip install ".[${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" \
129+
--upgrade \
130+
--find-links="${TORCH_URL}"
131+
uv pip list
132+
135133
- name: Dump handy wheels
136134
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
137135
continue-on-error: true
@@ -179,6 +177,9 @@ jobs:
179177
name: CPU-coverage
180178
fail_ci_if_error: false
181179

180+
- name: Minimize uv cache
181+
run: uv cache prune --ci
182+
182183
fabric-cpu-guardian:
183184
runs-on: ubuntu-latest
184185
needs: fabric-cpu

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ jobs:
8989
- name: Append Env. vars for Linux
9090
if: ${{ runner.os == 'Linux' }}
9191
run: echo "GLOO_SOCKET_IFNAME=eth0" >> $GITHUB_ENV
92+
9293
- name: Append Env. vars for MacOS
9394
if: ${{ runner.os == 'macOS' }}
9495
run: echo "GLOO_SOCKET_IFNAME=lo0" >> $GITHUB_ENV

.lightning/workflows/fabric.yml

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,116 @@
11
trigger:
22
push:
3-
branches: ["master"]
3+
branches: ["master", "release/stable"]
44
pull_request:
5-
branches: ["master"]
5+
branches: ["master", "release/stable"]
66

77
timeout: "55" # minutes
88
parametrize:
99
matrix: {}
1010
include:
11-
# note that this is setting also all oldest requirements which is linked to Torch == 2.1
12-
- image: "pytorchlightning/pytorch_lightning:base-cuda12.1.1-py3.10-torch2.1"
11+
# note that this is setting also all oldest requirements which is linked to python == 3.10
12+
- image: "nvidia/cuda:12.1.1-runtime-ubuntu22.04"
1313
PACKAGE_NAME: "fabric"
14+
python_version: "3.10"
1415
machine: "A100_X_2"
15-
- image: "pytorchlightning/pytorch_lightning:base-cuda12.6.3-py3.12-torch2.8"
16+
- image: "nvidia/cuda:12.6.3-runtime-ubuntu22.04"
1617
PACKAGE_NAME: "fabric"
18+
python_version: "3.12"
1719
machine: "L4_X_2"
18-
# - image: "pytorchlightning/pytorch_lightning:base-cuda12.6.3-py3.12-torch2.7"
20+
# - image: "nvidia/cuda:12.6-runtime-ubuntu22.04"
1921
# PACKAGE_NAME: "fabric"
20-
- image: "pytorchlightning/pytorch_lightning:base-cuda12.6.3-py3.12-torch2.8"
22+
- image: "nvidia/cuda:12.6.3-runtime-ubuntu22.04"
2123
PACKAGE_NAME: "lightning"
24+
python_version: "3.12"
2225
machine: "L4_X_2"
2326
exclude: []
2427

2528
env:
29+
TZ: "Etc/UTC"
30+
DEBIAN_FRONTEND: "noninteractive"
31+
CUDA_TOOLKIT_ROOT_DIR: "/usr/local/cuda"
32+
MKL_THREADING_LAYER: "GNU"
33+
CUDA_LAUNCH_BLOCKING: "1"
34+
NCCL_DEBUG: "INFO"
35+
TORCHDYNAMO_VERBOSE: "1"
2636
FREEZE_REQUIREMENTS: "1"
2737
RUN_ONLY_CUDA_TESTS: "1"
2838

2939
run: |
40+
# Install Python and UV
41+
apt-get update -qq --fix-missing
42+
apt-get install -q -y software-properties-common curl
43+
# Add deadsnakes PPA for newer Python versions if needed
44+
add-apt-repository ppa:deadsnakes/ppa -y
45+
apt-get update -qq --fix-missing
46+
apt-get install -q -y --no-install-recommends --allow-downgrades --allow-change-held-packages \
47+
build-essential \
48+
pkg-config \
49+
cmake \
50+
ca-certificates \
51+
libopenmpi-dev \
52+
openmpi-bin \
53+
ninja-build \
54+
libnccl2 \
55+
libnccl-dev
56+
57+
apt-get install -y python${python_version} python${python_version}-venv python${python_version}-dev
58+
ln -sf /usr/bin/python${python_version} /usr/bin/python
59+
curl -LsSf https://astral.sh/uv/install.sh | sh
60+
61+
# Source the environment and ensure UV is in PATH
62+
[ -f "$HOME/.local/bin/env" ] && . "$HOME/.local/bin/env"
63+
export PATH="$HOME/.local/bin:$PATH"
64+
source $HOME/.cargo/env 2>/dev/null || true
65+
export PATH="$HOME/.cargo/bin:$PATH"
66+
67+
# Verify UV installation
68+
command -v uv || (echo "UV not found in PATH" && exit 1)
69+
# Create and activate a local uv virtual environment
70+
uv venv .venv -p "/usr/bin/python${python_version}" || uv venv .venv -p "python${python_version}" || uv venv .venv
71+
. .venv/bin/activate
72+
hash -r
73+
3074
whereis nvidia
3175
nvidia-smi
3276
python --version
33-
pip --version
34-
pip install -q fire wget packaging
35-
pip list
77+
uv --version
78+
uv pip list
3679
set -ex
3780
38-
CUDA_VERSION="${image##*cuda}" # Remove everything up to and including "cuda"
81+
# Parse CUDA version from image tag, e.g., "nvidia/cuda:12.6.3-devel-ubuntu22.04"
82+
IMAGE_TAG="${image##*:}" # "12.6.3-devel-ubuntu22.04"
83+
CUDA_VERSION="${IMAGE_TAG%%-*}" # "12.6.3"
3984
echo "Using CUDA version: ${CUDA_VERSION}"
40-
CUDA_VERSION_M_M="${cuda_version%.*}" # Get major.minor by removing the last dot and everything after
41-
CUDA_VERSION_MM="${CUDA_VERSION_M_M//'.'/''}"
42-
TORCH_URL="https://download.pytorch.org/whl/cu${CUDA_VERSION_MM}/torch_stable.html"
43-
echo "Torch URL: ${TORCH_URL}"
85+
CUDA_VERSION_M_M="${CUDA_VERSION%.*}" # "12.6"
86+
CUDA_VERSION_MM="${CUDA_VERSION_M_M//./}" # "126"
87+
export UV_TORCH_BACKEND=cu${CUDA_VERSION_MM}
4488
COVERAGE_SOURCE=$(python -c 'n = "$(PACKAGE_NAME)" ; print(dict(fabric="lightning_fabric").get(n, n))')
4589
echo "collecting coverage for: ${COVERAGE_SOURCE}"
46-
TORCH_VER=$(python -c "import torch; print(torch.__version__.rsplit('.', 1)[0])")
4790
48-
if [ "${TORCH_VER}" == "2.1" ]; then
91+
uv pip install fire wget packaging "lightning-utilities[cli]"
92+
if [ "${python_version}" == "3.10" ]; then
4993
echo "Set oldest versions"
50-
pip uninstall -y deepspeed
51-
pip install -U "lightning-utilities[cli]"
5294
cd requirements/fabric
5395
python -m lightning_utilities.cli requirements set-oldest --req_files "['base.txt', 'strategies.txt']"
5496
python -m lightning_utilities.cli requirements prune-pkgs --packages deepspeed --req_files strategies.txt
5597
cd ../..
56-
pip install "cython<3.0" wheel # for compatibility
98+
uv pip install "cython<3.0" wheel # for compatibility
5799
fi
58100
101+
# install the base so we can adjust other packages
102+
uv pip install .
59103
echo "Adjust torch versions in requirements files"
60104
PYTORCH_VERSION=$(python -c "import torch; print(torch.__version__.split('+')[0])")
61-
pip install -q wget packaging
105+
uv pip install wget packaging
62106
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
63107
for fpath in `ls requirements/**/*.txt`; do \
64108
python ./adjust-torch-versions.py $fpath ${PYTORCH_VERSION}; \
65109
done
66110
67111
if [ "${PACKAGE_NAME}" == "fabric" ]; then
68112
echo "Replaced PL imports"
69-
pip install -U -q -r .actions/requirements.txt
113+
uv pip install --upgrade -r .actions/requirements.txt
70114
python .actions/assistant.py copy_replace_imports --source_dir="./tests/tests_fabric" \
71115
--source_import="lightning.fabric" \
72116
--target_import="lightning_fabric"
@@ -76,11 +120,10 @@ run: |
76120
fi
77121
78122
extra=$(python -c "print({'lightning': 'fabric-'}.get('$(PACKAGE_NAME)', ''))")
79-
pip install -e ".[${extra}dev]" -U --upgrade-strategy=eager --extra-index-url="${TORCH_URL}"
123+
uv pip install ".[${extra}dev]" --upgrade
80124
81125
python requirements/collect_env_details.py
82126
python -c "import torch ; mgpu = torch.cuda.device_count() ; assert mgpu >= 2, f'GPU: {mgpu}'"
83-
python requirements/pytorch/check-avail-extras.py
84127
python -c "import bitsandbytes"
85128
86129
echo "Testing: Fabric doctests"
@@ -96,7 +139,7 @@ run: |
96139
97140
echo "Testing: fabric standalone"
98141
export PL_RUN_STANDALONE_TESTS=1
99-
wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/run_standalone_tests.sh
142+
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/run_standalone_tests.sh
100143
bash ./run_standalone_tests.sh "tests_fabric"
101144
export PL_RUN_STANDALONE_TESTS=0
102145

0 commit comments

Comments
 (0)