From 4dd9e257b7f42b1b19b96b1ce6f8963443f2cf54 Mon Sep 17 00:00:00 2001 From: Zhiyuan Li Date: Fri, 20 Dec 2024 01:39:10 +0000 Subject: [PATCH] fix: RET505 --- src/lightning/fabric/strategies/ddp.py | 6 +++--- src/lightning/pytorch/strategies/ddp.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lightning/fabric/strategies/ddp.py b/src/lightning/fabric/strategies/ddp.py index a9b8a1787bb2c..daa1ebf959b95 100644 --- a/src/lightning/fabric/strategies/ddp.py +++ b/src/lightning/fabric/strategies/ddp.py @@ -242,11 +242,11 @@ def _create_stream_context(self, device_ids=None): and device_ids is not None ): stream = self.torch_lib.Stream() - return self.torch_lib.stream(stream) + ctx = self.torch_lib.stream(stream) else: from contextlib import nullcontext - - return nullcontext() + ctx = nullcontext() + return ctx class _DDPBackwardSyncControl(_BackwardSyncControl): diff --git a/src/lightning/pytorch/strategies/ddp.py b/src/lightning/pytorch/strategies/ddp.py index 32ef51d09e00b..458d2089ffbce 100644 --- a/src/lightning/pytorch/strategies/ddp.py +++ b/src/lightning/pytorch/strategies/ddp.py @@ -431,11 +431,11 @@ def _create_stream_context(self, device_ids=None): and device_ids is not None ): stream = self.torch_lib.Stream() - return self.torch_lib.stream(stream) + ctx = self.torch_lib.stream(stream) else: from contextlib import nullcontext - - return nullcontext() + ctx = nullcontext() + return ctx class _DDPForwardRedirection(_ForwardRedirection):