Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Torchscript Deprecation

Aperta
#8,632 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Refactoring
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python, pytorch

Direzione di ricerca

Iniziare con l’esempio documentato di monai.networks.nets.UNet usando torch.export, quindi verificare l’uso esistente di torch.jit in MONAI. Identificare le reti e i comportamenti incompatibili e sviluppare le routine helper, i test di compatibilità, gli adattamenti, i tutorial e la rimozione dell’uso legacy elencati. Il lavoro è completo quando l’ambito della migrazione è stato coperto senza dipendenze Torchscript non supportate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
Python
Stelle
8.7k
Fork
1.6k
Merge medio
5g 3h
PR unite (30g)
14

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Project-MONAI/MONAI

Tutte le issue di Project-MONAI/MONAI

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.