From 57ac5483a0af9616d49d16f0cafbcf9601680f4d Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Sun, 13 Nov 2022 00:39:23 +0100 Subject: [PATCH] Upgrade CI to PyTorch 1.13 (#15403) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jirka Borovec Co-authored-by: Akihiro Nitta Co-authored-by: Carlos Mocholí Co-authored-by: Adrian Wälchli --- .github/checkgroup.yml | 54 +++++++++---------- .github/workflows/ci-lite-tests.yml | 30 +++++------ .github/workflows/ci-pytorch-tests.yml | 32 ++++++----- requirements/lite/base.txt | 2 +- requirements/pytorch/adjust-versions.py | 4 +- requirements/pytorch/base.txt | 2 +- requirements/pytorch/check-avail-extras.py | 11 ++-- .../pytorch/check-avail-strategies.py | 13 ++--- .../cli/app-template/tests/requirements.txt | 4 +- .../component-template/tests/requirements.txt | 4 +- .../plugins/precision/test_native_amp.py | 8 +-- 11 files changed, 82 insertions(+), 82 deletions(-) diff --git a/.github/checkgroup.yml b/.github/checkgroup.yml index c23bea48d99ce..af024a2fe543a 100644 --- a/.github/checkgroup.yml +++ b/.github/checkgroup.yml @@ -1,7 +1,4 @@ custom_service_name: "Lightning CI required checker" -# For security reasons, configuration is only loaded from the repository's default branch, -# changes made in pull requests from different branches or forks are ignored. This means that changes to this file -# will only be used after they are merged. subprojects: # SECTION: pytorch_lightning @@ -18,26 +15,25 @@ subprojects: - "setup.cfg" # includes pytest config - ".actions/**" checks: - # Note: updates here should be applied to the lightning_lite group - - "pl-cpu (macOS-11, pytorch, 3.8, 1.10)" - - "pl-cpu (macOS-11, pytorch, 3.9, 1.11)" - - "pl-cpu (macOS-11, pytorch, 3.10, 1.12)" - - "pl-cpu (macOS-11, pytorch, 3.10, 1.13, pre)" + - "pl-cpu (macOS-11, pytorch, 3.8, 1.11)" + - "pl-cpu (macOS-11, pytorch, 3.9, 1.12)" + - "pl-cpu (macOS-11, pytorch, 3.10, 1.13)" + - "pl-cpu (macOS-11, pytorch, 3.8, 1.10, oldest)" - "pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.10)" - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.11)" - - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.11)" - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.12)" - - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.13, pre)" + - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.13)" + - "pl-cpu (ubuntu-20.04, pytorch, 3.7, 1.10, oldest)" - "pl-cpu (windows-2022, pytorch, 3.9, 1.11)" - - "pl-cpu (windows-2022, pytorch, 3.10, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.12)" - - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" - - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" - - "pl-cpu (ubuntu-20.04, lightning, 3.10, 1.12)" - - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" + - "pl-cpu (windows-2022, pytorch, 3.10, 1.13)" + - "pl-cpu (windows-2022, pytorch, 3.7, 1.10, oldest)" - "pl-cpu (slow, macOS-11, pytorch, 3.7, 1.11)" - "pl-cpu (slow, ubuntu-20.04, pytorch, 3.7, 1.11)" - "pl-cpu (slow, windows-2022, pytorch, 3.7, 1.11)" + - "pl-cpu (macOS-11, lightning, 3.8, 1.13)" + - "pl-cpu (ubuntu-20.04, lightning, 3.8, 1.13)" + - "pl-cpu (windows-2022, lightning, 3.8, 1.13)" - id: "pytorch_lightning: Azure GPU" paths: @@ -145,7 +141,7 @@ subprojects: - "build-pl (3.9, 1.10, 11.3.1)" - "build-pl (3.9, 1.11, 11.3.1)" - "build-pl (3.9, 1.12, 11.6.1)" - # TODO: add 1.13 + - "build-pl (3.9, 1.13, 11.6.1)" - "build-xla (3.7, 1.12)" # SECTION: lightning_lite @@ -159,20 +155,22 @@ subprojects: - ".github/workflows/ci-lite-tests.yml" - ".actions/**" checks: - - "lite-cpu (macOS-11, lite, 3.9, 1.11)" - - "lite-cpu (macOS-11, lite, 3.8, 1.10)" - - "lite-cpu (macOS-11, lite, 3.10, 1.12)" - - "lite-cpu (macOS-11, lite, 3.10, 1.13, pre)" - - "lite-cpu (ubuntu-20.04, lite, 3.8, 1.11)" + - "lite-cpu (macOS-11, lite, 3.8, 1.11)" + - "lite-cpu (macOS-11, lite, 3.9, 1.12)" + - "lite-cpu (macOS-11, lite, 3.10, 1.13)" + - "lite-cpu (macOS-11, lite, 3.7, 1.10, oldest)" + - "lite-cpu (ubuntu-20.04, lite, 3.8, 1.10)" + - "lite-cpu (ubuntu-20.04, lite, 3.9, 1.11)" - "lite-cpu (ubuntu-20.04, lite, 3.10, 1.12)" - - "lite-cpu (ubuntu-20.04, lite, 3.9, 1.13, pre)" - - "lite-cpu (windows-2022, lite, 3.9, 1.10)" - - "lite-cpu (windows-2022, lite, 3.10, 1.11)" + - "lite-cpu (ubuntu-20.04, lite, 3.10, 1.13)" + - "lite-cpu (ubuntu-20.04, lite, 3.7, 1.10, oldest)" + - "lite-cpu (windows-2022, lite, 3.9, 1.11)" - "lite-cpu (windows-2022, lite, 3.10, 1.12)" - - "lite-cpu (windows-2022, lite, 3.8, 1.13, pre)" - - "lite-cpu (macOS-11, lightning, 3.8, 1.12)" - - "lite-cpu (ubuntu-20.04, lightning, 3.8, 1.12)" - - "lite-cpu (windows-2022, lightning, 3.8, 1.12)" + - "lite-cpu (windows-2022, lite, 3.10, 1.13)" + - "lite-cpu (windows-2022, lite, 3.7, 1.10, oldest)" + - "lite-cpu (macOS-11, lightning, 3.8, 1.13)" + - "lite-cpu (ubuntu-20.04, lightning, 3.8, 1.13)" + - "lite-cpu (windows-2022, lightning, 3.8, 1.13)" - id: "lightning_lite: Azure GPU" paths: diff --git a/.github/workflows/ci-lite-tests.yml b/.github/workflows/ci-lite-tests.yml index 6da2ee4274b04..d9fed28522b33 100644 --- a/.github/workflows/ci-lite-tests.yml +++ b/.github/workflows/ci-lite-tests.yml @@ -36,25 +36,25 @@ jobs: include: # assign python and pytorch version combinations to operating systems (arbitrarily) # note: there's no distribution of torch==1.10 for Python>=3.10 - - {os: "macOS-11", pkg-name: "lite", python-version: "3.9", pytorch-version: "1.11"} - - {os: "macOS-11", pkg-name: "lite", python-version: "3.8", pytorch-version: "1.10"} - - {os: "windows-2022", pkg-name: "lite", python-version: "3.10", pytorch-version: "1.11"} - - {os: "windows-2022", pkg-name: "lite", python-version: "3.9", pytorch-version: "1.10"} - - {os: "ubuntu-20.04", pkg-name: "lite", python-version: "3.8", pytorch-version: "1.11"} - # only run PyTorch latest with Python latest - - {os: "macOS-11", pkg-name: "lite", python-version: "3.10", pytorch-version: "1.12"} + - {os: "macOS-11", pkg-name: "lite", python-version: "3.8", pytorch-version: "1.11"} + - {os: "macOS-11", pkg-name: "lite", python-version: "3.9", pytorch-version: "1.12"} + - {os: "ubuntu-20.04", pkg-name: "lite", python-version: "3.8", pytorch-version: "1.10"} + - {os: "ubuntu-20.04", pkg-name: "lite", python-version: "3.9", pytorch-version: "1.11"} - {os: "ubuntu-20.04", pkg-name: "lite", python-version: "3.10", pytorch-version: "1.12"} + - {os: "windows-2022", pkg-name: "lite", python-version: "3.9", pytorch-version: "1.11"} - {os: "windows-2022", pkg-name: "lite", python-version: "3.10", pytorch-version: "1.12"} + # only run PyTorch latest with Python latest + - {os: "macOS-11", pkg-name: "lite", python-version: "3.10", pytorch-version: "1.13"} + - {os: "ubuntu-20.04", pkg-name: "lite", python-version: "3.10", pytorch-version: "1.13"} + - {os: "windows-2022", pkg-name: "lite", python-version: "3.10", pytorch-version: "1.13"} # "oldest" versions tests, only on minimum Python - # TODO: add back with 1.13 - # release-candidate tests, mixed Python versions - - {os: "macOS-11", pkg-name: "lite", python-version: "3.10", pytorch-version: "1.13", release: "pre"} - - {os: "ubuntu-20.04", pkg-name: "lite", python-version: "3.9", pytorch-version: "1.13", release: "pre"} - - {os: "windows-2022", pkg-name: "lite", python-version: "3.8", pytorch-version: "1.13", release: "pre"} + - {os: "macOS-11", pkg-name: "lite", python-version: "3.7", pytorch-version: "1.10", requires: "oldest"} + - {os: "ubuntu-20.04", pkg-name: "lite", python-version: "3.7", pytorch-version: "1.10", requires: "oldest"} + - {os: "windows-2022", pkg-name: "lite", python-version: "3.7", pytorch-version: "1.10", requires: "oldest"} # "lightning" installs the monolithic package - - {os: "macOS-11", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.12"} - - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.12"} - - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.12"} + - {os: "macOS-11", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.13"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.13"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.13"} timeout-minutes: 15 diff --git a/.github/workflows/ci-pytorch-tests.yml b/.github/workflows/ci-pytorch-tests.yml index 5bc4a48ef474b..18d698e2b72af 100644 --- a/.github/workflows/ci-pytorch-tests.yml +++ b/.github/workflows/ci-pytorch-tests.yml @@ -40,33 +40,31 @@ jobs: include: # assign python and pytorch version combinations to operating systems (arbitrarily) # note: there's no distribution of torch==1.10 for Python>=3.10 - - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.11"} - - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.10"} + - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.11"} + - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.12"} - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.10"} - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.11"} - - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.11"} - - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.10"} - - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.11"} - - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.11"} - # only run PyTorch latest with Python latest - - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.12"} - - {os: "macOS-11", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.12"} - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.12"} - - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.12"} + - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.11"} - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.12"} - - {os: "windows-2022", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.12"} + # only run PyTorch latest with Python latest + - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.13"} + - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.13"} + - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.13"} # "oldest" versions tests, only on minimum Python - # TODO: add back with 1.13 - # release-candidate tests, mixed Python versions - - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.13", release: "pre"} - - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.13", release: "pre"} - - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.13", release: "pre"} + - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.10", requires: "oldest"} # 3.7 hangs + - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.10", requires: "oldest"} + - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.10", requires: "oldest"} # run test under SLOW label - {type: "slow", os: "macOS-11", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.11"} - {type: "slow", os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.11"} - {type: "slow", os: "windows-2022", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.11"} + # "lightning" installs the monolithic package + - {os: "macOS-11", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.13"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.13"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.13"} - timeout-minutes: 60 + timeout-minutes: 70 # tests with macOS-11, py3.7 oldest takes much longer then expected steps: - uses: actions/checkout@v3 diff --git a/requirements/lite/base.txt b/requirements/lite/base.txt index 676837f04bda1..1b82742a78021 100644 --- a/requirements/lite/base.txt +++ b/requirements/lite/base.txt @@ -2,7 +2,7 @@ # in case you want to preserve/enforce restrictions on the latest compatible version, add "strict" as an in-line comment numpy>=1.17.2, <1.23.1 -torch>=1.10.*, <1.13.0 +torch>=1.10.*, <=1.13.0 fsspec[http]>2021.06.0, <2022.6.0 packaging>=17.0, <=21.3 typing-extensions>=4.0.0, <=4.4.0 diff --git a/requirements/pytorch/adjust-versions.py b/requirements/pytorch/adjust-versions.py index 59869df16ac31..c9ed4c0770427 100644 --- a/requirements/pytorch/adjust-versions.py +++ b/requirements/pytorch/adjust-versions.py @@ -5,8 +5,8 @@ # IMPORTANT: this list needs to be sorted in reverse VERSIONS = [ - dict(torch="1.13.0", torchvision="0.14.0"), # RC - dict(torch="1.12.1", torchvision="0.13.1"), # stable + dict(torch="1.13.0", torchvision="0.14.0"), # stable + dict(torch="1.12.1", torchvision="0.13.1"), dict(torch="1.12.0", torchvision="0.13.0"), dict(torch="1.11.0", torchvision="0.12.0"), dict(torch="1.10.2", torchvision="0.11.3"), diff --git a/requirements/pytorch/base.txt b/requirements/pytorch/base.txt index 5587b8db1963d..5da61d3fe1acc 100644 --- a/requirements/pytorch/base.txt +++ b/requirements/pytorch/base.txt @@ -2,7 +2,7 @@ # in case you want to preserve/enforce restrictions on the latest compatible version, add "strict" as an in-line comment numpy>=1.17.2, <1.23.1 -torch>=1.10.*, <1.13.0 +torch>=1.10.*, <=1.13.0 tqdm>=4.57.0, <4.65.0 PyYAML>=5.4, <=6.0 fsspec[http]>2021.06.0, <2022.8.0 diff --git a/requirements/pytorch/check-avail-extras.py b/requirements/pytorch/check-avail-extras.py index 9af53010b605b..3ab8d2848c3f0 100644 --- a/requirements/pytorch/check-avail-extras.py +++ b/requirements/pytorch/check-avail-extras.py @@ -1,5 +1,6 @@ -import hydra # noqa: F401 -import jsonargparse # noqa: F401 -import matplotlib # noqa: F401 -import omegaconf # noqa: F401 -import rich # noqa: F401 +if __name__ == "__main__": + import hydra # noqa: F401 + import jsonargparse # noqa: F401 + import matplotlib # noqa: F401 + import omegaconf # noqa: F401 + import rich # noqa: F401 diff --git a/requirements/pytorch/check-avail-strategies.py b/requirements/pytorch/check-avail-strategies.py index db28a1a1fe051..ffe12d024199b 100644 --- a/requirements/pytorch/check-avail-strategies.py +++ b/requirements/pytorch/check-avail-strategies.py @@ -1,7 +1,8 @@ -import bagua # noqa: F401 -import deepspeed # noqa: F401 -import fairscale # noqa: F401 -import horovod.torch +if __name__ == "__main__": + import bagua # noqa: F401 + import deepspeed # noqa: F401 + import fairscale # noqa: F401 + import horovod.torch -# returns an error code -assert horovod.torch.nccl_built() + # returns an error code + assert horovod.torch.nccl_built() diff --git a/src/lightning_app/cli/app-template/tests/requirements.txt b/src/lightning_app/cli/app-template/tests/requirements.txt index 984d177fbe16c..3185d1c44f033 100644 --- a/src/lightning_app/cli/app-template/tests/requirements.txt +++ b/src/lightning_app/cli/app-template/tests/requirements.txt @@ -1,8 +1,8 @@ coverage codecov>=2.1 -pytest>=3.0.5 +pytest>=5.0.0 pytest-cov pytest-flake8 flake8 check-manifest -twine==1.13.0 +twine==4.0.1 diff --git a/src/lightning_app/cli/component-template/tests/requirements.txt b/src/lightning_app/cli/component-template/tests/requirements.txt index 984d177fbe16c..3185d1c44f033 100644 --- a/src/lightning_app/cli/component-template/tests/requirements.txt +++ b/src/lightning_app/cli/component-template/tests/requirements.txt @@ -1,8 +1,8 @@ coverage codecov>=2.1 -pytest>=3.0.5 +pytest>=5.0.0 pytest-cov pytest-flake8 flake8 check-manifest -twine==1.13.0 +twine==4.0.1 diff --git a/tests/tests_lite/plugins/precision/test_native_amp.py b/tests/tests_lite/plugins/precision/test_native_amp.py index e766908910d3a..69f3f758a59a2 100644 --- a/tests/tests_lite/plugins/precision/test_native_amp.py +++ b/tests/tests_lite/plugins/precision/test_native_amp.py @@ -41,19 +41,21 @@ def test_native_amp_precision_bf16_min_torch(): def test_native_amp_precision_forward_context(): - """Test to ensure that the context manager correctly is set to CPU + bfloat16.""" + """Test to ensure that the context manager correctly is set to bfloat16 on CPU and CUDA.""" precision = NativeMixedPrecision(precision=16, device="cuda") assert precision.device == "cuda" assert isinstance(precision.scaler, torch.cuda.amp.GradScaler) assert torch.get_default_dtype() == torch.float32 with precision.forward_context(): - assert torch.get_autocast_gpu_dtype() == torch.float16 + # check with str due to a bug upstream: https://github.com/pytorch/pytorch/issues/65786 + assert str(torch.get_autocast_gpu_dtype()) in ("torch.float16", "torch.half") precision = NativeMixedPrecision(precision="bf16", device="cpu") assert precision.device == "cpu" assert precision.scaler is None with precision.forward_context(): - assert torch.get_autocast_cpu_dtype() == torch.bfloat16 + # check with str due to a bug upstream: https://github.com/pytorch/pytorch/issues/65786 + assert str(torch.get_autocast_cpu_dtype()) == str(torch.bfloat16) context_manager = precision._autocast_context_manager() assert isinstance(context_manager, torch.autocast)