Skip to content

Commit f3f49ff

Browse files
committed
fix: revert return_state_dict change; update R5/R8 diagnostics
- Revert return_state_dict=False from endoscopic_inbody_classification.ipynb: the upstream MONAI dev (≥1.5) removed the deprecated param entirely and load() now returns nn.Module by default. The extra kwarg caused a TypeError in CI. The original notebook is correct for MONAI ≥1.5. - Update diagnose_1_6_release.md: - R5: clarify it is a local-only issue (our MONAI @ 19cab577 still has the deprecated return_state_dict=True default; upstream dev does not) - R8: mark confirmed fixed — isolated run with --ulimit nofile=65536:65536 completed all 39 cells in 3m1s with no ancdata error (2026-06-11) Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
1 parent 252b9d6 commit f3f49ff

2 files changed

Lines changed: 30 additions & 27 deletions

File tree

computer_assisted_intervention/endoscopic_inbody_classification.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@
347347
"id": "4784fe9e",
348348
"metadata": {},
349349
"outputs": [],
350-
"source": "max_epochs = 5\n\n# return_state_dict=False returns the nn.Module rather than a raw OrderedDict (MONAI 1.6 API)\npretrained_model = monai.bundle.load(name=\"endoscopic_inbody_classification\", bundle_dir=\"./\", return_state_dict=False)\n\npretrained_model.train()\nlosses = []\n\nfor _ in trange(max_epochs):\n epoch_loss = 0\n for data in train_dataloader:\n inputs, labels = data[\"image\"].to(device), data[\"label\"].to(device)\n optimizer.zero_grad()\n predictions = pretrained_model(inputs)\n loss_iter = loss(predictions, labels)\n loss_iter.backward()\n optimizer.step()\n epoch_loss += loss_iter.item()\n losses.append(epoch_loss / len(train_dataloader))\n\nfig, ax = plt.subplots(1, 1, figsize=(6, 6), facecolor=\"white\")\nax.set_xlabel(\"Epoch\")\nepochs = list(range(len(losses)))\nax.plot(epochs, losses, label=\"loss\")\nplt.legend()\nplt.show()"
350+
"source": "max_epochs = 5\n\npretrained_model = monai.bundle.load(name=\"endoscopic_inbody_classification\", bundle_dir=\"./\")\n\npretrained_model.train()\nlosses = []\n\nfor _ in trange(max_epochs):\n epoch_loss = 0\n for data in train_dataloader:\n inputs, labels = data[\"image\"].to(device), data[\"label\"].to(device)\n optimizer.zero_grad()\n predictions = pretrained_model(inputs)\n loss_iter = loss(predictions, labels)\n loss_iter.backward()\n optimizer.step()\n epoch_loss += loss_iter.item()\n losses.append(epoch_loss / len(train_dataloader))\n\nfig, ax = plt.subplots(1, 1, figsize=(6, 6), facecolor=\"white\")\nax.set_xlabel(\"Epoch\")\nepochs = list(range(len(losses)))\nax.plot(epochs, losses, label=\"loss\")\nplt.legend()\nplt.show()"
351351
},
352352
{
353353
"cell_type": "markdown",
@@ -407,4 +407,4 @@
407407
},
408408
"nbformat": 4,
409409
"nbformat_minor": 5
410-
}
410+
}

diagnose_1_6_release.md

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -318,28 +318,25 @@ eccefc57 (+143 commits) which may already include it, or the notebook needs upda
318318
**Fix:** Cherry-pick the Restormer commit into the dev branch, or add the
319319
notebook to `skip_run_papermill` until the class is merged.
320320

321-
#### Group R5 — MONAI `bundle.load` API change (1 notebook)
321+
#### Group R5 — MONAI `bundle.load` API — local-only issue (1 notebook)
322322

323-
| Notebook | Error |
323+
| Notebook | Error (local MONAI dev @ 19cab577 only) |
324324
|---|---|
325325
| `computer_assisted_intervention/endoscopic_inbody_classification.ipynb` | `AttributeError: 'collections.OrderedDict' object has no attribute 'train'` |
326326

