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: