From 6b4a27f156de43f63f1f799e82484b97d0dc7a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Tue, 6 Jun 2023 16:25:16 +0200 Subject: [PATCH 1/3] XLA only --- src/lightning/fabric/CHANGELOG.md | 2 +- src/lightning/fabric/fabric.py | 2 +- tests/tests_fabric/test_fabric.py | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lightning/fabric/CHANGELOG.md b/src/lightning/fabric/CHANGELOG.md index b7123cd02b9b4..30a121cbb9bae 100644 --- a/src/lightning/fabric/CHANGELOG.md +++ b/src/lightning/fabric/CHANGELOG.md @@ -100,7 +100,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed -- +- Removed warning when using `fabric.no_backward_sync` with XLA strategies ([#17761](https://github.com/Lightning-AI/lightning/pull/17761)) ### Fixed diff --git a/src/lightning/fabric/fabric.py b/src/lightning/fabric/fabric.py index 875f1409847a7..671bc165ea920 100644 --- a/src/lightning/fabric/fabric.py +++ b/src/lightning/fabric/fabric.py @@ -565,7 +565,7 @@ def no_backward_sync(self, module: _FabricModule, enabled: bool = True) -> Gener "You need to set up the model first before you can call `self.no_backward_sync()`:" " `model = self.setup(model, ...)`" ) - if not enabled or isinstance(self._strategy, SingleDeviceStrategy): + if not enabled or isinstance(self._strategy, (SingleDeviceStrategy, XLAStrategy)): context = nullcontext() elif self._strategy._backward_sync_control is None: rank_zero_warn( diff --git a/tests/tests_fabric/test_fabric.py b/tests/tests_fabric/test_fabric.py index 9cba2a6b14864..e61d788b4150d 100644 --- a/tests/tests_fabric/test_fabric.py +++ b/tests/tests_fabric/test_fabric.py @@ -637,6 +637,11 @@ def test_no_backward_sync(): with fabric.no_backward_sync(model): pass fabric._strategy._backward_sync_control.no_backward_sync.assert_not_called() + # same for XLA + fabric._strategy = Mock(spec=XLAStrategy, _backward_sync_control=MagicMock()) + with fabric.no_backward_sync(model): + pass + fabric._strategy._backward_sync_control.no_backward_sync.assert_not_called() # pretend that the strategy supports skipping backward sync fabric._strategy = Mock(_backward_sync_control=MagicMock()) @@ -644,7 +649,7 @@ def test_no_backward_sync(): with fabric.no_backward_sync(model, enabled=False): pass fabric._strategy._backward_sync_control.no_backward_sync.assert_not_called() - # when enabld, the wrapped module gets passed down + # when enabled, the wrapped module gets passed down with fabric.no_backward_sync(model): pass fabric._strategy._backward_sync_control.no_backward_sync.assert_called_once_with(model._forward_module) From e5fc31eda350f08b90cae21871a6d2826b13a170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Tue, 6 Jun 2023 17:43:01 +0200 Subject: [PATCH 2/3] Update CHANGELOG.md --- src/lightning/fabric/CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lightning/fabric/CHANGELOG.md b/src/lightning/fabric/CHANGELOG.md index b1959c55fd44f..760f5b6036357 100644 --- a/src/lightning/fabric/CHANGELOG.md +++ b/src/lightning/fabric/CHANGELOG.md @@ -103,7 +103,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed -- Removed warning when using `fabric.no_backward_sync` with XLA strategies ([#17761](https://github.com/Lightning-AI/lightning/pull/17761)) +- ### Fixed @@ -123,6 +123,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed computing the next version folder in `CSVLogger` ([#17139](https://github.com/Lightning-AI/lightning/pull/17139)) +- Removed false positive warning when using `fabric.no_backward_sync` with XLA strategies ([#17761](https://github.com/Lightning-AI/lightning/pull/17761)) + + ## [2.0.1.post0] - 2023-04-11 No changes From cbb8fb54e8c66ed00b7d3b338ed357b58f8b8d23 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:44:04 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/lightning/fabric/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning/fabric/CHANGELOG.md b/src/lightning/fabric/CHANGELOG.md index 760f5b6036357..c83eb9727f4dc 100644 --- a/src/lightning/fabric/CHANGELOG.md +++ b/src/lightning/fabric/CHANGELOG.md @@ -103,7 +103,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed -- +- ### Fixed