327-
`monai.bundle.load(name="endoscopic_inbody_classification")` returns an
328-
`OrderedDict` (the raw state dict) in our branch but the notebook calls
329-
`.train()` on it expecting a full `nn.Module`.
327+
`monai.bundle.load()` in our local MONAI dev branch (19cab577) has
328+
`@deprecated_arg("return_state_dict", since="1.2", removed="1.5")` with
329+
`return_state_dict=True` still active as the default, so it returns an
330+
`OrderedDict` instead of an `nn.Module`.
330331

331-
**Fix (notebook):** Replace
332-
```python
333-
pretrained_model = monai.bundle.load(name="endoscopic_inbody_classification", bundle_dir="./")
334-
pretrained_model.train()
335-
```
336-
with
337-
```python
338-
bundle = monai.bundle.load(name="endoscopic_inbody_classification", bundle_dir="./",
339-
return_state_dict=False) # or use BundleWorkflow
340-
```
341-
**Fix (MONAI):** Verify whether `bundle.load` is supposed to return a model or a
342-
state dict and align the API with the notebook expectation.
332+
**This is a local-environment-only issue.** The upstream MONAI dev branch
333+
(eccefc57, used by CI and the upstream Docker image) removed the
334+
`return_state_dict` parameter in MONAI 1.5, and `load()` now returns `nn.Module`
335+
by default. The notebook is correct as-is for any MONAI ≥ 1.5.
336+
337+
**No notebook fix needed.** The `return_state_dict=False` workaround that was
338+
previously applied broke CI because the upstream MONAI does not accept that
339+
parameter at all (`TypeError: unexpected keyword argument`). It has been reverted.
343340

344341
#### Group R6 — Missing `aim` package (1 notebook)
345342

@@ -377,8 +374,14 @@ This happens when the per-process open-file-descriptor limit is too low
377374
(Docker default: 1024; DataLoader workers need ~65 k).
378375

379376
**Fix:** Add `--ulimit nofile=65536:65536` to the docker run command (already
380-
reflected in the working command above). Confirmed fixed in rerun
381-
`runner_output_rerun_r2r7r8.logs`.
377+
reflected in the working command above).
378+
379+
**Rerun note:** The targeted rerun (`runner_output_rerun_r2r7r8.logs`) ran `public_datasets` in
380+
the same container as `deep_atlas`. That notebook pip-installs packages which upgraded `urllib3`
381+
to 2.x; `papermill` then failed to import immediately (`ModuleNotFoundError: No module named
382+
'urllib3.packages.six.moves'`) — a run-order contamination, **not** the ancdata fix being tested.
383+
**Confirmed fixed** in isolated run (container with `--ulimit nofile=65536:65536`, no shared
384+
container): all 39 cells passed, `real 3m1s`. No `ancdata` error observed.
382385

383386
#### Group R9 — MissingKeyword (1 notebook)
384387

@@ -394,12 +397,12 @@ Known issue (documented in Category 2 above). Add to `doesnt_contain_max_epochs`
394397

