Skip to content

uv in pytorch-version-tests.yml #3350 #3400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 36 additions & 47 deletions .github/workflows/pytorch-version-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,86 +6,75 @@ on:
# Run at 00:00 UTC Every Day
- cron: "0 0 * * *"
workflow_dispatch:
pull_request:
paths:
- ".github/workflows/pytorch-version-tests.yml"

jobs:
build:
runs-on: ubuntu-latest
env:
UV_SYSTEM_PIP: 1
CLEARML_OFFLINE_MODE: 1
CLEARML_API_HOST: http://localhost
CLEARML_WEB_HOST: http://localhost
CLEARML_FILES_HOST: http://localhost
timeout-minutes: 85
strategy:
max-parallel: 5
fail-fast: false
matrix:
python-version: [3.9, "3.10", "3.11"]
pytorch-version:
[2.5.1, 2.4.1, 2.3.1, 2.2.2, 1.13.1, 1.12.1, 1.10.0]
pytorch-version: [2.5.1, 2.4.1, 2.3.1, 2.2.2, 1.13.1, 1.12.1, 1.10.0]
exclude:
- pytorch-version: 1.10.0
python-version: "3.10"
- pytorch-version: 1.10.0
python-version: "3.11"

- pytorch-version: 1.11.0
python-version: "3.10"
- pytorch-version: 1.11.0
python-version: "3.11"
- pytorch-version: 1.12.1
python-version: "3.11"
# Conda fails to install cpuonly version and few cpu distributed tests are
# failing with unrelated errors
- pytorch-version: 1.13.1
python-version: "3.11"

steps:
- uses: actions/checkout@v4

- name: Get year & week number
id: get-date
run: echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT
shell: bash -l {0}

- name: Get pip cache dir
id: pip-cache
run: |
python3 -m pip install -U pip
echo "pip_cache=$(python3 -m pip cache dir)" >> $GITHUB_OUTPUT
shell: bash -l {0}

- uses: actions/cache@v3
with:
path: |
~/conda_pkgs_dir
${{ steps.pip-cache.outputs.pip_cache }}
key: ${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-version }}-${{ hashFiles('requirements-dev.txt') }}
restore-keys: |
${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-version }}-

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
path: ~/.cache/uv
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements-dev.txt') }}
- name: Install uv and Python
uses: astral-sh/setup-uv@v5
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!

- name: Install dependencies
shell: bash -l {0}
- name: Install PyTorch ${{ matrix.pytorch-version }}
run: |
conda install pytorch=${{ matrix.pytorch-version }} torchvision cpuonly python=${{ matrix.python-version }} -c pytorch
if [[ "${{ matrix.pytorch-version }}" == 2.* || "${{ matrix.pytorch-version }}" == 1.13* || "${{ matrix.pytorch-version }}" == 1.12* || "${{ matrix.pytorch-version }}" == 1.10* ]]; then
uv pip install torch==${{ matrix.pytorch-version }} torchvision --extra-index-url https://download.pytorch.org/whl/cpu
else
uv pip install torch==${{ matrix.pytorch-version }} torchvision
fi
uv pip install setuptools

# We should install numpy<2.0 for pytorch<2.3
numpy_one_pth_version=$(python -c "import torch; print(float('.'.join(torch.__version__.split('.')[:2])) < 2.3)")
if [ "${numpy_one_pth_version}" == "True" ]; then
pip install -U "numpy<2.0"
- name: Install numpy conditionally for PyTorch < 2.3
run: |
version=$(python -c "import torch; print(float('.'.join(torch.__version__.split('.')[:2])))")
if (( $(echo "$version < 2.3" | bc -l) )); then
uv pip install "numpy<2.0"
fi

pip install -r requirements-dev.txt
python setup.py install
- name: Install Ignite dependencies
run: |
uv pip install -r requirements-dev.txt
uv pip install -e .

# pytorch>=1.9.0,<1.11.0 is using "from setuptools import distutils; distutils.version.LooseVersion" anti-pattern
# which raises the error: AttributeError: module 'distutils' has no attribute 'version' for setuptools>59
bad_pth_version=$(python -c "import torch; print('.'.join(torch.__version__.split('.')[:2]) in ['1.9', '1.10'])")
if [ "${bad_pth_version}" == "True" ]; then
pip install --upgrade "setuptools<59"
python -c "from setuptools import distutils; distutils.version.LooseVersion"
# Patch setuptools for old PyTorch versions
version=$(python -c "import torch; print('.'.join(torch.__version__.split('.')[:2]))")
if [[ "$version" == "1.9" || "$version" == "1.10" ]]; then
uv pip install "setuptools<59"
fi

- name: Download MNIST
Expand All @@ -99,8 +88,8 @@ jobs:
max_attempts: 5
timeout_minutes: 15
shell: bash
command: bash -l tests/run_cpu_tests.sh "not test_time_profilers"
new_command_on_retry: USE_LAST_FAILED=1 bash -l tests/run_cpu_tests.sh "not test_time_profilers"
command: bash tests/run_cpu_tests.sh "not test_time_profilers"
new_command_on_retry: USE_LAST_FAILED=1 bash tests/run_cpu_tests.sh "not test_time_profilers"

create-issue:
runs-on: ubuntu-latest
Expand Down
Loading