Skip to content

Commit ba188e2

Browse files
marksgrahamKumoLiukvtttheyufan1995binliunls
authored
monai generative: refactor autoencoderkl (#7552)
Part of the refactoring in #7227 ### Description Refactors autoencoderkl. Changes are: - Introduce `CastToTempType` class for upsampling - `Downsample` block removed and replaced by a `Sequential` - The attention block now uses MONAI's `SABlock`, allowing a lot of code to be removed - Added a `load_old_state_dict` that allows for models trained on MONAI Generative to be loaded in to this model, especially important given some of the MONAI Generative's [model zoo](https://github.com/Project-MONAI/GenerativeModels/tree/main/model-zoo) uses this model. I have tested this works locally. I discussed with @ericspod inheriting from `AutoEncoder` but after experimentation have decided against it as it introduced changes that made it very hard to ensure we could load model's trained in MONAI Generative. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [x] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: KumoLiu <[email protected]> Signed-off-by: kaibo <[email protected]> Signed-off-by: heyufan1995 <[email protected]> Signed-off-by: YunLiu <[email protected]> Signed-off-by: binliu <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: axel.vlaminck <[email protected]> Signed-off-by: monai-bot <[email protected]> Signed-off-by: Ibrahim Hadzic <[email protected]> Signed-off-by: Behrooz <[email protected]> Signed-off-by: Timothy Baker <[email protected]> Signed-off-by: Mathijs de Boer <[email protected]> Signed-off-by: Fabian Klopfer <[email protected]> Signed-off-by: Lucas Robinet <[email protected]> Signed-off-by: Lucas Robinet <[email protected]> Signed-off-by: chaoliu <[email protected]> Signed-off-by: cxlcl <[email protected]> Signed-off-by: chaoliu <[email protected]> Signed-off-by: Suraj Pai <[email protected]> Signed-off-by: Juan Pablo de la Cruz Gutiérrez <[email protected]> Signed-off-by: elitap <[email protected]> Signed-off-by: Felix Schnabel <[email protected]> Signed-off-by: YanxuanLiu <[email protected]> Signed-off-by: ytl0623 <[email protected]> Signed-off-by: Dženan Zukić <[email protected]> Signed-off-by: Ishan Dutta <[email protected]> Signed-off-by: John Zielke <[email protected]> Signed-off-by: Mingxin Zheng <[email protected]> Signed-off-by: Vladimir Chernyi <[email protected]> Signed-off-by: Yiheng Wang <[email protected]> Signed-off-by: Szabolcs Botond Lorincz Molnar <[email protected]> Signed-off-by: Mark Graham <[email protected]> Signed-off-by: Lucas Robinet <[email protected]> Signed-off-by: Mingxin <[email protected]> Signed-off-by: Han Wang <[email protected]> Signed-off-by: Konstantin Sukharev <[email protected]> Co-authored-by: YunLiu <[email protected]> Co-authored-by: Kaibo Tang <[email protected]> Co-authored-by: Yufan He <[email protected]> Co-authored-by: binliunls <[email protected]> Co-authored-by: Ben Murray <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Eric Kerfoot <[email protected]> Co-authored-by: axel.vlaminck <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Mingxin Zheng <[email protected]> Co-authored-by: monai-bot <[email protected]> Co-authored-by: Ibrahim Hadzic <[email protected]> Co-authored-by: Dr. Behrooz Hashemian <[email protected]> Co-authored-by: Timothy J. Baker <[email protected]> Co-authored-by: Mathijs de Boer <[email protected]> Co-authored-by: Mathijs de Boer <[email protected]> Co-authored-by: Fabian Klopfer <[email protected]> Co-authored-by: Yiheng Wang <[email protected]> Co-authored-by: Lucas Robinet <[email protected]> Co-authored-by: Lucas Robinet <[email protected]> Co-authored-by: cxlcl <[email protected]> Co-authored-by: Suraj Pai <[email protected]> Co-authored-by: Juampa <[email protected]> Co-authored-by: elitap <[email protected]> Co-authored-by: Felix Schnabel <[email protected]> Co-authored-by: YanxuanLiu <[email protected]> Co-authored-by: ytl0623 <[email protected]> Co-authored-by: Dženan Zukić <[email protected]> Co-authored-by: Ishan Dutta <[email protected]> Co-authored-by: johnzielke <[email protected]> Co-authored-by: Vladimir Chernyi <[email protected]> Co-authored-by: Lőrincz-Molnár Szabolcs-Botond <[email protected]> Co-authored-by: Nic Ma <[email protected]> Co-authored-by: Lucas Robinet <[email protected]> Co-authored-by: Han Wang <[email protected]> Co-authored-by: Konstantin Sukharev <[email protected]>
1 parent f15a173 commit ba188e2

File tree

810 files changed

+4480
-1126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

810 files changed

+4480
-1126
lines changed

.github/workflows/chatops.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: dispatch
13-
uses: peter-evans/slash-command-dispatch@v3.0.2
13+
uses: peter-evans/slash-command-dispatch@v4.0.0
1414
with:
1515
token: ${{ secrets.PR_MAINTAIN }}
1616
reaction-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/conda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
steps:
2727
- if: runner.os == 'windows'
2828
name: Config pagefile (Windows only)
29-
uses: al-cheb/configure-pagefile-action@v1.3
29+
uses: al-cheb/configure-pagefile-action@v1.4
3030
with:
3131
minimum-size: 8GB
3232
maximum-size: 16GB

.github/workflows/cron-ngc-bundle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
id: pip-cache
2727
run: echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
2828
- name: cache for pip
29-
uses: actions/cache@v3
29+
uses: actions/cache@v4
3030
id: cache
3131
with:
3232
path: ~/.cache/pip

.github/workflows/cron.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ jobs:
1919
- "PTLATEST+CUDA121"
2020
include:
2121
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes
22-
- environment: PT191+CUDA113
23-
pytorch: "torch==1.9.1 torchvision==0.10.1 --extra-index-url https://download.pytorch.org/whl/cu113"
24-
base: "nvcr.io/nvidia/pytorch:21.06-py3" # CUDA 11.3
2522
- environment: PT110+CUDA113
2623
pytorch: "torch==1.10.2 torchvision==0.11.3 --extra-index-url https://download.pytorch.org/whl/cu113"
2724
base: "nvcr.io/nvidia/pytorch:21.06-py3" # CUDA 11.3
2825
- environment: PT113+CUDA113
2926
pytorch: "torch==1.13.1 torchvision==0.14.1 --extra-index-url https://download.pytorch.org/whl/cu113"
3027
base: "nvcr.io/nvidia/pytorch:21.06-py3" # CUDA 11.3
31-
- environment: PTLATEST+CUDA121
32-
pytorch: "-U torch torchvision --extra-index-url https://download.pytorch.org/whl/cu118"
28+
- environment: PT113+CUDA122
29+
pytorch: "torch==1.13.1 torchvision==0.14.1 --extra-index-url https://download.pytorch.org/whl/cu121"
3330
base: "nvcr.io/nvidia/pytorch:23.08-py3" # CUDA 12.2
31+
- environment: PTLATEST+CUDA124
32+
pytorch: "-U torch torchvision --extra-index-url https://download.pytorch.org/whl/cu121"
33+
base: "nvcr.io/nvidia/pytorch:24.03-py3" # CUDA 12.4
3434
container:
3535
image: ${{ matrix.base }}
3636
options: "--gpus all"
@@ -67,7 +67,7 @@ jobs:
6767
if pgrep python; then pkill python; fi
6868
shell: bash
6969
- name: Upload coverage
70-
uses: codecov/codecov-action@v3
70+
uses: codecov/codecov-action@v4
7171
with:
7272
fail_ci_if_error: false
7373
files: ./coverage.xml
@@ -76,7 +76,7 @@ jobs:
7676
if: github.repository == 'Project-MONAI/MONAI'
7777
strategy:
7878
matrix:
79-
container: ["pytorch:22.10", "pytorch:23.08"]
79+
container: ["pytorch:23.08", "pytorch:24.03"]
8080
container:
8181
image: nvcr.io/nvidia/${{ matrix.container }}-py3 # testing with the latest pytorch base image
8282
options: "--gpus all"
@@ -111,7 +111,7 @@ jobs:
111111
if pgrep python; then pkill python; fi
112112
shell: bash
113113
- name: Upload coverage
114-
uses: codecov/codecov-action@v3
114+
uses: codecov/codecov-action@v4
115115
with:
116116
fail_ci_if_error: false
117117
files: ./coverage.xml
@@ -121,7 +121,7 @@ jobs:
121121
if: github.repository == 'Project-MONAI/MONAI'
122122
strategy:
123123
matrix:
124-
container: ["pytorch:23.08"]
124+
container: ["pytorch:24.03"]
125125
container:
126126
image: nvcr.io/nvidia/${{ matrix.container }}-py3 # testing with the latest pytorch base image
127127
options: "--gpus all"
@@ -212,7 +212,7 @@ jobs:
212212
if pgrep python; then pkill python; fi
213213
shell: bash
214214
- name: Upload coverage
215-
uses: codecov/codecov-action@v3
215+
uses: codecov/codecov-action@v4
216216
with:
217217
fail_ci_if_error: false
218218
files: ./coverage.xml
@@ -221,7 +221,7 @@ jobs:
221221
if: github.repository == 'Project-MONAI/MONAI'
222222
needs: cron-gpu # so that monai itself is verified first
223223
container:
224-
image: nvcr.io/nvidia/pytorch:23.08-py3 # testing with the latest pytorch base image
224+
image: nvcr.io/nvidia/pytorch:24.03-py3 # testing with the latest pytorch base image
225225
options: "--gpus all --ipc=host"
226226
runs-on: [self-hosted, linux, x64, integration]
227227
steps:

.github/workflows/docker.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ jobs:
1717
versioning_dev:
1818
# compute versioning file from python setup.py
1919
# upload as artifact
20-
if: github.repository == 'Project-MONAI/MONAI'
20+
# if: github.repository == 'Project-MONAI/MONAI'
21+
if: ${{ false }} # disable docker build job project-monai/monai#7450
2122
runs-on: ubuntu-latest
2223
steps:
2324
- uses: actions/checkout@v4
@@ -47,8 +48,8 @@ jobs:
4748
rm -rf {*,.[^.]*}
4849
4950
docker_build_dev:
50-
# builds projectmonai/monai:latest
51-
if: github.repository == 'Project-MONAI/MONAI'
51+
# if: github.repository == 'Project-MONAI/MONAI'
52+
if: ${{ false }} # disable docker build job project-monai/monai#7450
5253
needs: versioning_dev
5354
runs-on: ubuntu-latest
5455
steps:
@@ -62,7 +63,7 @@ jobs:
6263
- name: docker_build
6364
shell: bash
6465
run: |
65-
rm -rf /opt/hostedtoolcache
66+
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
6667
docker --version
6768
# get tag info for versioning
6869
cat _version.py

.github/workflows/integration.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
id: pip-cache
2323
run: echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
2424
- name: cache for pip
25-
uses: actions/cache@v3
25+
uses: actions/cache@v4
2626
id: cache
2727
with:
2828
path: |
@@ -71,7 +71,7 @@ jobs:
7171
run: ./runtests.sh --build --net
7272

7373
- name: Add reaction
74-
uses: peter-evans/create-or-update-comment@v3
74+
uses: peter-evans/create-or-update-comment@v4
7575
with:
7676
token: ${{ secrets.PR_MAINTAIN }}
7777
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
@@ -95,7 +95,7 @@ jobs:
9595
id: pip-cache
9696
run: echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
9797
- name: cache for pip
98-
uses: actions/cache@v3
98+
uses: actions/cache@v4
9999
id: cache
100100
with:
101101
path: |
@@ -151,7 +151,7 @@ jobs:
151151
python -m tests.test_integration_gpu_customization
152152
153153
- name: Add reaction
154-
uses: peter-evans/create-or-update-comment@v3
154+
uses: peter-evans/create-or-update-comment@v4
155155
with:
156156
token: ${{ secrets.PR_MAINTAIN }}
157157
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}

