Skip to content

feat(core): declarative YAML model catalog, pretrained bridge and model reorg - #38

Merged
vboussot merged 3 commits into
mainfrom
network
Jul 14, 2026
Merged

feat(core): declarative YAML model catalog, pretrained bridge and model reorg#38
vboussot merged 3 commits into
mainfrom
network

Conversation

@vboussot

Copy link
Copy Markdown
Member

Reorganises the builtin models and ships a declarative YAML model catalog, so a full architecture can live entirely in configuration and load real pretrained weights — with the framework-level correctness fixes underneath.

What's in it

A declarative YAML model catalog (konfai/models/yaml/, packaged in the wheel, referenced as classpath: default|<Name>.yml):

Entry Validation
UNet / NestedUNet / ResNet weight-exact vs the KonfAI Python classes
SegResNet / VNet / DynUNet weight-exact vs MONAI (observed maxdiff 0.0)
ResNet18 / VGG16 weight-exact vs torchvision (real ImageNet weights load through the bridge)
PlainConvUNet weight-exact vs nnU-Net dynamic_network_architectures (also a parametric Python variant for any topology)
ViT encoder token-features allclose vs MONAI
AttentionUNet / UNETR structural-strict, divergence documented in the header

Plus an SMP encoder-backed wrapper, the MIND descriptor, and a ClipNormalize block for checkpoint-baked normalization.

A pretrained-weight bridge (konfai.utils.pretrained.transfer_weights_by_execution_order) that loads an external MONAI/torchvision/nnU-Net checkpoint into a weight-exact KonfAI graph by execution-order leaf pairing (no key map), and refuses a non-equivalent pair.

Reorganisation: builtin Python models move under konfai/models/python/<task>/ next to yaml/; the classpath resolver is re-rooted so the short form (segmentation.UNet.UNet) is unchanged.

BREAKING CHANGE: fully-qualified references konfai.models.<task>.<Module>:<Class> become konfai.models.python.<task>.<Module>:<Class> (no compatibility alias).

Silent-correctness fixes across the core (FocalLoss batch>1, BEST-checkpoint direction, OneHot.inverse batching, Literal defaults, SLURM host, …) and point-of-use guards so the package imports without the itk extra.

Examples: a runnable synthetic-data registration example, and the Segmentation/Synthesis examples now ship their model in both a YAML and an equivalent Python form (verified weight-identical).

Verification

pixi run check (lint + format + core + apps) and the konfai-mcp suite are green; every catalog entry is locked by a build/forward/equivalence test.

vboussot added 3 commits July 14, 2026 14:59
…ridge

Reorganise builtin models under konfai/models/{python,yaml} and ship a declarative YAML model
catalog resolved via 'classpath: default|<Name>.yml' and packaged in the wheel: UNet, NestedUNet,
ResNet (weight-exact vs the KonfAI classes), SegResNet/VNet/DynUNet/ResNet18/VGG16/PlainConvUNet
(weight-exact vs MONAI/torchvision/nnU-Net, real pretrained weights load through the new
konfai.utils.pretrained execution-order bridge), a parametric PlainConvUNet for any nnU-Net topology,
an SMP encoder-backed wrapper, the MIND descriptor, and the ClipNormalize block. The model-builder
registry grows curated primitives (norms, activations, transformer blocks); the classpath resolver is
re-rooted to konfai.models.python (short form unchanged). Also folds the mixed-accumulation
double-backward fix and the point-of-use SimpleITK guard that touch network.py/blocks.py.

BREAKING CHANGE: fully-qualified references 'konfai.models.<task>.<Module>:<Class>' become
'konfai.models.python.<task>.<Module>:<Class>' (no compatibility alias).
FocalLoss batch>1 broadcast, BEST-checkpoint optimisation direction, OneHot.inverse batched argmax,
Literal defaults, SLURM rendezvous host, ConvNeXt LayerScaler, DDP shard tail, load_state_dict shrink,
and a --resubmit warning instead of a silently dropped flag. SimpleITK is guarded at point-of-use so
the package imports without the itk extra. Comments unified in English and SPDX headers completed
(incl. the app CLI wrappers); the Slicer-facing core API surface is locked by contract tests.
A runnable synthetic-data registration example (train/predict/evaluate on the builtin VoxelMorph),
and the Segmentation and Synthesis examples now ship their model in both a declarative YAML and an
equivalent Python form (verified weight-identical), with READMEs explaining when each form applies.
@vboussot
vboussot merged commit b6516be into main Jul 14, 2026
29 checks passed
@vboussot
vboussot deleted the network branch July 14, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant