From 16853b46da337c8f9a4f51386d1c5eb690f337ad Mon Sep 17 00:00:00 2001 From: Sait Cakmak Date: Sat, 7 Sep 2024 06:15:41 -0700 Subject: [PATCH] Require PyTorch>=2.0.1, GPyTorch==1.13 and linear_operator==0.5.3 (#2511) Summary: As titled. Also includes some updates to test against stable workflow to make it pass. Pull Request resolved: https://github.com/pytorch/botorch/pull/2511 Test Plan: https://github.com/pytorch/botorch/actions/runs/10751171192 Reviewed By: esantorella Differential Revision: D62320479 Pulled By: saitcakmak fbshipit-source-id: 8442389ed79fc50e8612015548283405deda63b8 --- .conda/meta.yaml | 6 +++--- .github/workflows/reusable_tutorials.yml | 1 + .github/workflows/test_stable.yml | 21 +++++++++++++++------ README.md | 6 +++--- environment.yml | 6 +++--- requirements.txt | 6 +++--- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/.conda/meta.yaml b/.conda/meta.yaml index 04248a8886..a8c0e68baf 100644 --- a/.conda/meta.yaml +++ b/.conda/meta.yaml @@ -17,9 +17,9 @@ requirements: - setuptools - setuptools_scm run: - - pytorch >=1.13.1 - - gpytorch ==1.12 - - linear_operator ==0.5.2 + - pytorch >=2.0.1 + - gpytorch ==1.13 + - linear_operator ==0.5.3 - scipy - multipledispatch - pyro-ppl >=1.8.4 diff --git a/.github/workflows/reusable_tutorials.yml b/.github/workflows/reusable_tutorials.yml index 0b9aa1120b..f994f4bce3 100644 --- a/.github/workflows/reusable_tutorials.yml +++ b/.github/workflows/reusable_tutorials.yml @@ -54,6 +54,7 @@ jobs: min_torch_version=$(grep '\btorch[>=]=' ${req_txt} | sed 's/[^0-9.]//g') min_gpytorch_version=$(grep '\bgpytorch[>=]=' ${req_txt} | sed 's/[^0-9.]//g') min_linear_operator_version=$(grep '\blinear_operator[>=]=' ${req_txt} | sed 's/[^0-9.]//g') + pip install "numpy<2" # Numpy >2.0 is not compatible with PyTorch <2.2. pip install "torch==${min_torch_version}" "gpytorch==${min_gpytorch_version}" "linear_operator==${min_linear_operator_version}" torchvision - name: Install BoTorch with tutorials dependencies env: diff --git a/.github/workflows/test_stable.yml b/.github/workflows/test_stable.yml index 4294e165f1..1eabadd15b 100644 --- a/.github/workflows/test_stable.yml +++ b/.github/workflows/test_stable.yml @@ -38,10 +38,14 @@ jobs: conda install -y -c gpytorch gpytorch conda install -y -c conda-forge pyro-ppl>=1.8.4 pip install .[test] - - name: Unit tests + - name: Unit tests and coverage -- BoTorch shell: bash -l {0} run: | - pytest -ra + pytest -ra test/ --cov botorch/ --cov-report term-missing --cov-report xml:botorch_cov.xml + - name: Unit tests and coverage -- BoTorch Community + shell: bash -l {0} + run: | + pytest -ra test_community/ --cov botorch_community/ --cov-report term-missing --cov-report xml:botorch_community_cov.xml tests-and-coverage-min-req-pip: name: Tests and coverage min req. torch, gpytorch & linear_operator versions (pip, Python ${{ matrix.python-version }}, ${{ matrix.os }}) @@ -59,18 +63,23 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | + pip install setuptools # Needed for next line on Python 3.12. python setup.py egg_info req_txt="botorch.egg-info/requires.txt" min_torch_version=$(grep '\btorch[>=]=' ${req_txt} | sed 's/[^0-9.]//g') - # HACK around the fact that pytorch does not offer a mac binary for 1.13.1 for py3.11 - TODO: Remove when bumping torch to 2.0.1 - min_torch_version="$(if ${{ matrix.python-version == '3.11' }} && ${{ matrix.os == 'macos-14' }}; then echo "2.0.1"; else echo "${min_torch_version}"; fi)" + # The earliest PyTorch version on Python 3.12 is 2.2.0. + min_torch_version="$(if ${{ matrix.python-version == '3.12' }}; then echo "2.2.0"; else echo "${min_torch_version}"; fi)" min_gpytorch_version=$(grep '\bgpytorch[>=]=' ${req_txt} | sed 's/[^0-9.]//g') min_linear_operator_version=$(grep '\blinear_operator[>=]=' ${req_txt} | sed 's/[^0-9.]//g') + pip install "numpy<2" # Numpy >2.0 is not compatible with PyTorch <2.2. pip install "torch==${min_torch_version}" "gpytorch==${min_gpytorch_version}" "linear_operator==${min_linear_operator_version}" pip install .[test] - - name: Unit tests and coverage + - name: Unit tests and coverage -- BoTorch + run: | + pytest -ra test/ --cov botorch/ --cov-report term-missing --cov-report xml:botorch_cov.xml + - name: Unit tests and coverage -- BoTorch Community run: | - pytest -ra --cov=. --cov-report term-missing + pytest -ra test_community/ --cov botorch_community/ --cov-report term-missing --cov-report xml:botorch_community_cov.xml run_tutorials_stable_w_latest_ax: name: Run tutorials without smoke test on min req. versions of PyTorch & GPyTorch and latest Ax diff --git a/README.md b/README.md index 21ee4aebbd..d10fa94c66 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,9 @@ Optimization simply use Ax. **Installation Requirements** - Python >= 3.10 -- PyTorch >= 1.13.1 -- gpytorch == 1.12 -- linear_operator == 0.5.2 +- PyTorch >= 2.0.1 +- gpytorch == 1.13 +- linear_operator == 0.5.3 - pyro-ppl >= 1.8.4 - scipy - multiple-dispatch diff --git a/environment.yml b/environment.yml index f659c7b9c3..9957bcd731 100644 --- a/environment.yml +++ b/environment.yml @@ -4,9 +4,9 @@ channels: - gpytorch - conda-forge dependencies: - - pytorch>=1.13.1 - - gpytorch==1.12 - - linear_operator==0.5.2 + - pytorch>=2.0.1 + - gpytorch==1.13 + - linear_operator==0.5.3 - scipy - multipledispatch - pyro-ppl>=1.8.4 diff --git a/requirements.txt b/requirements.txt index c094eede8e..3fbe7d8a05 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ multipledispatch scipy mpmath>=0.19,<=1.3 -torch>=1.13.1 +torch>=2.0.1 pyro-ppl>=1.8.4 -gpytorch==1.12 -linear_operator==0.5.2 +gpytorch==1.13 +linear_operator==0.5.3