File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
src/lightning/pytorch/core Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 6464from lightning .pytorch .utilities .exceptions import MisconfigurationException
6565from lightning .pytorch .utilities .imports import _TORCH_GREATER_EQUAL_2_6 , _TORCHMETRICS_GREATER_EQUAL_0_9_1
6666from lightning .pytorch .utilities .model_helpers import _restricted_classmethod
67- from lightning .pytorch .utilities .rank_zero import WarningCache , rank_zero_warn
67+ from lightning .pytorch .utilities .rank_zero import WarningCache , rank_zero_deprecation , rank_zero_warn
6868from lightning .pytorch .utilities .signature_utils import is_param_in_hook_signature
6969from lightning .pytorch .utilities .types import (
7070 _METRIC ,
@@ -1498,6 +1498,11 @@ def to_torchscript(
14981498 scripted you should override this method. In case you want to return multiple modules, we recommend using a
14991499 dictionary.
15001500
1501+ .. deprecated::
1502+ ``LightningModule.to_torchscript`` has been deprecated in v2.7 and will be removed in v2.8.
1503+ TorchScript is deprecated in PyTorch. Use ``torch.export.export()`` for model exporting instead.
1504+ See https://pytorch.org/docs/stable/export.html for more information.
1505+
15011506 Args:
15021507 file_path: Path where to save the torchscript. Default: None (no file saved).
15031508 method: Whether to use TorchScript's script or trace method. Default: 'script'
@@ -1536,6 +1541,11 @@ def forward(self, x):
15361541 defined or not.
15371542
15381543 """
1544+ rank_zero_deprecation (
1545+ "`LightningModule.to_torchscript` has been deprecated in v2.5 and will be removed in v2.7. "
1546+ "TorchScript is deprecated in PyTorch. Use `torch.export.export()` for model exporting instead. "
1547+ "See https://pytorch.org/docs/stable/export.html for more information."
1548+ )
15391549 mode = self .training
15401550
15411551 if method == "script" :
You can’t perform that action at this time.
0 commit comments