Skip to content

Commit 1649422

Browse files
carmoccalexierule
authored andcommitted
Use the setter in the children recursively (#14724)
1 parent 1b4c838 commit 1649422

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/pytorch_lightning/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
66

77

8-
## [1.7.7] - 2022-09-??
8+
## [1.7.7] - 2022-09-22
99

1010
### Fixed
1111

1212
- Fixed the availability check for the neptune-client package ([#14714](https://github.com/Lightning-AI/lightning/pull/14714))
1313
- Break HPU Graphs into two parts (forward + backward as one and optimizer as another) for better performance ([#14656](https://github.com/Lightning-AI/lightning/pull/14656))
14+
- Fixed torchscript error with ensembles of LightningModules ([#14657](https://github.com/Lightning-AI/lightning/pull/14657), [#14724](https://github.com/Lightning-AI/lightning/pull/14724))
1415

1516

1617
## [1.7.6] - 2022-09-13
@@ -25,7 +26,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
2526
- Fixed an issue to keep downscaling the batch size in case there hasn't been even a single successful optimal batch size with `mode="power"` ([#14372](https://github.com/Lightning-AI/lightning/pull/14372))
2627
- Fixed an issue where `self.log`-ing a tensor would create a user warning from PyTorch about cloning tensors ([#14599](https://github.com/Lightning-AI/lightning/pull/14599))
2728
- Fixed compatibility when `torch.distributed` is not available ([#14454](https://github.com/Lightning-AI/lightning/pull/14454))
28-
- Fixed torchscript error with ensembles of LightningModules ([#14657](https://github.com/Lightning-AI/lightning/pull/14657))
2929

3030

3131
## [1.7.5] - 2022-09-06

src/pytorch_lightning/core/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def _running_torchscript(self) -> bool:
297297
def _running_torchscript(self, value: bool) -> None:
298298
for v in self.children():
299299
if isinstance(v, LightningModule):
300-
v._running_torchscript_internal = value
300+
v._running_torchscript = value
301301
self._running_torchscript_internal = value
302302

303303
def _call_batch_hook(self, hook_name: str, *args: Any) -> Any:

tests/tests_pytorch/models/test_torchscript.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,22 @@ def test_torchscript_with_no_input(tmpdir):
174174

175175

176176
def test_torchscript_script_recursively():
177-
class Child(LightningModule):
177+
class GrandChild(LightningModule):
178178
def __init__(self):
179179
super().__init__()
180180
self.model = torch.nn.Linear(1, 1)
181181

182182
def forward(self, inputs):
183183
return self.model(inputs)
184184

185+
class Child(LightningModule):
186+
def __init__(self):
187+
super().__init__()
188+
self.model = GrandChild()
189+
190+
def forward(self, inputs):
191+
return self.model(inputs)
192+
185193
class Parent(LightningModule):
186194
def __init__(self):
187195
super().__init__()

0 commit comments

Comments
 (0)