[UX] Tag torch.compile log lines with the component being compiled (#48133)
Signed-off-by: Francesco Fusco <ffu@zurich.ibm.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Luka Govedič <ProExpertProg@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude
Luka Govedič
parent
d71f662606
commit
d5ee309314
@@ -17,18 +17,27 @@ torch_compile_start_time: float = 0.0
|
||||
@contextlib.contextmanager
|
||||
def monitor_torch_compile(
|
||||
vllm_config: VllmConfig,
|
||||
message: str = "torch.compile took %.2f s in total",
|
||||
message: str = "%storch.compile took %.2f s in total",
|
||||
is_encoder: bool = False,
|
||||
tag: str = "",
|
||||
announce_start: bool = True,
|
||||
) -> Generator[None, None, None]:
|
||||
"""Context manager that times torch.compile and manages depyf debugging.
|
||||
|
||||
On normal exit: logs the compile time and exits depyf.
|
||||
On exception: cleans up depyf without logging (compilation failed).
|
||||
|
||||
``announce_start=False`` suppresses the "Starting torch.compile" line;
|
||||
used by the AOT-load probe so a failed load attempt doesn't announce a
|
||||
compile it didn't perform.
|
||||
"""
|
||||
global torch_compile_start_time
|
||||
torch_compile_start_time = time.perf_counter()
|
||||
|
||||
compilation_config = vllm_config.compilation_config
|
||||
log_prefix = f"[{tag}] " if tag else ""
|
||||
if announce_start and compilation_config.mode == CompilationMode.VLLM_COMPILE:
|
||||
logger.info("%sStarting torch.compile", log_prefix)
|
||||
depyf_cm = None
|
||||
path = vllm_config.compile_debug_dump_path()
|
||||
if compilation_config.mode == CompilationMode.VLLM_COMPILE and path:
|
||||
@@ -50,7 +59,7 @@ def monitor_torch_compile(
|
||||
compilation_config.encoder_compilation_time += total_compile_time
|
||||
else:
|
||||
compilation_config.compilation_time += total_compile_time
|
||||
logger.info_once(message, total_compile_time)
|
||||
logger.info(message, log_prefix, total_compile_time)
|
||||
finally:
|
||||
if depyf_cm is not None:
|
||||
try:
|
||||
@@ -60,7 +69,7 @@ def monitor_torch_compile(
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def monitor_profiling_run() -> Generator[None, None, None]:
|
||||
def monitor_profiling_run(tag: str = "") -> Generator[None, None, None]:
|
||||
"""Context manager that times the initial profiling run.
|
||||
|
||||
Asserts that no backend compilation occurs during the profiling run
|
||||
@@ -78,8 +87,10 @@ def monitor_profiling_run() -> Generator[None, None, None]:
|
||||
"backend compilation occurred during the initial profiling run; "
|
||||
"all compilation should be complete before the profiling run starts."
|
||||
)
|
||||
logger.info_once(
|
||||
"Initial profiling/warmup run took %.2f s",
|
||||
log_prefix = f"[{tag}] " if tag else ""
|
||||
logger.info(
|
||||
"%sInitial profiling/warmup run took %.2f s",
|
||||
log_prefix,
|
||||
elapsed,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user