Measure encoder compile time seperate from llm backbone (#39240)
Signed-off-by: Lucas Kabela <lucaskabela@meta.com>
This commit is contained in:
@@ -265,6 +265,7 @@ class CompilerManager:
|
||||
compile_range: Range,
|
||||
graph_index: int = 0,
|
||||
num_graphs: int = 1,
|
||||
is_encoder: bool = False,
|
||||
) -> Any:
|
||||
if graph_index == 0:
|
||||
# before compiling the first graph, record the start time
|
||||
@@ -282,7 +283,10 @@ class CompilerManager:
|
||||
# after loading the last graph for this shape, record the time.
|
||||
# there can be multiple graphs due to piecewise compilation.
|
||||
elapsed = time.perf_counter() - compilation_start_time
|
||||
compilation_config.compilation_time += elapsed
|
||||
if is_encoder:
|
||||
compilation_config.encoder_compilation_time += elapsed
|
||||
else:
|
||||
compilation_config.compilation_time += elapsed
|
||||
logger.info_once(
|
||||
"Directly load the compiled graph(s) for compile range %s "
|
||||
"from the cache, took %.3f s",
|
||||
@@ -387,7 +391,10 @@ class CompilerManager:
|
||||
# after compiling the last graph, record the end time
|
||||
if graph_index == num_graphs - 1:
|
||||
elapsed = time.perf_counter() - compilation_start_time
|
||||
compilation_config.compilation_time += elapsed
|
||||
if is_encoder:
|
||||
compilation_config.encoder_compilation_time += elapsed
|
||||
else:
|
||||
compilation_config.compilation_time += elapsed
|
||||
logger.info_once(
|
||||
"Compiling a graph for compile range %s takes %.2f s",
|
||||
str(compile_range),
|
||||
@@ -1130,7 +1137,10 @@ class VllmBackend:
|
||||
logger.info_once(
|
||||
"Dynamo bytecode transform time: %.2f s", dynamo_time, scope="local"
|
||||
)
|
||||
self.compilation_config.compilation_time += dynamo_time
|
||||
if self.is_encoder:
|
||||
self.compilation_config.encoder_compilation_time += dynamo_time
|
||||
else:
|
||||
self.compilation_config.compilation_time += dynamo_time
|
||||
|
||||
# Record Dynamo time in tracing if available
|
||||
start_time = int(torch_compile_start_time * 1e9)
|
||||
|
||||
@@ -270,6 +270,7 @@ class PiecewiseBackend:
|
||||
compile_range=range_entry.compile_range,
|
||||
graph_index=self.piecewise_compile_index,
|
||||
num_graphs=self.total_piecewise_compiles,
|
||||
is_encoder=self.vllm_backend.is_encoder,
|
||||
)
|
||||
|
||||
range_entry.compiled = True
|
||||
|
||||
Reference in New Issue
Block a user