pytorch-lightning

Форк
0
/
ci-tests-pytorch.yml 
221 строка · 9.2 Кб
1
name: Test PyTorch
2

3
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
4
on:
5
  push:
6
    branches: [master, "release/*"]
7
  pull_request:
8
    branches: [master, "release/*"]
9
    types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
10
    paths:
11
      - ".actions/*"
12
      - "requirements/ci.txt"
13
      - "requirements/pytorch/**"
14
      - "src/lightning/pytorch/**"
15
      - "src/pytorch_lightning/*"
16
      - "tests/tests_pytorch/**"
17
      - "tests/legacy/**"
18
      - "pyproject.toml" # includes pytest config
19
      - ".github/workflows/ci-tests-pytorch.yml"
20
      - "requirements/fabric/**"
21
      - "src/lightning/fabric/**"
22
      - "src/lightning_fabric/*"
23
      - "!requirements/pytorch/docs.txt"
24
      - "!*.md"
25
      - "!**/*.md"
26
  schedule:
27
    # At the end of every day
28
    - cron: "0 0 * * *"
29

30
concurrency:
31
  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
32
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
33

34
defaults:
35
  run:
36
    shell: bash
37

38
jobs:
39
  pl-cpu:
40
    runs-on: ${{ matrix.os }}
41
    if: github.event.pull_request.draft == false
42
    strategy:
43
      fail-fast: false
44
      matrix:
45
        include:
