Skip to content

Commit 93d21ed

Browse files
carmoccalantiga
authored andcommitted
Simplify rank_zero_experiment for torch.compile support (#17216)
1 parent 7c65eee commit 93d21ed

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/lightning/fabric/loggers/logger.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def rank_zero_experiment(fn: Callable) -> Callable:
9999
"""Returns the real experiment on rank 0 and otherwise the _DummyExperiment."""
100100

101101
@wraps(fn)
102-
def experiment(self) -> Union[Any, _DummyExperiment]: # type: ignore[no-untyped-def]
102+
def experiment(self: Logger) -> Union[Any, _DummyExperiment]:
103103
"""
104104
Note:
105105
``self`` is a custom logger instance. The loggers typically wrap an ``experiment`` method
@@ -109,12 +109,9 @@ def experiment(self) -> Union[Any, _DummyExperiment]: # type: ignore[no-untyped
109109
types that are specific to the custom logger. The return type here can be considered as
110110
``Union[return type of logger.experiment, _DummyExperiment]``.
111111
"""
112-
113-
@rank_zero_only
114-
def get_experiment() -> Callable:
115-
return fn(self)
116-
117-
return get_experiment() or _DummyExperiment()
112+
if rank_zero_only.rank > 0:
113+
return _DummyExperiment()
114+
return fn(self)
118115

119116
return experiment
120117

src/lightning/pytorch/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
1818
- Fixed WandbLogger not showing "best" aliases for model checkpoints when `ModelCheckpoint(save_top_k>0)` is used ([#17121](https://github.com/Lightning-AI/lightning/pull/17121))
1919
- Fixed the availability check for `rich` that prevented Lightning to be imported in Google Colab ([#17156](https://github.com/Lightning-AI/lightning/pull/17156))
2020
- Fixed parsing the precision config for inference in `DeepSpeedStrategy` ([#16973](https://github.com/Lightning-AI/lightning/pull/16973))
21+
- Fixed issue where `torch.compile` would fail when logging to WandB ([#17216](https://github.com/Lightning-AI/lightning/pull/17216))
2122

2223

2324
## [2.0.0] - 2023-03-15

0 commit comments

Comments
 (0)