Skip to content

Commit fce8d4b

Browse files
akihironittalexierule
authored andcommitted
Fix false positive deprecation warning from register_ddp_comm_hook (#12846)
* Use new rank_zero_debug * Fix and move import statement to the top
1 parent c9c7ea5 commit fce8d4b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pytorch_lightning/utilities/distributed.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from pytorch_lightning.utilities.rank_zero import rank_zero_only # noqa: F401
2626
from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation
2727
from pytorch_lightning.utilities.rank_zero import rank_zero_info as new_rank_zero_info
28+
from pytorch_lightning.utilities.rank_zero import rank_zero_warn as new_rank_zero_warn
2829

2930
if _TPU_AVAILABLE:
3031
import torch_xla.core.xla_model as xm
@@ -281,23 +282,23 @@ def register_ddp_comm_hook(
281282
... ddp_comm_wrapper=default.fp16_compress_wrapper,
282283
... )
283284
"""
284-
from pytorch_lightning.utilities import rank_zero_warn
285-
286285
if ddp_comm_hook is None:
287286
return
288287
# inform mypy that ddp_comm_hook is callable
289288
ddp_comm_hook: Callable = ddp_comm_hook
290289

291290
if ddp_comm_wrapper is not None:
292291
if not _TORCH_GREATER_EQUAL_1_9:
293-
rank_zero_warn("Not applying DDP comm wrapper. To use communication wrapper, please use pytorch>=1.9.0.")
292+
new_rank_zero_warn(
293+
"Not applying DDP comm wrapper. To use communication wrapper, please use pytorch>=1.9.0."
294+
)
294295
else:
295296
new_rank_zero_info(
296297
f"DDP comm wrapper is provided, apply {ddp_comm_wrapper.__qualname__}({ddp_comm_hook.__qualname__})."
297298
)
298299
ddp_comm_hook = ddp_comm_wrapper(ddp_comm_hook)
299300

300-
rank_zero_debug(f"Registering DDP comm hook: {ddp_comm_hook.__qualname__}.")
301+
new_rank_zero_debug(f"Registering DDP comm hook: {ddp_comm_hook.__qualname__}.")
301302
model.register_comm_hook(state=ddp_comm_state, hook=ddp_comm_hook)
302303

303304

0 commit comments

Comments
 (0)