Skip to content

Commit fb9dae8

Browse files
Bordaawaelchlicarmoccaakihironittalantiga
authored
ci: update install lite & cut pkg dependency (#14517)
* ci: update install lite * try without lite in req file * ci: install * app * init * Revert "app" This reverts commit f3f09e7. * ci: cpu * ci: gpu * pkg * env * bench * trigger * notes * prune * set version * fix version * git reset * hpu, ipu * adjust * --hard * git checkout * Apply suggestions from code review Co-authored-by: Carlos Mocholí <[email protected]> Co-authored-by: Akihiro Nitta <[email protected]> * rc2 * L * docs * hpu Co-authored-by: awaelchli <[email protected]> Co-authored-by: Carlos Mocholí <[email protected]> Co-authored-by: Akihiro Nitta <[email protected]> Co-authored-by: Luca Antiga <[email protected]>
1 parent 4a4b7f3 commit fb9dae8

File tree

16 files changed

+190
-73
lines changed

16 files changed

+190
-73
lines changed

.actions/setup_tools.py

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@
1919
import tarfile
2020
import tempfile
2121
import urllib.request
22-
from datetime import datetime
2322
from distutils.version import LooseVersion
2423
from importlib.util import module_from_spec, spec_from_file_location
2524
from itertools import chain
2625
from types import ModuleType
27-
from typing import Dict, List, Sequence
26+
from typing import Dict, List
2827

2928
from pkg_resources import parse_requirements
3029

3130
_PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
32-
_PACKAGE_MAPPING = {"pytorch": "pytorch_lightning", "app": "lightning_app"}
31+
_PACKAGE_MAPPING = {"pytorch": "pytorch_lightning", "app": "lightning_app", "lite": "lightning_lite"}
3332

3433
# TODO: remove this once lightning-ui package is ready as a dependency
3534
_LIGHTNING_FRONTEND_RELEASE_URL = "https://storage.googleapis.com/grid-packages/lightning-ui/v0.0.0/build.tar.gz"
@@ -83,7 +82,7 @@ def _augment_requirement(ln: str, comment_char: str = "#", unfreeze: str = "all"
8382
is_strict = False
8483
req = ln.strip()
8584
# skip directly installed dependencies
86-
if not req or req.startswith("http") or "@http" in req:
85+
if not req or req.startswith("http") or "@" in req:
8786
return ""
8887
# extract the major version from all listed versions
8988
if unfreeze == "major":
@@ -237,20 +236,6 @@ def create_mirror_package(src_folder: str, lit_pkg_mapping: dict) -> None:
237236
copy_adjusted_modules(src_folder, pkg_name, lit_name, lit_pkg_mapping)
238237

239238

240-
def set_version_today(fpath: str) -> None:
241-
"""Replace the template date with today."""
242-
with open(fpath) as fp:
243-
lines = fp.readlines()
244-
245-
def _replace_today(ln):
246-
today = datetime.now()
247-
return ln.replace("YYYY.-M.-D", f"{today.year}.{today.month}.{today.day}")
248-
249-
lines = list(map(_replace_today, lines))
250-
with open(fpath, "w") as fp:
251-
fp.writelines(lines)
252-
253-
254239
def _download_frontend(pkg_path: str):
255240
"""Downloads an archive file for a specific release of the Lightning frontend and extracts it to the correct
256241
directory."""
@@ -273,27 +258,6 @@ def _download_frontend(pkg_path: str):
273258
print("The Lightning UI downloading has failed!")
274259

275260

276-
def _relax_require_versions(
277-
source_dir: str = "src", req_dir: str = "requirements", strict_pkgs: Sequence[str] = ("lightning_app",)
278-
) -> None:
279-
"""Parse the base requirements and append as version adjustments if needed `pkg>=X1.Y1.Z1,==X2.Y2.*`.
280-
281-
>>> _relax_require_versions("../src", "../requirements")
282-
"""
283-
strict_pkgs = strict_pkgs or tuple()
284-
reqs = load_requirements(req_dir, file_name="base.txt")
285-
for i, req in enumerate(parse_requirements(reqs)):
286-
ver = parse_version_from_file(os.path.join(source_dir, req.name))
287-
if not ver:
288-
continue
289-
if req.name not in strict_pkgs:
290-
ver = ".".join(ver.split(".")[:2] + ["*"])
291-
reqs[i] = f"{req}, =={ver}"
292-
293-
with open(os.path.join(req_dir, "base.txt"), "w") as fp:
294-
fp.writelines([ln + os.linesep for ln in reqs])
295-
296-
297261
def _load_aggregate_requirements(req_dir: str = "requirements", freeze_requirements: bool = False) -> None:
298262
"""Load all base requirements from all particular packages and prune duplicates."""
299263
requires = [
@@ -308,3 +272,19 @@ def _load_aggregate_requirements(req_dir: str = "requirements", freeze_requireme
308272
requires = list(chain(*requires))
309273
with open(os.path.join(req_dir, "base.txt"), "w") as fp:
310274
fp.writelines([ln + os.linesep for ln in requires])
275+
276+
277+
def set_actual_version_from_src(req_path: str, src_root: str, pkg_name: str) -> None:
278+
"""Setting actual version from source code for a given package."""
279+
with open(req_path, encoding="utf-8") as fo:
280+
lines = fo.readlines()
281+
ver = parse_version_from_file(os.path.join(src_root, pkg_name.replace("-", "_")))
282+
for i, ln in enumerate(lines):
283+
reqs = list(parse_requirements([ln]))
284+
if not reqs:
285+
continue
286+
if reqs[0].name == pkg_name:
287+
lines[i] = f"{pkg_name}=={ver}{os.linesep}"
288+
289+
with open(req_path, "w", encoding="utf-8") as fw:
290+
fw.writelines(lines)

.azure/gpu-benchmark.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ trigger:
1313
- "release/*"
1414
- "refs/tags/*"
1515

16-
pr: none
16+
pr:
17+
branches:
18+
include:
19+
- "master"
20+
- "release/*"
21+
paths:
22+
include:
23+
- ".azure/gpu-benchmark.yml"
1724

1825
schedules:
1926
- cron: "0 0 * * *" # At the end of every day
@@ -26,17 +33,36 @@ jobs:
2633
- job: benchmarks
2734
timeoutInMinutes: "90"
2835
cancelTimeoutInMinutes: "2"
29-
pool: azure-jirka-spot
36+
pool: lit-rtx-3090
37+
variables:
38+
DEVICES: $( python -c 'print("$(Agent.Name)".split("_")[-1])' )
3039
container:
3140
image: "pytorchlightning/pytorch_lightning:base-cuda-py3.9-torch1.12-cuda11.6.1"
32-
options: "--runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all --shm-size=32g"
41+
options: "--gpus=all --shm-size=32g"
3342
workspace:
3443
clean: all
3544

3645
steps:
3746

3847
- bash: |
39-
pip install -e . -r requirements/pytorch/strategies.txt
48+
echo "##vso[task.setvariable variable=CUDA_VISIBLE_DEVICES]$(DEVICES)"
49+
cuda_ver=$(python -c "import torch ; print(''.join(map(str, torch.version.cuda.split('.')[:2])))")
50+
echo "##vso[task.setvariable variable=CUDA_VERSION_MM]$cuda_ver"
51+
echo "##vso[task.setvariable variable=TORCH_URL]https://download.pytorch.org/whl/cu${cuda_ver}/torch_stable.html"
52+
displayName: 'set env. vars'
53+
54+
- bash: |
55+
pip install -e . --find-links ${TORCH_URL}
56+
git checkout -- setup.py MANIFEST.in
57+
env:
58+
PACKAGE_NAME: lite
59+
FREEZE_REQUIREMENTS: 1
60+
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
61+
# also installing from source not from on-the-fly created package tp prevent accidental interaction with cache
62+
displayName: 'Install Lite pkg'
63+
64+
- bash: |
65+
pip install -e .[strategies] --find-links ${TORCH_URL}
4066
pip list
4167
env:
4268
PACKAGE_NAME: pytorch
@@ -45,7 +71,7 @@ jobs:
4571
4672
- bash: python -m pytest benchmarks -v --durations=0
4773
env:
48-
PL_RUNNING_BENCHMARKS: 1
74+
PL_RUNNING_BENCHMARKS: "1"
4975
PL_RUN_CUDA_TESTS: "1"
5076
workingDirectory: tests/tests_pytorch
5177
displayName: 'Testing: PyTorch benchmarks'

.azure/gpu-tests-pytorch.yml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,18 @@ jobs:
6161
clean: all
6262

6363
steps:
64+
6465
- bash: |
66+
echo "##vso[task.setvariable variable=CUDA_VISIBLE_DEVICES]$(DEVICES)"
67+
cuda_ver=$(python -c "import torch ; print(''.join(map(str, torch.version.cuda.split('.')[:2])))")
68+
echo "##vso[task.setvariable variable=CUDA_VERSION_MM]$cuda_ver"
69+
echo "##vso[task.setvariable variable=TORCH_URL]https://download.pytorch.org/whl/cu${cuda_ver}/torch_stable.html"
70+
displayName: 'set env. vars'
71+
72+
- bash: |
73+
echo $CUDA_VISIBLE_DEVICES
74+
echo $CUDA_VERSION_MM
75+
echo $TORCH_URL
6576
lspci | egrep 'VGA|3D'
6677
whereis nvidia
6778
nvidia-smi
@@ -72,11 +83,6 @@ jobs:
7283
displayName: 'Image info & NVIDIA'
7384
7485
- bash: |
75-
echo "##vso[task.setvariable variable=CUDA_VISIBLE_DEVICES]$(DEVICES)"
76-
displayName: 'set visible devices'
77-
78-
- bash: |
79-
set -e
8086
python -c "fname = 'requirements/pytorch/strategies.txt' ; lines = [line for line in open(fname).readlines() if 'horovod' not in line] ; open(fname, 'w').writelines(lines)"
8187
python -c "fname = 'requirements/pytorch/strategies.txt' ; lines = [line for line in open(fname).readlines() if 'bagua' not in line] ; open(fname, 'w').writelines(lines)"
8288
python -c "fname = 'requirements/pytorch/strategies.txt' ; lines = [line for line in open(fname).readlines() if 'colossalai' not in line] ; open(fname, 'w').writelines(lines)"
@@ -85,12 +91,26 @@ jobs:
8591
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/base.txt ${PYTORCH_VERSION}
8692
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/extra.txt ${PYTORCH_VERSION}
8793
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt ${PYTORCH_VERSION}
94+
displayName: 'Adjust dependencies'
8895
89-
CUDA_VERSION_MM=$(python -c "import torch ; print(''.join(map(str, torch.version.cuda.split('.')[:2])))")
90-
pip install -e .[strategies] --find-links https://download.pytorch.org/whl/cu${CUDA_VERSION_MM}/torch_stable.html
91-
pip install --requirement requirements/pytorch/devel.txt --find-links https://download.pytorch.org/whl/cu${CUDA_VERSION_MM}/torch_stable.html
92-
pip install --requirement requirements/pytorch/examples.txt --find-links https://download.pytorch.org/whl/cu${CUDA_VERSION_MM}/torch_stable.html
96+
- bash: |
97+
pip install -e . --find-links ${TORCH_URL}
98+
git checkout -- setup.py MANIFEST.in
99+
env:
100+
PACKAGE_NAME: "lite"
101+
FREEZE_REQUIREMENTS: "1"
102+
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
103+
# also installing from source not from on-the-fly created package to prevent accidental interaction with cache
104+
displayName: 'Install Lite pkg'
105+
106+
- bash: pip install -e .[strategies] -r requirements/pytorch/devel.txt -r requirements/pytorch/examples.txt --find-links ${TORCH_URL}
107+
env:
108+
PACKAGE_NAME: "pytorch"
109+
FREEZE_REQUIREMENTS: "1"
110+
displayName: 'Install package'
93111

112+
- bash: |
113+
set -e
94114
CUDA_VERSION_BAGUA=$(python -c "print([ver for ver in [116,113,111,102] if $CUDA_VERSION_MM >= ver][0])")
95115
pip install "bagua-cuda$CUDA_VERSION_BAGUA"
96116
@@ -100,14 +120,10 @@ jobs:
100120
pip install "colossalai==0.1.10+torch${PYTORCH_VERSION_COLOSSALAI}cu${CUDA_VERSION_COLOSSALAI}" --find-links https://release.colossalai.org
101121
102122
pip list
103-
env:
104-
PACKAGE_NAME: pytorch
105-
FREEZE_REQUIREMENTS: 1
106123
displayName: 'Install dependencies'
107124
108125
- bash: |
109126
set -e
110-
echo $CUDA_VISIBLE_DEVICES
111127
python requirements/collect_env_details.py
112128
python -c "import torch ; mgpu = torch.cuda.device_count() ; assert mgpu == 2, f'GPU: {mgpu}'"
113129
python requirements/pytorch/check-avail-strategies.py

.azure/hpu-tests.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ jobs:
5858
sudo pip install pip -U
5959
displayName: 'Instance HW info'
6060
61+
- bash: |
62+
pip install -e .
63+
git checkout -- setup.py MANIFEST.in
64+
env:
65+
PACKAGE_NAME: "lite"
66+
FREEZE_REQUIREMENTS: "1"
67+
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
68+
# also installing from source not from on-the-fly created package to prevent accidental interaction with cache
69+
displayName: 'Install Lite pkg'
70+
6171
- bash: |
6272
set -e
6373
pip --version
@@ -67,9 +77,9 @@ jobs:
6777
pip install ".[extra,test]"
6878
pip list
6979
env:
70-
PACKAGE_NAME: pytorch
71-
FREEZE_REQUIREMENTS: 1
72-
displayName: 'Install dependencies'
80+
PACKAGE_NAME: "pytorch"
81+
FREEZE_REQUIREMENTS: "1"
82+
displayName: 'Install package & dependencies'
7383
7484
- bash: |
7585
hl-smi -L

.azure/ipu-tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ jobs:
6262
done
6363
displayName: "Reset IPU devices"
6464
65+
- bash: |
66+
pip install -e .
67+
git checkout -- setup.py MANIFEST.in
68+
env:
69+
PACKAGE_NAME: "lite"
70+
FREEZE_REQUIREMENTS: "1"
71+
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
72+
# also installing from source not from on-the-fly created package tp prevent accidental interaction with cache
73+
displayName: 'Install Lite pkg'
74+
6575
- bash: |
6676
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/extra.txt
6777
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt

.github/workflows/ci-pkg-install.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,46 @@ defaults:
2323

2424
jobs:
2525

26+
init-pypi:
27+
runs-on: ubuntu-20.04
28+
steps:
29+
- run: mkdir pypi && touch pypi/.placeholder
30+
- uses: actions/upload-artifact@v3
31+
with:
32+
name: ci-packages-${{ github.sha }}
33+
path: pypi
34+
35+
build-pypi:
36+
needs: init-pypi
37+
# This serves to create packages for potential internal dependencies
38+
runs-on: ubuntu-20.04
39+
strategy:
40+
fail-fast: true
41+
max-parallel: 1
42+
matrix:
43+
pkg: ["lite"]
44+
steps:
45+
- uses: actions/checkout@v3
46+
- uses: actions/setup-python@v4
47+
with:
48+
python-version: "3.8"
49+
- uses: actions/download-artifact@v3
50+
with:
51+
name: ci-packages-${{ github.sha }}
52+
path: pypi
53+
- name: Build package
54+
env:
55+
PACKAGE_NAME: ${{ matrix.pkg }}
56+
run: |
57+
python setup.py sdist
58+
cp dist/* pypi/
59+
- uses: actions/upload-artifact@v3
60+
with:
61+
name: ci-packages-${{ github.sha }}
62+
path: pypi
63+
2664
install-pkg:
65+
needs: build-pypi
2766
runs-on: ${{ matrix.os }}
2867
strategy:
2968
fail-fast: false
@@ -49,7 +88,14 @@ jobs:
4988
pkg-name: ${{ matrix.pkg }}
5089
nb-dirs: ${{ env.NB_DIRS }}
5190

91+
- uses: actions/download-artifact@v3
92+
with:
93+
name: ci-packages-${{ github.sha }}
94+
path: pypi
95+
- run: ls -l pypi/
5296
- uses: ./.github/actions/pkg-install
97+
with:
98+
pip-flags: "--pre --find-links ../pypi/"
5399

54100
- name: Run CLI
55101
# todo: add testing for `lightning_app`

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,18 @@ jobs:
5555
restore-keys: |
5656
${{ runner.os }}-pip-py${{ matrix.python-version }}-
5757
58-
- name: Install dependencies
58+
- name: Install lite for PL
59+
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
60+
# also installing from source not from on-the-fly created package to prevent accidental interaction with cache
5961
env:
60-
PACKAGE_NAME: pytorch
62+
PACKAGE_NAME: "lite"
63+
run: |
64+
pip install -e . --upgrade --find-links https://download.pytorch.org/whl/cpu/torch_stable.html
65+
git checkout -- setup.py MANIFEST.in
66+
67+
- name: Install package & dependencies
68+
env:
69+
PACKAGE_NAME: "pytorch"
6170
FREEZE_REQUIREMENTS: 1
6271
run: |
6372
# adjust versions according installed Torch version

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ jobs:
103103
- name: Adjust PyTorch versions in requirements files
104104
if: ${{ matrix.requires != 'oldest' }}
105105
run: |
106+
python ./requirements/pytorch/adjust-versions.py requirements/lite/base.txt ${{ matrix.pytorch-version }}
106107
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/base.txt ${{ matrix.pytorch-version }}
107108
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt ${{ matrix.pytorch-version }}
108109
cat requirements/pytorch/base.txt
@@ -122,6 +123,16 @@ jobs:
122123
- name: Switch PyTorch URL
123124
run: python -c "print('TORCH_URL=https://download.pytorch.org/whl/' + str('test/cpu/torch_test.html' if '${{matrix.release}}' == 'pre' else 'cpu/torch_stable.html'))" >> $GITHUB_ENV
124125

126+
- name: Install lite for PL
127+
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
128+
# also installing from source not from on-the-fly created package tp prevent accidental interaction with cache
129+
if: ${{ matrix.pkg-name != 'lightning' }}
130+
env:
131+
PACKAGE_NAME: "lite"
132+
run: |
133+
pip install -e . --upgrade --find-links ${TORCH_URL}
134+
git checkout -- setup.py MANIFEST.in
135+
125136
- name: Install package & dependencies
126137
env:
127138
PACKAGE_NAME: ${{ matrix.pkg-name }}

0 commit comments

Comments
 (0)