46
          - { os: "macOS-11", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.13" }
47
          - { os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.13" }
48
          - { os: "windows-2022", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.13" }
49
          # only run PyTorch latest
50
          - { os: "macOS-11", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
51
          - { os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
52
          - { os: "windows-2022", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
53
          - { os: "macOS-11", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.2" }
54
          - { os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.2" }
55
          - { os: "windows-2022", pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.2" }
56
          # only run PyTorch latest with Python latest, use PyTorch scope to limit dependency issues
57
          - { os: "macOS-12", pkg-name: "pytorch", python-version: "3.11", pytorch-version: "2.0" }
58
          - { os: "ubuntu-22.04", pkg-name: "pytorch", python-version: "3.11", pytorch-version: "2.0" }
59
          - { os: "windows-2022", pkg-name: "pytorch", python-version: "3.11", pytorch-version: "2.0" }
60
          - { os: "macOS-12", pkg-name: "pytorch", python-version: "3.11", pytorch-version: "2.1" }
61
          - { os: "ubuntu-22.04", pkg-name: "pytorch", python-version: "3.11", pytorch-version: "2.1" }
62
          - { os: "windows-2022", pkg-name: "pytorch", python-version: "3.11", pytorch-version: "2.1" }
63
          # "oldest" versions tests, only on minimum Python
64
          - {
65
              os: "macOS-11",
66
              pkg-name: "lightning",
67
              python-version: "3.8",
68
              pytorch-version: "1.13",
69
              requires: "oldest",
70
            }
71
          - {
72
              os: "ubuntu-20.04",
73
              pkg-name: "lightning",
74
              python-version: "3.8",
75
              pytorch-version: "1.13",
76
              requires: "oldest",
77
            }
78
          - {
79
              os: "windows-2022",
80
              pkg-name: "lightning",
81
              python-version: "3.8",
82
              pytorch-version: "1.13",
83
              requires: "oldest",
84
            }
85
          # "pytorch" installs the standalone package
86
          - { os: "macOS-11", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.13" }
87
          - { os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.13" }
88
          - { os: "windows-2022", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.13" }
89
    timeout-minutes: 50
90
    env:
91
      PACKAGE_NAME: ${{ matrix.pkg-name }}
92
      TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
93
      TORCH_URL_STABLE: "https://download.pytorch.org/whl/cpu/torch_stable.html"
94
      TORCH_URL_TEST: "https://download.pytorch.org/whl/test/cpu/torch_test.html"
95
      FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
96
      PYPI_CACHE_DIR: "_pip-wheels"
97
    steps:
98
      - uses: actions/checkout@v4
99

100
      - name: Set up Python ${{ matrix.python-version }}
101
        uses: actions/setup-python@v5
102
        with:
103
          python-version: ${{ matrix.python-version }}
104

105
      - name: basic setup
106
        run: pip install -q -r .actions/requirements.txt
107

108
      - name: Set min. dependencies
109
        if: ${{ matrix.requires == 'oldest' }}
110
        run: python .actions/assistant.py replace_oldest_ver
111

112
      - name: Adjust PyTorch versions in requirements files
113
        if: ${{ matrix.requires != 'oldest' }}
114
        run: |
115
          pip install -q -r requirements/ci.txt
116
          python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
117
          for fpath in `ls requirements/**/*.txt`; do \
118
            python ./adjust-torch-versions.py $fpath ${{ matrix.pytorch-version }}; \
119
          done
120
          cat requirements/pytorch/base.txt
121

122
      - name: pip wheels cache
123
        uses: actions/cache/restore@v4
124
        with:
125
          path: ${{ env.PYPI_CACHE_DIR }}
126
          key: pypi_wheels
127
      - run: |
128
          mkdir -p $PYPI_CACHE_DIR
129
          ls -lh $PYPI_CACHE_DIR
130

131
      - name: Env. variables
132
        run: |
133
          # Switch PyTorch URL
134
          python -c "print('TORCH_URL=' + str('${{env.TORCH_URL_TEST}}' if '${{ matrix.pytorch-version }}' == '2.2' else '${{env.TORCH_URL_STABLE}}'))" >> $GITHUB_ENV
135
          # Switch coverage scope
136
          python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV
137
          # if you install mono-package set dependency only for this subpackage
138
          python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.pkg-name}}' != 'lightning' else 'pytorch-'))" >> $GITHUB_ENV
139

140
      - name: Install package & dependencies
141
        timeout-minutes: 20
142
        run: |
143
          pip install ".[${EXTRA_PREFIX}extra,${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" -U --prefer-binary \
144
            -r requirements/_integrations/accelerators.txt \
145
            --find-links="${TORCH_URL}" --find-links="${PYPI_CACHE_DIR}"
146
          pip list
147
      - name: Drop LAI from extensions
148
        if: ${{ matrix.pkg-name != 'lightning' }}
149
        # Lightning is dependency of Habana or other accelerators/integrations so in case we test PL we need to remove it
150
        run: pip uninstall -y lightning
151
      - name: Drop PL for LAI
152
        if: ${{ matrix.pkg-name == 'lightning' }}
153
        run: pip uninstall -y pytorch-lightning
154
      - name: Dump handy wheels
155
        if: github.event_name == 'push' && github.ref == 'refs/heads/master'
156
        continue-on-error: true
157
        uses: ./.github/actions/pip-wheels
158
        with:
159
          wheel-dir: ${{ env.PYPI_CACHE_DIR }}
160
          torch-url: ${{ env.TORCH_URL }}
161
          cache-key: "pypi_wheels"
162

163
      - name: Cache datasets
164
        uses: actions/cache@v4
165
        with:
166
          path: Datasets
167
          key: pl-dataset
168

169
      - name: Sanity check
170
        run: |
171
          set -e
172
          python requirements/pytorch/check-avail-extras.py
173
          python -c "from torch import __version__ as ver; assert ver.startswith('${{ matrix.pytorch-version }}'), ver"
174

175
      - name: Adjust tests / env. -> PL
176
        if: ${{ matrix.pkg-name != 'lightning' }}
177
        run: |
178
          python .actions/assistant.py copy_replace_imports --source_dir="./tests" \
179
            --source_import="lightning.fabric,lightning.pytorch" \
180
            --target_import="lightning_fabric,pytorch_lightning"
181

182
      - name: Prevent using raw source
183
        run: rm -rf src/
184

185
      - name: Get legacy checkpoints
186
        run: |
187
          bash .actions/pull_legacy_checkpoints.sh
188
          cd tests/legacy
189
          bash generate_checkpoints.sh
190
          ls -l checkpoints/
191

192
      - name: Testing Warnings
193
        working-directory: tests/tests_pytorch
194
        # needs to run outside `pytest`
195
        run: python utilities/test_warnings.py
196

197
      - name: Testing PyTorch
198
        working-directory: tests/tests_pytorch
199
        # NOTE: do not include coverage report here, see: https://github.com/nedbat/coveragepy/issues/1003
200
        run: |
201
          echo $GITHUB_RUN_ID
202
          python -m coverage run --source ${{ env.COVERAGE_SCOPE }} \
203
            -m pytest . -v --timeout=60 --durations=50 --random-order-seed=$GITHUB_RUN_ID
204

205
      - name: Statistics
206
        if: success()
207
        working-directory: tests/tests_pytorch
208
        run: |
209
          coverage report
210
          coverage xml
211

212
      - name: Upload coverage to Codecov
213
        uses: codecov/codecov-action@v4
214
        # see: https://github.com/actions/toolkit/issues/399
215
        continue-on-error: true
216
        with:
217
          token: ${{ secrets.CODECOV_TOKEN }}
218
          file: tests/tests_pytorch/coverage.xml
219
          flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest-full,python${{ matrix.python-version }},pytorch${{ matrix.pytorch-version }}
220
          name: CPU-coverage
221
          fail_ci_if_error: false
222

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.