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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

222 lines
9.3 KiB
YAML
Raw Normal View History

2022-10-26 14:24:16 +00:00
name: Test PyTorch
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
branches: [master, "release/*"]
pull_request:
branches: [master, "release/*"]
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
paths:
2023-06-15 15:25:59 +00:00
- ".actions/*"
- "requirements/pytorch/**"
- "src/lightning/pytorch/**"
- "src/pytorch_lightning/*"
- "tests/tests_pytorch/**"
2023-01-25 12:14:42 +00:00
- "tests/legacy/**"
- "pyproject.toml" # includes pytest config
- ".github/workflows/ci-tests-pytorch.yml"
- "requirements/fabric/**"
- "src/lightning/fabric/**"
- "src/lightning_fabric/*"
2022-11-26 01:16:48 +00:00
- "!requirements/pytorch/docs.txt"
2022-11-16 10:07:02 +00:00
- "!*.md"
- "!**/*.md"
schedule:
# At the end of every day
- cron: "0 0 * * *"
2022-02-02 19:48:15 +00:00
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
defaults:
run:
shell: bash
2021-04-19 13:49:25 +00:00
jobs:
pl-cpu:
runs-on: ${{ matrix.os }}
2021-04-19 13:49:25 +00:00
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
CI: Combine conda and full testing into a single workflow (#14387) * Remove conda job * Remove conda job from readme * Remove conda jobs from checkgroup * Remove conda from docker builds * Remove base-conda dockerfile * Rewrite the strategy matrix while keeping equivalent * Run the workflow on this branch * Revert "Rewrite the strategy matrix while keeping equivalent" This reverts commit e54298d60e57cffbf8107890987be3fe4a006c77. * Add PyTorch versions * Run on draft and disable unrelated costly CI * Revert "Run the workflow on this branch" This reverts commit 51ed8b905d8926b630dce4817124bd486135d3ec. * tmp: Lightweight relevant CI * Fix CI pathfilter * Update matrix * Drop skipping logic * pip list * reorder pip list * tmp: lightweight ci * Install specified pytorch * Fix torch installation * Uncomment steps * Increase timeout * bad merge * Revert "Run on draft and disable unrelated costly CI" This reverts commit eb5dc5e6bd07ba801eea34111052e7d31701fddc. * Update checkgroup * Update docs and remove Python/PyTorch versions * Remove pip-list * Fail if wrong pytorch version installed * Add Python 3.8, PyTorch 1.9 job * tmp: remove azure jobs * tmp: remove dockers * tmp: remove others * Run all combinations * Include oldest * Exclude no Python 3.10 distributions * tmp: no concurrency * tmp: double timeout * Add pytest log reporter * Add pytest-reportlog * Fewer jobs * Revert "tmp: no concurrency" This reverts commit 4a7978dcb3499ce754306580412110b7a42920cd. * fix artifact name * Revert test reports * Revert unrelated changes * Revert unrelated changes * Add the combination of ex-conda jobs * Update checkgroup * revert timeout * remove conda job * revert docker build workflow file Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
2022-09-30 02:39:04 +00:00
include:
- { os: "macOS-11", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.11" }
- { os: "macOS-11", pkg-name: "lightning", python-version: "3.9", pytorch-version: "1.12" }
- { os: "macOS-11", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.13" }
- { os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.11" }
- { os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.9", pytorch-version: "1.12" }
- { os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.13" }
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.11" }
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.9", pytorch-version: "1.12" }
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.13" }
2023-08-28 15:15:12 +00:00
# only run PyTorch latest with Python recent
- { os: "macOS-11", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.0" }
- { os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.0" }
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.0" }
2023-08-28 15:15:12 +00:00
# only run PyTorch latest with Python latest, use PyTorch scope to limit dependency issues
- { os: "macOS-12", pkg-name: "pytorch", python-version: "3.11", pytorch-version: "2.0" }
- { os: "ubuntu-22.04", pkg-name: "pytorch", python-version: "3.11", pytorch-version: "2.0" }
- { os: "windows-2022", pkg-name: "pytorch", python-version: "3.11", pytorch-version: "2.0" }
# "oldest" versions tests, only on minimum Python
- {
os: "macOS-11",
pkg-name: "lightning",
python-version: "3.8",
pytorch-version: "1.11",
requires: "oldest",
}
- {
os: "ubuntu-20.04",
pkg-name: "lightning",
python-version: "3.8",
pytorch-version: "1.11",
requires: "oldest",
}
- {
os: "windows-2022",
pkg-name: "lightning",
python-version: "3.8",
pytorch-version: "1.11",
requires: "oldest",
}
# "pytorch" installs the standalone package
- { os: "macOS-11", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.13" }
- { os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.13" }
- { os: "windows-2022", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.13" }
timeout-minutes: 50
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
2023-08-28 15:15:12 +00:00
TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
TORCH_URL_STABLE: "https://download.pytorch.org/whl/cpu/torch_stable.html"
TORCH_URL_TEST: "https://download.pytorch.org/whl/test/cpu/torch_test.html"
FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
PYPI_CACHE_DIR: "_pip-wheels"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: basic setup
run: pip install -q -r .actions/requirements.txt
- name: Set min. dependencies
if: ${{ matrix.requires == 'oldest' }}
run: python .actions/assistant.py replace_oldest_ver
- name: Adjust PyTorch versions in requirements files
if: ${{ matrix.requires != 'oldest' }}
run: |
pip install -q wget packaging
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
for fpath in `ls requirements/**/*.txt`; do \
python ./adjust-torch-versions.py $fpath ${{ matrix.pytorch-version }}; \
done
cat requirements/pytorch/base.txt
- name: pip wheels cache
uses: actions/cache/restore@v3
with:
path: ${{ env.PYPI_CACHE_DIR }}
key: pypi_wheels
- run: |
mkdir -p $PYPI_CACHE_DIR
ls -lh $PYPI_CACHE_DIR
- name: Env. variables
run: |
# Switch PyTorch URL
#python -c "print('TORCH_URL=' + str('${{env.TORCH_URL_TEST}}' if '${{ matrix.release }}' == 'pre' else '${{env.TORCH_URL_STABLE}}'))" >> $GITHUB_ENV
# Switch coverage scope
python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV
# if you install mono-package set dependency only for this subpackage
python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.pkg-name}}' != 'lightning' else 'pytorch-'))" >> $GITHUB_ENV
- name: Install package & dependencies
timeout-minutes: 20
run: |
#python -m pip install -q pip -U
pip install ".[${EXTRA_PREFIX}extra,${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" -U --prefer-binary \
-r requirements/_integrations/accelerators.txt \
--find-links="${TORCH_URL}" --find-links="${PYPI_CACHE_DIR}"
pip list
- name: Drop LAI from extensions
if: ${{ matrix.pkg-name != 'lightning' }}
# Lightning is dependency of Habana or other accelerators/integrations so in case we test PL we need to remove it
run: pip uninstall -y lightning
- name: Drop PL for LAI
if: ${{ matrix.pkg-name == 'lightning' }}
run: pip uninstall -y pytorch-lightning
- name: Dump handy wheels
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
continue-on-error: true
uses: ./.github/actions/pip-wheels
with:
wheel-dir: ${{ env.PYPI_CACHE_DIR }}
torch-url: ${{ env.TORCH_URL }}
cache-key: "pypi_wheels"
- name: Cache datasets
uses: actions/cache@v3
with:
path: Datasets
key: pl-dataset
- name: Sanity check
run: |
set -e
python requirements/pytorch/check-avail-extras.py
python -c "from torch import __version__ as ver; assert ver.startswith('${{ matrix.pytorch-version }}'), ver"
- name: Adjust tests / env. -> PL
if: ${{ matrix.pkg-name != 'lightning' }}
run: |
python .actions/assistant.py copy_replace_imports --source_dir="./tests" \
--source_import="lightning.fabric,lightning.pytorch" \
--target_import="lightning_fabric,pytorch_lightning"
- name: Prevent using raw source
run: rm -rf src/
- name: Get legacy checkpoints
run: |
bash .actions/pull_legacy_checkpoints.sh
cd tests/legacy
bash generate_checkpoints.sh
ls -l checkpoints/
- name: Testing Warnings
working-directory: tests/tests_pytorch
# needs to run outside of `pytest`
run: python utilities/test_warnings.py
- name: Testing PyTorch
working-directory: tests/tests_pytorch
# NOTE: do not include coverage report here, see: https://github.com/nedbat/coveragepy/issues/1003
run: |
echo $GITHUB_RUN_ID
python -m coverage run --source ${{ env.COVERAGE_SCOPE }} \
-m pytest . -v --timeout=60 --durations=50 --random-order-seed=$GITHUB_RUN_ID
- name: Statistics
if: success()
working-directory: tests/tests_pytorch
run: |
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
# see: https://github.com/actions/toolkit/issues/399
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: tests/tests_pytorch/coverage.xml
flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest-full,python${{ matrix.python-version }},pytorch${{ matrix.pytorch-version }}
name: CPU-coverage
fail_ci_if_error: false