.github/workflows/pythonapp-gpu.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ jobs:
2929
- "PT210+CUDA121DOCKER"
3030
include:
3131
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes
32-
- environment: PT19+CUDA114DOCKER
33-
# 21.10: 1.10.0a0+0aef44c
34-
pytorch: "-h" # we explicitly set pytorch to -h to avoid pip install error
35-
base: "nvcr.io/nvidia/pytorch:21.10-py3"
3632
- environment: PT110+CUDA111
3733
pytorch: "torch==1.10.2 torchvision==0.11.3 --extra-index-url https://download.pytorch.org/whl/cu111"
3834
base: "nvcr.io/nvidia/cuda:11.1.1-devel-ubuntu18.04"
@@ -47,6 +43,10 @@ jobs:
4743
# 23.08: 2.1.0a0+29c30b1
4844
pytorch: "-h" # we explicitly set pytorch to -h to avoid pip install error
4945
base: "nvcr.io/nvidia/pytorch:23.08-py3"
46+
- environment: PT210+CUDA121DOCKER
47+
# 24.03: 2.3.0a0+40ec155e58.nv24.3
48+
pytorch: "-h" # we explicitly set pytorch to -h to avoid pip install error
49+
base: "nvcr.io/nvidia/pytorch:24.03-py3"
5050
container:
5151
image: ${{ matrix.base }}
5252
options: --gpus all --env NVIDIA_DISABLE_REQUIRE=true # workaround for unsatisfied condition: cuda>=11.6
@@ -137,6 +137,6 @@ jobs:
137137
shell: bash
138138
- name: Upload coverage
139139
if: ${{ github.head_ref != 'dev' && github.event.pull_request.merged != true }}
140-
uses: codecov/codecov-action@v3
140+
uses: codecov/codecov-action@v4
141141
with:
142142
files: ./coverage.xml

