Skip to content

Commit 956b006

Browse files
authored
Merge branch 'dev' into build_update
2 parents f456bec + 3e2ff2b commit 956b006

8 files changed

Lines changed: 930 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
55

66
## [Unreleased]
77
### Added
8+
* `NaViT` (`monai.networks.nets.NaViT`): Native Resolution Vision Transformer with Patch n' Pack, supporting variable-resolution 2D and 3D inputs. Implements factorized positional embeddings, token dropout, attention pooling, and QK normalization, based on ["Patch n' Pack: NaViT, a Vision Transformer for any Aspect Ratio and Resolution"](https://arxiv.org/abs/2307.06304).
89
* `HyenaMixer`, `HyenaTransformerBlock`, and `DepthwiseFFTConv{2,3}d` in `monai.networks.blocks`: subquadratic O(N log N) alternatives to windowed self-attention, backed by the HyenaND operator from the optional `nvsubquadratic` package.
910
* `HyenaNDUNETR` (`monai.networks.nets.HyenaNDUNETR`): thin `SwinUNETR` subclass with a `get_variant(name)` classmethod for the three Hyena variants (`HHHH`, `HAHA`, `HHAA`) from the NeurIPS 2026 paper "Native Multi-Dimensional Subquadratic Operators via Input Dependent Long Convolutions" (paper id 26539).
1011
* `SwinUNETR.use_hyena` and `SwinUNETR.hyena_stages` kwargs to thread HyenaND blocks through any subset of Swin stages. Default `use_hyena=False` preserves bit-identical forward behavior of the existing code path.

docs/source/networks.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,11 @@ Nets
662662
.. autoclass:: VarAutoEncoder
663663
:members:
664664

665+
`NaViT`
666+
~~~~~~~
667+
.. autoclass:: NaViT
668+
:members:
669+
665670
`ViT`
666671
~~~~~
667672
.. autoclass:: ViT

monai/bundle/scripts.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,14 @@ def load(
648648
"""
649649
Load model weights or TorchScript module of a bundle.
650650
651+
Security note: if `model` is `None`, building `network_def` requires parsing the bundle's own
652+
"{workflow_type}.json" config, which can define `"_target_"` components resolved to any importable
653+
callable and `"$"`-prefixed expressions evaluated with Python `eval()`. Only call `load()` this way
654+
for bundles from a source you trust; a warning is printed every time this happens
655+
(see https://github.com/Project-MONAI/MONAI/security/advisories/GHSA-873f-pvrv-4x83). To skip parsing
656+
the bundle's config entirely, pass an explicit `model=` — only the weights are then loaded, via
657+
`torch.load(..., weights_only=True)`.
658+
651659
Args:
652660
name: bundle name. If `None` and `url` is `None`, it must be provided in `args_file`.
653661
for example:
@@ -935,6 +943,12 @@ def run(
935943
"""
936944
Specify `config_file` to run monai bundle components and workflows.
937945
946+
Security note: parsing `config_file` can run arbitrary code. Any `"_target_"` value is resolved to an
947+
importable callable and invoked with no allow list, and any `"$"`-prefixed value is passed to Python
948+
`eval()`. Only point this at config files you wrote or otherwise fully trust; never at a config
949+
downloaded from, or otherwise sourced from, an untrusted party. A warning is printed every time this
950+
happens (see https://github.com/Project-MONAI/MONAI/security/advisories/GHSA-873f-pvrv-4x83).
951+
938952
Typical usage examples:
939953
940954
.. code-block:: bash
@@ -1929,6 +1943,12 @@ def create_workflow(
19291943
The workflow should be subclass of `BundleWorkflow` and be available to import.
19301944
It can be MONAI existing bundle workflows or user customized workflows.
19311945
1946+
Security note: parsing `config_file` can run arbitrary code. Any `"_target_"` value is resolved to an
1947+
importable callable and invoked with no allow list, and any `"$"`-prefixed value is passed to Python
1948+
`eval()`. Only point this at config files you wrote or otherwise fully trust; never at a config
1949+
downloaded from, or otherwise sourced from, an untrusted party. A warning is printed every time this
1950+
happens (see https://github.com/Project-MONAI/MONAI/security/advisories/GHSA-873f-pvrv-4x83).
1951+
19321952
Typical usage examples:
19331953
19341954
.. code-block:: python
@@ -1966,6 +1986,13 @@ def create_workflow(
19661986
)
19671987

19681988
if config_file is not None:
1989+
warnings.warn(
1990+
f'parsing config_file {config_file}: any `"_target_"` value in it is resolved to an importable '
1991+
'callable and invoked with no allow list, and any `"$"`-prefixed value is passed to Python '
1992+
"`eval()`. Only proceed if this config is from a source you trust "
1993+
"(see https://github.com/Project-MONAI/MONAI/security/advisories/GHSA-873f-pvrv-4x83).",
1994+
stacklevel=2,
1995+
)
19691996
# pyrefly: ignore [unexpected-keyword]
19701997
workflow_ = workflow_class(config_file=config_file, **_args)
19711998
else:

monai/networks/nets/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
MedNextSmall,
7676
)
7777
from .milmodel import MILModel
78+
from .navit import NaViT
7879
from .netadapter import NetAdapter
7980
from .patchgan_discriminator import MultiScalePatchDiscriminator, PatchDiscriminator
8081
from .quicknat import Quicknat

0 commit comments

Comments
 (0)