Lightning-AI / Lightning-AI/pytorch-lightning
Update from Torchscript to `torch.export`
@SkafteNicki is already working on this.
Since Dec 1, 2025.
- Dominant language
- Python
- Stars
- 31.4k
- Forks
- 3.8k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 6
Description
### Outline & Motivation
Torchscript is deprecated in the most recent releases of Pytorch
https://docs.pytorch.org/docs/stable/jit.html
Instead `torch.export` is the recommended way to go:
https://docs.pytorch.org/docs/stable/export.html
The most obvious change that need to be made is to `LightningModule.to_torchscript` which either:
* keep function but update internals to use the new `torch.export` functionality
* deprecate/remove and introduce a new function called `export` or similar that use new functionality
* deprecate/remove and let users manually export
In addition to this we need to update documentation etc. since there are still multiple references to `torch.jit`. See this hotfix for when torch v2.9 was released: https://github.com/Lightning-AI/pytorch-lightning/pull/21292
### Pitch
_No response_
### Additional context
_No response_
cc @lantiga @justusschock
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.