DiNTS forward() breaks the torch.compile graph on every topology branch
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- machine-learning, performance
Hướng nghiên cứu
Start in monai/networks/nets/dints.py, focusing on DiNTS.forward and TopologyInstance.forward and their node_a/arch_code_a control flow. Run the provided TorchDynamo reproducer first, then verify that the topology behavior is preserved and compilation reaches the stated 1 graph with 0 breaks for the sample configuration.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
DiNTS.forward and TopologyInstance.forward pick which cells to run by indexing the node_a / arch_code_a tensors inside Python control flow:
# monai/networks/nets/dints.py
if self.node_a[0][d]: ...
elif self.node_a[blk_idx + 1][res_idx]: ...
for res_idx, activation in enumerate(self.arch_code_a[blk_idx].data): ...
Each is a data-dependent tensor read, so TorchDynamo cannot constant-fold the branch and splits the graph instead: a 6-block / 3-depth DiNTS compiles into 14 graphs with 13 breaks. These flags are fixed once a model is deployed, so the breaks are pure overhead — they block fusion across the network and scale with num_blocks, so deeper searched architectures fragment further.
To Reproduce
-
Install MONAI from
dev, with a torch 2.x providing TorchDynamo. -
Run:
import torch, torch._dynamo as dyn from monai.networks.nets.dints import DiNTS, TopologyInstance grid = dict(channel_mul=0.2, num_blocks=6, num_depths=3, use_downsample=True, spatial_dims=3, device="cpu") m = DiNTS(dints_space=TopologyInstance(**grid), in_channels=1, num_classes=2, spatial_dims=3, use_downsample=True).eval() expl = dyn.explain(m)(torch.randn(1, 1, 32, 32, 32)) print(expl.graph_count, expl.graph_break_count) -
Observed:
14 13. (expl.break_reasonsis not populated on this torch version, so only the counts are available.)
Expected behavior
The topology flags are constant for the lifetime of a deployed model, so the branches should be constant-foldable and the network should compile to 1 0 — one graph, no breaks.
Screenshots
N/A — the reproducer output above is the full evidence.
Environment
MONAI version: 1.6.1rc0+8.g860506514
MONAI rev id : 860506514fb1fba41db1578e0eeacfa952583a13 (dev)
Pytorch version: 2.12.1+rocm7.1
Numpy version: 2.5.2
Reproduced on CPU. The graph breaks are introduced at Dynamo trace time, so they are independent of
the accelerator and of the torch build — this is not platform-specific.
python -c "import monai; monai.config.print_debug_info()"
================================
Printing MONAI config...
================================
MONAI version: 1.6.1rc0+8.g860506514
Numpy version: 2.5.2
Pytorch version: 2.12.1+rocm7.1
MONAI flags: HAS_EXT=False, USE_COMPILED=False, USE_META_DICT=False
MONAI rev id: 860506514fb1fba41db1578e0eeacfa952583a13
MONAI __file__: /home/user/upstream_monai/upstream-fork-monai/monai/__init__.py
Optional dependencies:
Pytorch Ignite version: 0.5.5
ITK version: NOT INSTALLED or UNKNOWN VERSION.
Nibabel version: 5.4.2
scikit-image version: 0.26.0
scipy version: 1.18.1
Pillow version: 12.3.0
Tensorboard version: NOT INSTALLED or UNKNOWN VERSION.
gdown version: NOT INSTALLED or UNKNOWN VERSION.
TorchVision version: 0.27.1+rocm7.1
tqdm version: 4.70.1
lmdb version: NOT INSTALLED or UNKNOWN VERSION.
psutil version: NOT INSTALLED or UNKNOWN VERSION.
pandas version: NOT INSTALLED or UNKNOWN VERSION.
einops version: 0.8.2
transformers version: NOT INSTALLED or UNKNOWN VERSION.
mlflow version: NOT INSTALLED or UNKNOWN VERSION.
pynrrd version: NOT INSTALLED or UNKNOWN VERSION.
clearml version: NOT INSTALLED or UNKNOWN VERSION.
================================
Printing system config...
================================
`psutil` required for `print_system_info`
================================
Printing GPU config...
================================
Num GPUs: 1
Has CUDA: True
CUDA version: None
cuDNN enabled: True
NVIDIA_TF32_OVERRIDE: None
TORCH_ALLOW_TF32_CUBLAS_OVERRIDE: None
cuDNN version: 3005001
Current device: 0
Library compiled for CUDA architectures: ['gfx900', 'gfx906', 'gfx908', 'gfx90a', 'gfx942', 'gfx1030', 'gfx1100', 'gfx1101', 'gfx1102', 'gfx1200', 'gfx1201', 'gfx950', 'gfx1150', 'gfx1151']
GPU 0 Name: AMD Instinct MI300X
GPU 0 Is integrated: False
GPU 0 Is multi GPU board: False
GPU 0 Multi processor count: 304
GPU 0 Total memory (GB): 192.0
GPU 0 CUDA capability (maj.min): 9.4
- Ngôn ngữ chính
- Python
- Star
- 8.8k
- Fork
- 1.6k
- Merge trung bình
- 2 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Project-MONAI/MONAI
-
DiNTS: missing graph-break regression test (follow-up to #9145)Có thể đã có người làm @nilapate đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Project-MONAI/MONAI#9159 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ProbMapProducer raises IndexError on numpy 2.x: SlidingPatchWSIDataset emits float locationsCó thể đã có người làm @nilapate đã nhận 12 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Project-MONAI/MONAI#9135 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
RandGridPatch crashes for documented 0 or None patch_size entriesCó thể đã có người làm @Rajioba1 đã nhận 68 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Project-MONAI/MONAI#9046 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Incorrect type hint in `pad_func`Có thể đã có người làm @Harshal875 đã nhận 74 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Project-MONAI/MONAI#9026 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Remove MMAR CodeCó thể đã có người làm @KumoLiu đã nhận 1 ngày trước. Đang mở
Project-MONAI/MONAI#9162 · 2 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Project-MONAI/MONAI
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
topoteretes/cognee#5647 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Sendspin/sendspin-python-cli#291 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
awslabs/visual-asset-management-system#414 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
modelcontextprotocol/python-sdk#3670 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aicell-lab/bioengine#232 ·
Maintainer thường phản hồi trong vòng 1 ngày