Torchscript Deprecation
维护者通常 4 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 重构
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
调研方向
先从使用 torch.export 的文档化 monai.networks.nets.UNet 示例开始,然后审查 MONAI 现有的 torch.jit 用法。识别不兼容的网络和行为,并开发所列出的辅助例程、兼容性测试、适配、教程以及旧用法移除。完成的标准是:在不依赖不受支持的 Torchscript 依赖项的情况下,解决迁移范围内的问题。
由索引模型根据 Issue 内容生成。
描述
Torchscript is now fully deprecated in Pytorch 2.9. We should investigate converting usage in MONAI of torch.jit over to torch.export. Not all features and behaviours are supported as it is not the same sort of JIT architecture, and torch.compile is not meant for exporting models to a saved format.
Some MONAI models will have no issues with torch.export.export, however it doesn't capture control flow like Torchscript and is more like tracing. Networks without control flow in their forward definitions can be exported currently, eg.:
import torch
from monai.networks.nets import UNet
net = UNet(spatial_dims=2, in_channels=2, out_channels=1, channels=[4, 8, 16], strides=[2, 2])
t1 = torch.rand(3, 2, 16, 16)
t2 = torch.rand(5, 2, 32, 32)
print(net(t1).shape, net(t2).shape) # expected shapes
D = torch.export.Dim.DYNAMIC
S = torch.export.Dim.STATIC
enet = torch.export.export(net, args=(t1,), dynamic_shapes=((D, S, D, D),))
torch.export.save(enet, "out.pt2")
enet1 = torch.export.load("out.pt2")
net1 = enet1.module()
print(net1(t1).shape, net1(t2).shape) # same as expected shapes
Work is needed to develop:
- Helper routines to help export then import networks in regular use.
- Helper routines and tests to ensure compatibility.
- Adaptation of existing code to overcome any compatibility issues.
- Tutorials on this new usage and how to design compatible networks.
- Removal of legacy Torchscript usage wherever present, especially when its removal from Pytorch is imminent.
- 主要语言
- Python
- 星标
- 8.7k
- 派生
- 1.6k
- 平均合并
- 5 天 20 小时
- 30 天内合并 PR
- 12
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Project-MONAI/MONAI 的其他 Issue
-
ProbMapProducer raises IndexError on numpy 2.x: SlidingPatchWSIDataset emits float locations可能已有人在做 @nilapate 于 8 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
Project-MONAI/MONAI#9135 ·
维护者通常 4 天内回复
-
RandGridPatch crashes for documented 0 or None patch_size entries可能已有人在做 @Rajioba1 于 64 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
Project-MONAI/MONAI#9046 ·
维护者通常 4 天内回复
-
Incorrect type hint in `pad_func`可能已有人在做 @Harshal875 于 70 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
Project-MONAI/MONAI#9026 ·
维护者通常 4 天内回复
-
Add ROCm support for AMD Instinct GPUs可能已有人在做 @nilapate 于 1 天前认领。 未关闭
难度 5/5 一周以上 新手友好度 20/100
Project-MONAI/MONAI#9152 ·
维护者通常 4 天内回复
-
难度 3/5 1-2 天 新手友好度 74/100
Project-MONAI/MONAI#9151 ·
维护者通常 4 天内回复
查看 Project-MONAI/MONAI 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
modelcontextprotocol/python-sdk#3648 ·
维护者通常 1 天内回复
-
docs good first issue
难度 2/5 1-3 小时 新手友好度 78/100
VenetoStato/giorgio#6 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 70/100
EclipseFdn/open-vsx.org#13831 ·
维护者通常 1 天内回复