From d779dadda12ead73e02a903ca377330ee3328eff Mon Sep 17 00:00:00 2001 From: Jeffrey Dunn Date: Wed, 22 Mar 2023 18:34:13 +0000 Subject: [PATCH] Remove stack trace captures from import (#97274) Summary: Calls to this function without an argument will get a stack trace at import time. This is expensive, we can just skip it by passing in a value. Test Plan: Wait for tests Differential Revision: D44244345 Pull Request resolved: https://github.com/pytorch/pytorch/pull/97274 Approved by: https://github.com/kiukchung --- torch/distributed/elastic/agent/server/api.py | 2 +- torch/distributed/elastic/agent/server/local_elastic_agent.py | 2 +- torch/distributed/elastic/multiprocessing/__init__.py | 2 +- torch/distributed/elastic/multiprocessing/errors/__init__.py | 2 +- torch/distributed/elastic/utils/distributed.py | 2 +- torch/distributed/launcher/api.py | 2 +- torch/distributed/run.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/torch/distributed/elastic/agent/server/api.py b/torch/distributed/elastic/agent/server/api.py index a9907663bb58cc..92faad8e0bdff1 100644 --- a/torch/distributed/elastic/agent/server/api.py +++ b/torch/distributed/elastic/agent/server/api.py @@ -36,7 +36,7 @@ _TERMINAL_STATE_SYNC_ID = "torchelastic/agent/terminal_state" DEFAULT_ROLE = "default" -log = get_logger() +log = get_logger(__name__) @dataclass diff --git a/torch/distributed/elastic/agent/server/local_elastic_agent.py b/torch/distributed/elastic/agent/server/local_elastic_agent.py index 6f14eb07ff328c..639929b23cf5be 100644 --- a/torch/distributed/elastic/agent/server/local_elastic_agent.py +++ b/torch/distributed/elastic/agent/server/local_elastic_agent.py @@ -32,7 +32,7 @@ from torch.distributed.elastic.utils import macros from torch.distributed.elastic.utils.logging import get_logger -log = get_logger() +log = get_logger(__name__) __all__ = [ "LocalElasticAgent", diff --git a/torch/distributed/elastic/multiprocessing/__init__.py b/torch/distributed/elastic/multiprocessing/__init__.py index b5916cd95d750e..324e5827e758c6 100644 --- a/torch/distributed/elastic/multiprocessing/__init__.py +++ b/torch/distributed/elastic/multiprocessing/__init__.py @@ -79,7 +79,7 @@ def trainer(a, b, c): ) from torch.distributed.elastic.utils.logging import get_logger -log = get_logger() +log = get_logger(__name__) def start_processes( diff --git a/torch/distributed/elastic/multiprocessing/errors/__init__.py b/torch/distributed/elastic/multiprocessing/errors/__init__.py index 46c18d32b058c9..92d1368c9cd34d 100644 --- a/torch/distributed/elastic/multiprocessing/errors/__init__.py +++ b/torch/distributed/elastic/multiprocessing/errors/__init__.py @@ -67,7 +67,7 @@ __all__ = ["ProcessFailure", "ChildFailedError", "record", "ErrorHandler", "get_error_handler"] -log = get_logger() +log = get_logger(__name__) JSON = Dict diff --git a/torch/distributed/elastic/utils/distributed.py b/torch/distributed/elastic/utils/distributed.py index b1309ffd727721..15d81ee3a84012 100644 --- a/torch/distributed/elastic/utils/distributed.py +++ b/torch/distributed/elastic/utils/distributed.py @@ -13,7 +13,7 @@ from torch.distributed.elastic.utils.logging import get_logger -log = get_logger() +log = get_logger(__name__) _ADDRESS_IN_USE = "Address already in use" _SOCKET_TIMEOUT = "Socket Timeout" diff --git a/torch/distributed/launcher/api.py b/torch/distributed/launcher/api.py index a699e7f98239e7..361114a60afd19 100644 --- a/torch/distributed/launcher/api.py +++ b/torch/distributed/launcher/api.py @@ -22,7 +22,7 @@ __all__ = ['LaunchConfig', 'elastic_launch', 'launch_agent'] -logger = get_logger() +logger = get_logger(__name__) @dataclass diff --git a/torch/distributed/run.py b/torch/distributed/run.py index 0d0ce01e9988da..1a6c455368313b 100644 --- a/torch/distributed/run.py +++ b/torch/distributed/run.py @@ -386,7 +386,7 @@ def main(): from torch.distributed.launcher.api import LaunchConfig, elastic_launch -log = get_logger() +log = get_logger(__name__) def get_args_parser() -> ArgumentParser: