Drop vendored nnunetv2; depend on upstream pip package (v1.3.0)#4
Open
77even wants to merge 3 commits into
Open
Drop vendored nnunetv2; depend on upstream pip package (v1.3.0)#477even wants to merge 3 commits into
77even wants to merge 3 commits into
Conversation
d22e479 to
a8575e6
Compare
9 tasks
a8575e6 to
edc76b8
Compare
edc76b8 to
747c902
Compare
13 tasks
BREAKING CHANGE: distillation/nnunetv2/ is removed and replaced with a pip dependency on nnunetv2>=2.5,<3.0. Users must reinstall to pick up the new layout. What changed: - Removed entire distillation/nnunetv2/ vendored tree (~190 files, 1.7 MB). The only file we had authored was nnUNetDistillationTrainer.py; the rest was a stale snapshot of upstream nnUNet that the repo had to manually keep in sync. - Moved the trainer to distillation/nnunet_distillation_trainer.py at the top of the package so it sits next to the entry-point scripts. - Updated the four entry-point scripts to import the trainer from its new location and dropped the sys.path.insert hack that forced the vendored copy to win over pip. - setup.py: pin nnunetv2>=2.5,<3.0, list nnunet_distillation_trainer in py_modules, bump version 1.2.1 -> 1.3.0. Compatibility fix surfaced by the refactor: - nnunetv2 2.7 renamed nnUNetLogger to LocalLogger. Updated the trainer's import and instantiation accordingly. (The vendored copy hid this drift.) Verified locally: - python -m py_compile passes on all touched files. - After `pip install -e .` in distillation/, the four console entry points (nnUNetv2_distillation_train, nnUNetv2_resenc_distillation_train, nnUNetv2_distillation_export_onnx, nnUNetv2_resenc_distillation_export_onnx) all run --help successfully against pip-installed nnunetv2 2.7.0. - nnunet_distillation_trainer exposes nnUNetDistillationTrainer, nnUNetDistillationTrainerDA5, LiteNNUNetStudent, LiteResEncStudent. Not yet verified (requires GPU + dataset): - An end-to-end training step. The autocast/Logger changes need a real training run before this is shipped.
torch>=2.6 changed its ONNX exporter to require onnxscript, so users
hitting the export scripts on a fresh install were getting
ModuleNotFoundError. This adds:
- setup.py: extras_require={'onnx': [onnx, onnxruntime, onnxscript, onnx-simplifier]}
so users can pip install nnunetv2_distillation[onnx].
- docs/Distillation.md: a Prerequisites callout before the ONNX export
section listing both the extras install and the manual pip command.
After the rebase, primus_distillation_trainer.py still referenced nnunetv2.training.nnUNetTrainer.variants.nnUNetDistillationTrainer (the vendored path on main), which no longer exists on this branch. Switch the import to the top-level nnunet_distillation_trainer module that the "Drop vendored nnunetv2" commit introduced.
747c902 to
72eb6b1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BREAKING CHANGE — drops the vendored
distillation/nnunetv2/tree (~190 files, 1.7 MB) and switches to a plain pip dependency onnnunetv2>=2.5,<3.0. Bumps the package version to v1.3.0.nnUNetDistillationTrainer.py); the other ~190 files were stale upstream code.distillation/nnunet_distillation_trainer.py(top-level, next to the other scripts).sys.path.inserthack that forced the vendored copy to win over pip has been removed from all entry-point scripts.Rebased onto main (post-v1.2.4)
This branch has been rebased onto
mainafter v1.2.3 (PR #6) and v1.2.4 (PR #7) landed. v1.3.0 therefore includes everything from both:2d,3d_lowres, and3d_cascade_fullresconfigurations work end-to-end (was hardcoded 3D-only before). ONNX export adapts dummy input shape and dynamic axes per configuration dim. Output filenames include the configuration name so different configs don't overwrite each other.nnUNet_Primus_{S,B,M,L}_Trainerteachers. NewnnUNetv2_primus_distillation_trainandnnUNetv2_primus_distillation_export_onnxentry points; newprimus_distillation_trainermodule.After rebase,
primus_distillation_trainer.py's import of the distillation trainer was updated to point at the unvendored top-level module (see the third commit on this branch).Compatibility fix surfaced by the refactor
nnunetv22.7 renamednnUNetLogger->LocalLogger. The trainer's import and instantiation have been updated. (This drift was previously hidden by the vendored copy.)ONNX export prerequisites
PyTorch >= 2.6 changed its ONNX exporter to require
onnxscript. Addressed by:setup.py: addedextras_require={'onnx': ['onnx', 'onnxruntime', 'onnxscript', 'onnx-simplifier']}docs/Distillation.md: prerequisites callout before the ONNX export sectionInstall paths after this PR:
Commits on this branch
Drop vendored nnunetv2; depend on upstream pip package (v1.3.0)Document ONNX prerequisites and add [onnx] extras_requireUpdate Primus trainer imports for the unvendored layoutTest plan
python -m py_compilepasses on all touched filespip install -e '.[onnx]'indistillation/, all six console entry points run--helpagainst pip-installednnunetv22.7.0 (the three existing ones plus the two new Primus ones)nnunet_distillation_trainerexposesnnUNetDistillationTrainer,nnUNetDistillationTrainerDA5,LiteNNUNetStudent,LiteResEncStudentprimus_distillation_trainerexposesnnUNetDistillationPrimusTrainer,nnUNetDistillationPrimusTrainerDA5,LitePrimusStudent,reduce_primus_dims3d_fullres,2d,3d_cascade_fullres. Cascade requires upstreamnnUNetv2_train ... 3d_lowres+nnUNetv2_predict --save_probabilitiessopredicted_next_stage/exists.-ts S/M/Lwith-r 2. Primus teacher must be trained first with stock nnunetv2 (nnUNetv2_train DATASET_ID 3d_fullres 0 -tr nnUNet_Primus_M_Trainer).--simplifypath.Upgrade notes for users
Existing distilled checkpoints continue to load; the trainer/student APIs are unchanged from v1.2.4.