.github/workflows/pythonapp-min.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
4545
shell: bash
4646
- name: cache for pip
47-
uses: actions/cache@v3
47+
uses: actions/cache@v4
4848
id: cache
4949
with:
5050
path: ${{ steps.pip-cache.outputs.dir }}
@@ -90,7 +90,7 @@ jobs:
9090
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
9191
shell: bash
9292
- name: cache for pip
93-
uses: actions/cache@v3
93+
uses: actions/cache@v4
9494
id: cache
9595
with:
9696
path: ${{ steps.pip-cache.outputs.dir }}
@@ -135,7 +135,7 @@ jobs:
135135
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
136136
shell: bash
137137
- name: cache for pip
138-
uses: actions/cache@v3
138+
uses: actions/cache@v4
139139
id: cache
140140
with:
141141
path: ${{ steps.pip-cache.outputs.dir }}

.github/workflows/pythonapp.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: |
3737
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
3838
- name: cache for pip
39-
uses: actions/cache@v3
39+
uses: actions/cache@v4
4040
id: cache
4141
with:
4242
path: ~/.cache/pip
@@ -62,7 +62,7 @@ jobs:
6262
steps:
6363
- if: runner.os == 'windows'
6464
name: Config pagefile (Windows only)
65-
uses: al-cheb/configure-pagefile-action@v1.3
65+
uses: al-cheb/configure-pagefile-action@v1.4
6666
with:
6767
minimum-size: 8GB
6868
maximum-size: 16GB
@@ -83,7 +83,7 @@ jobs:
8383
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
8484
shell: bash
8585
- name: cache for pip
86-
uses: actions/cache@v3
86+
uses: actions/cache@v4
8787
id: cache
8888
with:
8989
path: ${{ steps.pip-cache.outputs.dir }}
@@ -136,7 +136,7 @@ jobs:
136136
run: |
137137
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
138138
- name: cache for pip
139-
uses: actions/cache@v3
139+
uses: actions/cache@v4
140140
id: cache
141141
with:
142142
path: |
@@ -217,7 +217,7 @@ jobs:
217217
run: |
218218
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
219219
- name: cache for pip
220-
uses: actions/cache@v3
220+
uses: actions/cache@v4
221221
id: cache
222222
with:
223223
path: |

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
python -m pip install --user --upgrade setuptools wheel
2828
- name: Build and test source archive and wheel file
2929
run: |
30-
rm -rf /opt/hostedtoolcache
30+
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
3131
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
3232
root_dir=$PWD
3333
echo "$root_dir"
@@ -102,7 +102,7 @@ jobs:
102102
python-version: '3.9'
103103
- shell: bash
104104
run: |
105-
rm -rf /opt/hostedtoolcache
105+
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
106106
git describe
107107
python -m pip install --user --upgrade setuptools wheel
108108
python setup.py build
@@ -143,7 +143,7 @@ jobs:
143143
RELEASE_VERSION: ${{ steps.versioning.outputs.tag }}
144144
shell: bash
145145
run: |
146-
rm -rf /opt/hostedtoolcache
146+
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
147147
# get tag info for versioning
148148
mv _version.py monai/
149149
# version checks