395398
1. **Pin `mlflow<3.0`** in the Dockerfile — fixes 4 notebooks (Group R1). ✓ DONE (PR #8912)
396399
2. **R2 is a run-order artifact** — not applicable on this host (39 GB free, data cached).
397-
3. **`--ulimit nofile=65536:65536`** added to working docker run command — fixes R8. ✓ DONE
400+
3. **`--ulimit nofile=65536:65536`** added to working docker run command — fixes R8. ✓ DONE (confirmed clean run 3m1s)
398401
4. **PEP8 autofix** — all three notebooks autofixed with `runner.sh --autofix`. ✓ DONE
399402
5. **Fix MissingKeyword**`msd_crossval_datalist_generator.ipynb` added to exemption list. ✓ DONE (PR #2065)
400403
6. **Pin `transformers<5.0`** — fixes R3. ✓ DONE (PR #8912)
401404
7. **Add `aim`** to `requirements-dev.txt` — fixes R6. ✓ DONE (PR #8912)
402-
8. **Fix `bundle.load` API** (R5) — `return_state_dict=False` added to notebook. ✓ DONE (PR #2065)
405+
8. **R5 is local-only** — no notebook fix needed; upstream MONAI ≥ 1.5 removed the deprecated param and `load()` returns `nn.Module` directly. ✓ CONFIRMED (reverted wrong fix)
403406
9. **Skip `image_restoration.ipynb`** until Restormer is merged (R4). ✓ DONE (PR #2065)
404407
10. **Fix R7**`pytorch-lightning>=2.1` pin in `bundle/05_spleen_segmentation_lightning.ipynb`. ✓ DONE (PR #2065)
405408

@@ -409,11 +412,11 @@ Known issue (documented in Category 2 above). Add to `doesnt_contain_max_epochs`
409412
|---|---|---|---|
410413
| High | Pin `mlflow<3.0` (Dockerfile rebuild) | +4 passes | ✓ Done (PR #8912) |
411414
| High | R2 disk-full | +4 passes | ✓ Not an issue (run-order artifact) |
412-
| Medium | `--ulimit nofile=65536:65536` in docker run | +1 pass | ✓ Done |
415+
| Medium | `--ulimit nofile=65536:65536` in docker run | +1 pass | ✓ Done (confirmed, 3m1s clean run) |
413416
| Medium | Add `msd_crossval_datalist_generator` to exemption | +1 pass | ✓ Done (PR #2065) |
414417
| Medium | Pin `transformers<5.0` | +1 pass | ✓ Done (PR #8912) |
415418
| Low | Add `aim` to requirements | +1 pass | ✓ Done (PR #8912) |
416-
| Low | Fix `bundle.load` in endoscopic notebook | +1 pass |Done (PR #2065) |
419+
| Low | R5 `bundle.load` API — local-only, no fix needed | +1 pass (upstream) |Confirmed (reverted bad fix) |
417420
| Low | PEP8 autofix (3 notebooks) | 0 fails eliminated | ✓ Done |
418421
| Low | Skip `image_restoration.ipynb` (Restormer missing) | +1 pass | ✓ Done (PR #2065) |
419422
| Low | Fix Spleen Lightning notebook (`pytorch-lightning>=2.1`) | +1 pass | ✓ Done (PR #2065) |
@@ -436,15 +439,15 @@ Changes committed to bring Docker run to parity with Eric's run:
436439
| File | Change |
437440
|---|---|
438441
| `runner.sh` | Add `msd_crossval_datalist_generator.ipynb` and `hovernet_infer_compare.ipynb` to `doesnt_contain_max_epochs`; add `image_restoration.ipynb` to `skip_run_papermill` |
439-
| `computer_assisted_intervention/endoscopic_inbody_classification.ipynb` | Pass `return_state_dict=False` to `monai.bundle.load` so it returns `nn.Module` instead of `OrderedDict` |
442+
| `computer_assisted_intervention/endoscopic_inbody_classification.ipynb` | Reverted `return_state_dict=False` — upstream MONAI ≥1.5 already returns `nn.Module` by default; the extra kwarg caused `TypeError` in CI |
440443
| `bundle/05_spleen_segmentation_lightning.ipynb` | Change `pytorch-lightning~=2.0.0``pytorch-lightning>=2.1` to avoid mlflow eager-import failure (R7) |
441444

442445
### Still pending (require environment changes or separate PRs)
443446

444447
| Issue | Action needed |
445448
|---|---|
446449
| Disk space (R2) | Free `/data` disk or bind-mount scratch volume; `deep_atlas` (~2 GB), `deployment/bentoml`, `experiment_management/bundle_integrate_mlflow`, `microscopy` notebooks |
447-
| Socket FD limit (R8) | Add `--ulimit nofile=65536:65536` to docker run invocation |
450+
| Socket FD limit (R8) | ✓ Confirmed fixed — `--ulimit nofile=65536:65536` resolves ancdata error; isolated run completed in 3m1s (2026-06-11) |
448451
| pytorch-lightning/mlflow import chain (R7) | ✓ Fixed: `pytorch-lightning>=2.1` in notebook (PR #2065) |
449452
| PEP8 in 3 notebooks | Run `bash runner.sh --autofix` for `surgtoolloc/preprocess_detect_scene_and_split_fold.ipynb`, `deep_atlas/deep_atlas_tutorial.ipynb`, `modules/interpretability/class_lung_lesion.ipynb` |
450453
| Restormer in MONAI dev | Cherry-pick Restormer network class commit; remove from skip list once merged |

0 commit comments

Comments
 (0)