[Bugfix][V2] Warm up kernels before capturing CUDA graphs (#55341)

Signed-off-by: aoshen02 <aoshen02@users.noreply.github.com>
Signed-off-by: Nick Hill <nickhill123@gmail.com>
Co-authored-by: aoshen02 <aoshen02@users.noreply.github.com>
Co-authored-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
aoshen02
2026-09-04 22:44:18 +00:00
committed by GitHub
co-authored by aoshen02 Nick Hill
parent 8f269a93bb
commit 685074cd61
7 changed files with 129 additions and 16 deletions
+1 -1
View File
@@ -828,7 +828,7 @@ def profile_cudagraph_memory(runner: "GPUModelRunner") -> int:
mem_samples: list[int] = []
manager._capture_mem_samples = mem_samples
measured = int(runner.capture_model())
measured = int(runner.capture_model(profile_only=True))
# The measured delta covers PIECEWISE, encoder and speculator graphs
# plus the sampled FULL graphs; swap the sampled FULL cost for the
+7 -2
View File
@@ -173,7 +173,7 @@ from vllm.v1.worker.utils import (
copy_kv_cache_blocks_inplace,
get_uniform_decode_token_count,
)
from vllm.v1.worker.workspace import use_workspace_lane
from vllm.v1.worker.workspace import lock_workspace, use_workspace_lane
logger = init_logger(__name__)
@@ -928,7 +928,7 @@ class GPUModelRunner(LoRAModelRunnerMixin):
return _profile_cudagraph_memory(self)
@torch.inference_mode()
def capture_model(self) -> int:
def capture_model(self, *, profile_only: bool = False) -> int:
assert self.cudagraph_manager is not None
capture_encoder = (
self.model_state.supports_mm_inputs
@@ -986,6 +986,11 @@ class GPUModelRunner(LoRAModelRunnerMixin):
end_free_gpu_memory = torch.accelerator.get_memory_info()[0]
if not profile_only:
# Lock workspace to prevent resizing during execution. A resize after
# capture frees the static cuda graph buffer.
lock_workspace()
end_time = time.perf_counter()
elapsed_time = end_time - start_time
cuda_graph_size = start_free_gpu_memory - end_free_gpu_memory