[v1] fix compilation cache (#11598)
Signed-off-by: youkaichao <youkaichao@gmail.com>
This commit is contained in:
@@ -619,8 +619,10 @@ class PiecewiseBackend:
|
||||
# the entries for different shapes that we need to either
|
||||
# compile or capture cudagraph
|
||||
self.concrete_size_entries: Dict[int, ConcreteSizeEntry] = {}
|
||||
self.to_be_compiled_sizes: Set[int] = self.compile_sizes.union(
|
||||
self.capture_sizes)
|
||||
|
||||
# to_be_compiled_sizes tracks the remaining sizes to compile,
|
||||
# and updates during the compilation process, so we need to copy it
|
||||
self.to_be_compiled_sizes: Set[int] = self.compile_sizes.copy()
|
||||
for shape in self.compile_sizes.union(self.capture_sizes):
|
||||
self.concrete_size_entries[shape] = ConcreteSizeEntry(
|
||||
runtime_shape=shape,
|
||||
@@ -628,12 +630,17 @@ class PiecewiseBackend:
|
||||
use_cudagraph=shape in self.capture_sizes,
|
||||
)
|
||||
|
||||
def check_for_ending_compilation(self):
|
||||
if self.is_last_graph and not self.to_be_compiled_sizes:
|
||||
# no specific sizes to compile
|
||||
# save the hash of the inductor graph for the next run
|
||||
self.compilation_config.inductor_hash_cache.save_to_file()
|
||||
end_monitoring_torch_compile(self.vllm_config)
|
||||
|
||||
def __call__(self, *args) -> Any:
|
||||
if not self.first_run_finished:
|
||||
self.first_run_finished = True
|
||||
# no specific sizes to compile
|
||||
if self.is_last_graph and not self.to_be_compiled_sizes:
|
||||
end_monitoring_torch_compile(self.vllm_config)
|
||||
self.check_for_ending_compilation()
|
||||
return self.compiled_graph_for_general_shape(*args)
|
||||
|
||||
runtime_shape = args[self.sym_shape_indices[0]]
|
||||
@@ -662,10 +669,7 @@ class PiecewiseBackend:
|
||||
|
||||
# finished compilations for all required shapes
|
||||
if self.is_last_graph and not self.to_be_compiled_sizes:
|
||||
|
||||
# save the hash of the inductor graph for the next run
|
||||
self.compilation_config.inductor_hash_cache.save_to_file()
|
||||
end_monitoring_torch_compile(self.vllm_config)
|
||||
self.check_for_ending_compilation()
|
||||
|
||||
if not entry.use_cudagraph:
|
||||
return entry.runnable(*args)
|
||||
|
||||
Reference in New Issue
Block a user