Lightning-AI / Lightning-AI/pytorch-lightning

Update from Torchscript to `torch.export`

Open
#21,293 2 comments 3 reactions 1 assignee View on GitHub

@SkafteNicki is already working on this.

Since Dec 1, 2025.

refactor
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.