.github/workflows/setupapp.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
3636
- name: cache for pip
3737
if: ${{ startsWith(github.ref, 'refs/heads/dev') }}
38-
uses: actions/cache@v3
38+
uses: actions/cache@v4
3939
id: cache
4040
with:
4141
path: |
@@ -68,7 +68,7 @@ jobs:
6868
if pgrep python; then pkill python; fi
6969
shell: bash
7070
- name: Upload coverage
71-
uses: codecov/codecov-action@v3
71+
uses: codecov/codecov-action@v4
7272
with:
7373
fail_ci_if_error: false
7474
files: ./coverage.xml
@@ -91,7 +91,7 @@ jobs:
9191
run: |
9292
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
9393
- name: cache for pip
94-
uses: actions/cache@v3
94+
uses: actions/cache@v4
9595
id: cache
9696
with:
9797
path: |
@@ -100,7 +100,7 @@ jobs:
100100
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ steps.pip-cache.outputs.datew }}
101101
- name: Install the dependencies
102102
run: |
103-
rm -rf /opt/hostedtoolcache
103+
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
104104
python -m pip install --upgrade pip wheel
105105
python -m pip install -r requirements-dev.txt
106106
- name: Run quick tests CPU ubuntu
@@ -111,7 +111,7 @@ jobs:
111111
BUILD_MONAI=1 ./runtests.sh --build --quick --min
112112
coverage xml --ignore-errors
113113
- name: Upload coverage
114-
uses: codecov/codecov-action@v3
114+
uses: codecov/codecov-action@v4
115115
with:
116116
fail_ci_if_error: false
117117
files: ./coverage.xml
@@ -128,7 +128,7 @@ jobs:
128128
run: |
129129
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
130130
- name: cache for pip
131-
uses: actions/cache@v3
131+
uses: actions/cache@v4
132132
id: cache
133133
with:
134134
path: |
@@ -146,7 +146,7 @@ jobs:
146146
- name: Install the default branch with build (dev branch only)
147147
if: github.ref == 'refs/heads/dev'
148148
run: |
149-
rm -rf /opt/hostedtoolcache
149+
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
150150
BUILD_MONAI=1 pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
151151
python -c 'import monai; monai.config.print_config()'
152152
- name: Get the test cases (dev branch only)

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
- id: end-of-file-fixer
2828
- id: mixed-line-ending
2929
- repo: https://github.com/charliermarsh/ruff-pre-commit
30-
rev: v0.0.261
30+
rev: v0.3.5
3131
hooks:
3232
- id: ruff
3333
args:
@@ -58,7 +58,7 @@ repos:
5858
name: Unused noqa
5959
additional_dependencies:
6060
- flake8>=3.8.1
61-
- flake8-bugbear
61+
- flake8-bugbear<=24.2.6
6262
- flake8-comprehensions
6363
- pep8-naming
6464
exclude: |

0 commit comments

Comments
 (0)