[Refactor] Clean up log once scope="local" (#40540)

Signed-off-by: yewentao256 <zhyanwentao@126.com>
Signed-off-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Wentao Ye
2026-04-22 16:42:43 -04:00
committed by GitHub
co-authored by gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
parent cfa49213d7
commit 8f87eb4622
44 changed files with 56 additions and 148 deletions
+4 -8
View File
@@ -63,7 +63,7 @@ class WorkerProfiler(ABC):
"""Call _stop with error handling but no safeguards."""
try:
self._stop()
logger.info_once("Profiler stopped successfully.", scope="local")
logger.info_once("Profiler stopped successfully.")
except Exception as e:
logger.warning("Failed to stop profiler: %s", e)
self._running = False # Always mark as not running, assume stop worked
@@ -93,7 +93,7 @@ class WorkerProfiler(ABC):
and self._delay_iters > 0
and self._active_iteration_count == self._delay_iters
):
logger.info_once("Starting profiler after delay...", scope="local")
logger.info_once("Starting profiler after delay...")
self._call_start()
# Call profiler step for schedule-based profiling
@@ -109,9 +109,7 @@ class WorkerProfiler(ABC):
# Automatically stop the profiler after max iters
# will be marked as not running, but leave as active so that stop
# can clean up properly
logger.info_once(
"Max profiling iterations reached. Stopping profiler...", scope="local"
)
logger.info_once("Max profiling iterations reached. Stopping profiler...")
self._call_stop()
return
@@ -141,7 +139,7 @@ class WorkerProfiler(ABC):
def shutdown(self) -> None:
"""Ensure profiler is stopped when shutting down."""
logger.info_once("Shutting down profiler", scope="local")
logger.info_once("Shutting down profiler")
if self._running:
self.stop()
@@ -176,7 +174,6 @@ class TorchProfilerWrapper(WorkerProfiler):
logger.info_once(
"Torch profiling enabled. Traces will be saved to: %s",
torch_profiler_trace_dir,
scope="local",
)
logger.debug(
"Profiler config: record_shapes=%s,"
@@ -216,7 +213,6 @@ class TorchProfilerWrapper(WorkerProfiler):
profiler_config.wait_iterations,
profiler_config.warmup_iterations,
profiler_config.active_iterations,
scope="local",
)
self.profiler = torch.profiler.profile(