From c2fb013312e107c6809b1bf5cc4f22e499e1b81d Mon Sep 17 00:00:00 2001 From: roikoren755 <26850796+roikoren755@users.noreply.github.com> Date: Thu, 30 Apr 2026 00:59:18 +0300 Subject: [PATCH] [Bugfix][Compile] Fix gc.collect/empty_cache patch arity in CUDAGraphWrapper (#41235) Signed-off-by: Roi Koren --- vllm/compilation/cuda_graph.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vllm/compilation/cuda_graph.py b/vllm/compilation/cuda_graph.py index 00bf4bbc71f..b63d8619972 100644 --- a/vllm/compilation/cuda_graph.py +++ b/vllm/compilation/cuda_graph.py @@ -290,9 +290,14 @@ class CUDAGraphWrapper: # across layers will make the cudagraph capture very slow. # therefore, we only run gc for the first graph, # and disable gc for the rest of the graphs. - stack.enter_context(patch("gc.collect", lambda: None)) stack.enter_context( - patch("torch.accelerator.empty_cache", lambda: None) + patch("gc.collect", lambda *args, **kwargs: None) + ) + stack.enter_context( + patch( + "torch.accelerator.empty_cache", + lambda *args, **kwargs: None, + ) ) if self.graph_pool is not None: