File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -324,12 +324,22 @@ trainer = Trainer(callbacks=[checkpointing])
324324</details >
325325
326326<details >
327- <summary >Export to torchscript (JIT) (production use)</summary >
327+ <summary >Export to torchscript (JIT) (production use) - DEPRECATED</summary >
328+
329+ > ** ⚠️ Deprecated** : ` to_torchscript() ` is deprecated in PyTorch Lightning v2.5 and will be removed in v2.7.
330+ > TorchScript is deprecated in PyTorch. Use ` torch.export.export() ` instead.
331+ > See [ PyTorch Export Documentation] ( https://pytorch.org/docs/stable/export.html ) for more information.
328332
329333``` python
330- # torchscript
334+ # torchscript (deprecated)
331335autoencoder = LitAutoEncoder()
332336torch.jit.save(autoencoder.to_torchscript(), " model.pt" )
337+
338+ # Recommended alternative using torch.export
339+ import torch
340+ autoencoder = LitAutoEncoder()
341+ exported_program = torch.export.export(autoencoder, (torch.randn(1 , 64 ),))
342+ torch.export.save(exported_program, " model.pt2" )
333343```
334344
335345</details >
Original file line number Diff line number Diff line change @@ -271,14 +271,6 @@ checkpointing = ModelCheckpoint(monitor="val_loss")
271271trainer = Trainer(callbacks = [checkpointing])
272272```
273273
274- <summary >Export to torchscript (JIT) (production use)</summary >
275-
276- ``` python
277- # torchscript
278- autoencoder = LitAutoEncoder()
279- torch.jit.save(autoencoder.to_torchscript(), " model.pt" )
280- ```
281-
282274<summary >Export to ONNX (production use)</summary >
283275
284276``` python
You can’t perform that action at this time.
0 commit comments