@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / f863994084
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 8, 00:00 UTC

[compile] Fix torch.compile time discrepancy in logging. (#34912)

Signed-off-by: zhxchen17 <zhxchen17@fb.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>

Zhengxu Chen committed Feb 20, 2026 at 11:47 UTC f8639940844bcc10e3f374d2bb5aa33ae52a2624
3 files changed +17 -8
vllm/compilation/backends.py
+4 -6
@@ -249,7 +249,7 @@ class CompilerManager:
249 if graph_index == 0:
250 # before compiling the first graph, record the start time
251 global compilation_start_time
252 - compilation_start_time = time.time()
252 + compilation_start_time = time.perf_counter()
253
254 compilation_counter.num_backend_compilations += 1
255
@@ -261,8 +261,7 @@ class CompilerManager:
261 if graph_index == num_graphs - 1:
262 # after loading the last graph for this shape, record the time.
263 # there can be multiple graphs due to piecewise compilation.
264 - now = time.time()
265 - elapsed = now - compilation_start_time
264 + elapsed = time.perf_counter() - compilation_start_time
265 compilation_config.compilation_time += elapsed
266 logger.info_once(
267 "Directly load the compiled graph(s) for compile range %s "
@@ -362,8 +361,7 @@ class CompilerManager:
361
362 # after compiling the last graph, record the end time
363 if graph_index == num_graphs - 1:
365 - now = time.time()
366 - elapsed = now - compilation_start_time
364 + elapsed = time.perf_counter() - compilation_start_time
365 compilation_config.compilation_time += elapsed
366 logger.info_once(
367 "Compiling a graph for compile range %s takes %.2f s",
@@ -974,7 +972,7 @@ class VllmBackend:
972 compilation_counter.num_graphs_seen += 1
973 from .monitor import torch_compile_start_time
974
977 - dynamo_time = time.time() - torch_compile_start_time
975 + dynamo_time = time.perf_counter() - torch_compile_start_time
976 logger.info_once(
977 "Dynamo bytecode transform time: %.2f s", dynamo_time, scope="local"
978 )
vllm/compilation/monitor.py
+3 -2
@@ -14,7 +14,7 @@ torch_compile_start_time: float = 0.0
14
15 def start_monitoring_torch_compile(vllm_config: VllmConfig) -> None:
16 global torch_compile_start_time
17 - torch_compile_start_time = time.time()
17 + torch_compile_start_time = time.perf_counter()
18
19 compilation_config: CompilationConfig = vllm_config.compilation_config
20 path = vllm_config.compile_debug_dump_path()
@@ -30,10 +30,11 @@ def start_monitoring_torch_compile(vllm_config: VllmConfig) -> None:
30
31 def end_monitoring_torch_compile(vllm_config: VllmConfig) -> None:
32 compilation_config: CompilationConfig = vllm_config.compilation_config
33 + total_compile_time: float = time.perf_counter() - torch_compile_start_time
34 if compilation_config.mode == CompilationMode.VLLM_COMPILE:
35 logger.info_once(
36 "torch.compile takes %.2f s in total",
36 - compilation_config.compilation_time,
37 + total_compile_time,
38 scope="local",
39 )
40 global context_manager
vllm/compilation/piecewise_backend.py
+10
@@ -5,6 +5,7 @@ import dataclasses
5 import io
6 import json
7 import pickle
8 +import time
9 from collections.abc import Callable
10 from pickle import Pickler
11 from typing import Any
@@ -164,7 +165,16 @@ class PiecewiseBackend:
165 if self.is_last_graph and not self.to_be_compiled_ranges:
166 # no specific sizes to compile
167 # save the hash of the inductor graph for the next run
168 + time_before_saving = time.perf_counter()
169 self.vllm_backend.compiler_manager.save_to_file()
170 + elapsed = time.perf_counter() - time_before_saving
171 + if elapsed > 1:
172 + logger.info_once(
173 + "Saved compiler manager cache in %.2f seconds.",
174 + elapsed,
175 + scope="local",
176 + )
177 +
178 end_monitoring_torch_compile(self.vllm_config)
179 # Call the completion callback (e.g., to save AOT compiled function)
180 if self.on_compilation_complete is not None: