From 0550ce832d4bdac48579696b5b222e16039db1f1 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Fri, 25 Apr 2025 12:37:34 +0100 Subject: [PATCH 1/3] Updates for Pytorch 2.7 Signed-off-by: Eric Kerfoot --- .github/workflows/pythonapp-min.yml | 2 +- .github/workflows/pythonapp.yml | 2 +- docs/requirements.txt | 2 +- pyproject.toml | 4 ++-- requirements.txt | 3 +-- setup.cfg | 3 +-- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pythonapp-min.yml b/.github/workflows/pythonapp-min.yml index afc9f6f6d4..7bc2cb38fa 100644 --- a/.github/workflows/pythonapp-min.yml +++ b/.github/workflows/pythonapp-min.yml @@ -124,7 +124,7 @@ jobs: strategy: fail-fast: false matrix: - pytorch-version: ['2.3.1', '2.4.1', '2.5.1', 'latest'] + pytorch-version: ['2.4.1', '2.5.1', '2.6.0', 'latest'] timeout-minutes: 40 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 5d6fd06afa..536ae6d18a 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -155,7 +155,7 @@ jobs: # install the latest pytorch for testing # however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated # fresh torch installation according to pyproject.toml - python -m pip install torch>=2.3.0 torchvision + python -m pip install torch>=2.4.1 torchvision - name: Check packages run: | pip uninstall monai diff --git a/docs/requirements.txt b/docs/requirements.txt index b314e10640..c5cf0b5baa 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,5 @@ -f https://download.pytorch.org/whl/cpu/torch-2.3.0%2Bcpu-cp39-cp39-linux_x86_64.whl -torch>=2.3.0 +torch>=2.4.1 pytorch-ignite==0.4.11 numpy>=1.20 itk>=5.2 diff --git a/pyproject.toml b/pyproject.toml index 588d6d22d8..7c76814554 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,14 +2,14 @@ requires = [ "wheel", "setuptools", - "torch>=2.3.0", + "torch>=2.4.1", "ninja", "packaging" ] [tool.black] line-length = 120 -target-version = ['py38', 'py39', 'py310'] +target-version = ['py38', 'py39', 'py310', 'py311', 'py312'] include = '\.pyi?$' exclude = ''' ( diff --git a/requirements.txt b/requirements.txt index ad394ce807..f0d1f54083 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ -torch>=2.3.0; sys_platform != 'win32' -torch>=2.4.1; sys_platform == 'win32' +torch>=2.4.1 numpy>=1.24,<3.0 diff --git a/setup.cfg b/setup.cfg index 622e24abe9..fc415e6cc0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,8 +42,7 @@ setup_requires = ninja packaging install_requires = - torch>=2.3.0; sys_platform != 'win32' - torch>=2.4.1; sys_platform == 'win32' + torch>=2.4.1 numpy>=1.24,<3.0 [options.extras_require] From 00a2dbae4a3ffa9f4b9de811e9b396b59325c052 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Fri, 25 Apr 2025 12:47:47 +0100 Subject: [PATCH 2/3] Type fix? Signed-off-by: Eric Kerfoot --- monai/networks/schedulers/ddpm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/networks/schedulers/ddpm.py b/monai/networks/schedulers/ddpm.py index d64e11d379..5cff2c72c6 100644 --- a/monai/networks/schedulers/ddpm.py +++ b/monai/networks/schedulers/ddpm.py @@ -238,7 +238,7 @@ def step( pred_prev_sample = pred_original_sample_coeff * pred_original_sample + current_sample_coeff * sample # 6. Add noise - variance = 0 + variance: int | torch.Tensor = 0 if timestep > 0: noise = torch.randn( model_output.size(), From c978eaea1f6bab16e1717b44cd7f8b63d115aac7 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Fri, 25 Apr 2025 12:59:01 +0100 Subject: [PATCH 3/3] Remove py38 reference Signed-off-by: Eric Kerfoot --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7c76814554..76b26731bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ requires = [ [tool.black] line-length = 120 -target-version = ['py38', 'py39', 'py310', 'py311', 'py312'] +target-version = ['py39', 'py310', 'py311', 'py312'] include = '\.pyi?$' exclude = ''' (