Skip to content

Commit fb48af9

Browse files
authored
Merge branch 'dev' into feature/7405-mlflow-system-metrics
2 parents ad5bc5d + 3e2ff2b commit fb48af9

67 files changed

Lines changed: 1209 additions & 53 deletions

Some content is hidden

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

.github/workflows/cicd_tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
runs-on: ubuntu-latest
5757
strategy:
5858
matrix:
59-
opt: ["codeformat", "mypy"] # "pytype" omitted for being essentially deprecated, see #8865
59+
opt: ["codeformat", "pyrefly"]
6060
steps:
6161
- name: Clean unused tools
6262
run: |
@@ -80,8 +80,7 @@ jobs:
8080
run: |
8181
# clean up temporary files
8282
$(pwd)/runtests.sh --build --clean
83-
# Github actions have multiple cores, so parallelize pytype
84-
$(pwd)/runtests.sh --build --${{ matrix.opt }} -j $(nproc --all)
83+
$(pwd)/runtests.sh --build --${{ matrix.opt }}
8584
8685
min-dep: # Test with minumum dependencies installed for different OS, Python, and PyTorch combinations
8786
runs-on: ${{ matrix.os }}

.github/workflows/cron.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ jobs:
214214
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
215215
python -c 'import torch; print(torch.rand(5,3, device=torch.device("cuda:0")))'
216216
ngc --version
217-
BUILD_MONAI=1 ./runtests.sh --build --coverage --unittests --disttests # unit tests with pytype checks, coverage report
217+
BUILD_MONAI=1 ./runtests.sh --build --coverage --pyrefly --unittests --disttests # unit tests with pyrefly checks, coverage report
218218
BUILD_MONAI=1 ./runtests.sh --build --coverage --net # integration tests with coverage report
219219
coverage xml --ignore-errors
220220
if pgrep python; then pkill python; fi

.github/workflows/weekly-preview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
opt: ["codeformat", "mypy"]
15+
opt: ["codeformat", "pyrefly"]
1616
steps:
1717
- name: Clean unused tools
1818
run: |

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,17 @@ venv.bak/
110110
# pytype cache
111111
.pytype/
112112

113+
# pyrefly cache
114+
.pyrefly_cache/
115+
113116
# mypy
114117
.mypy_cache/
118+
.dmypy.json
119+
115120
examples/scd_lvsegs.npz
116121
temp/
117122
.idea/
118-
.dmypy.json
123+
.plans/
119124

120125
*~
121126

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.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Please note that, as per PyTorch, MONAI uses American English spelling. This mea
3838
### Preparing pull requests
3939

4040
To ensure the code quality, MONAI relies on several linting tools ([black](https://github.com/psf/black), [isort](https://github.com/timothycrosley/isort), [ruff](https://github.com/astral-sh/ruff)),
41-
static type analysis tools ([mypy](https://github.com/python/mypy), [pytype](https://github.com/google/pytype)), as well as a set of unit/integration tests.
41+
static type analysis tools ([pyrefly](https://github.com/facebook/pyrefly)), as well as a set of unit/integration tests.
4242

4343
This section highlights all the necessary preparation steps required before sending a pull request.
4444
To collaborate efficiently, please read through this section and follow them.

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/apps/auto3dseg/auto_runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ def _train_algo_in_nni(self, history: list[dict[str, Any]]) -> None:
790790
nni_config_filename = os.path.abspath(os.path.join(self.work_dir, f"{name}_nni_config.yaml"))
791791
ConfigParser.export_config_file(nni_config, nni_config_filename, fmt="yaml", default_flow_style=None)
792792

793+
# pyrefly: ignore [redundant-cast]
793794
max_trial = min(self.hpo_tasks, cast(int, default_nni_config["maxTrialNumber"]))
794795
cmd = "nnictl create --config " + nni_config_filename + " --port 8088"
795796

@@ -805,6 +806,7 @@ def _train_algo_in_nni(self, history: list[dict[str, Any]]) -> None:
805806
n_trainings = len(import_bundle_algo_history(self.work_dir, only_trained=True))
806807

807808
cmd = "nnictl stop --all"
809+
# pyrefly: ignore [bad-argument-type]
808810
run_cmd(cmd.split(), check=True)
809811
logger.info(f"NNI completes HPO on {name}")
810812
last_total_tasks = n_trainings

monai/apps/deepedit/transforms.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ def _randomize(self, d, key_label):
434434
else:
435435
logger.info(f"Not slice IDs for label: {key_label}")
436436
sid = None
437+
# pyrefly: ignore [unsupported-operation]
437438
self.sid[key_label] = sid
438439

439440
def __call__(self, data: Mapping[Hashable, np.ndarray]) -> dict[Hashable, np.ndarray]:
@@ -561,6 +562,7 @@ def __init__(
561562
self.guidance: dict[str, list[list[int]]] = {}
562563

563564
def randomize(self, data=None):
565+
# pyrefly: ignore [unsupported-operation]
564566
probability = data[self.probability]
565567
self._will_interact = self.R.choice([True, False], p=[probability, 1.0 - probability])
566568

@@ -885,6 +887,7 @@ def _randomize(self, d, key_label):
885887
else:
886888
logger.info(f"Not slice IDs for label: {key_label}")
887889
sid = None
890+
# pyrefly: ignore [unsupported-operation]
888891
self.sid[key_label] = sid
889892

890893
def __call__(self, data: Mapping[Hashable, np.ndarray]) -> dict[Hashable, np.ndarray]:

monai/apps/deepgrow/dataset.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def _save_data_2d(vol_idx, vol_image, vol_label, dataset_dir, relative_path):
175175
continue
176176

177177
# For all Labels
178+
# pyrefly: ignore [missing-attribute]
178179
unique_labels = np.unique(label.flatten())
179180
unique_labels = unique_labels[unique_labels != 0]
180181
unique_labels_count = max(unique_labels_count, len(unique_labels))

0 commit comments

Comments
 (0)