mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-06-01 23:51:18 +08:00
Merge fd593c596de73fcb98ee8636150a385ea896b43d into 254f6b986720c92ddf97fbb1a6a6465da8e87e29
This commit is contained in:
commit
3bb2e7950a
@ -293,7 +293,7 @@ class CommunicatorBenchmark:
|
|||||||
graph = torch.cuda.CUDAGraph()
|
graph = torch.cuda.CUDAGraph()
|
||||||
graph_pool = torch.cuda.graph_pool_handle()
|
graph_pool = torch.cuda.graph_pool_handle()
|
||||||
set_graph_pool_id(graph_pool)
|
set_graph_pool_id(graph_pool)
|
||||||
with torch.cuda.graph(graph, pool=graph_pool):
|
with torch.cuda.graph(graph, pool=graph_pool, stream=stream):
|
||||||
for _ in range(CUDA_GRAPH_CAPTURE_CYCLES):
|
for _ in range(CUDA_GRAPH_CAPTURE_CYCLES):
|
||||||
allreduce_fn(graph_input)
|
allreduce_fn(graph_input)
|
||||||
|
|
||||||
|
|||||||
@ -189,13 +189,16 @@ class TestCUDAGraphWrapper:
|
|||||||
self.model, self.vllm_config, runtime_mode=CUDAGraphMode.FULL
|
self.model, self.vllm_config, runtime_mode=CUDAGraphMode.FULL
|
||||||
)
|
)
|
||||||
batch_descriptor = BatchDescriptor(num_tokens=10)
|
batch_descriptor = BatchDescriptor(num_tokens=10)
|
||||||
|
stream = torch.cuda.Stream()
|
||||||
# 0. global warmup
|
# 0. global warmup
|
||||||
with set_forward_context(
|
with (
|
||||||
attn_metadata=None,
|
set_forward_context(
|
||||||
vllm_config=self.vllm_config,
|
attn_metadata=None,
|
||||||
cudagraph_runtime_mode=CUDAGraphMode.NONE,
|
vllm_config=self.vllm_config,
|
||||||
batch_descriptor=None,
|
cudagraph_runtime_mode=CUDAGraphMode.NONE,
|
||||||
|
batch_descriptor=None,
|
||||||
|
),
|
||||||
|
torch.cuda.stream(stream),
|
||||||
):
|
):
|
||||||
wrapper(self.input_tensor)
|
wrapper(self.input_tensor)
|
||||||
|
|
||||||
@ -208,6 +211,7 @@ class TestCUDAGraphWrapper:
|
|||||||
batch_descriptor=batch_descriptor,
|
batch_descriptor=batch_descriptor,
|
||||||
),
|
),
|
||||||
patch("torch.cuda.graph", wraps=torch.cuda.graph) as mock_cuda_graph,
|
patch("torch.cuda.graph", wraps=torch.cuda.graph) as mock_cuda_graph,
|
||||||
|
torch.cuda.stream(stream),
|
||||||
):
|
):
|
||||||
output1 = wrapper(self.input_tensor)
|
output1 = wrapper(self.input_tensor)
|
||||||
# capturing phase should generate a zero output
|
# capturing phase should generate a zero output
|
||||||
|
|||||||
@ -263,7 +263,11 @@ class CUDAGraphWrapper:
|
|||||||
else:
|
else:
|
||||||
set_graph_pool_id(current_platform.graph_pool_handle())
|
set_graph_pool_id(current_platform.graph_pool_handle())
|
||||||
# mind-exploding: carefully manage the reference and memory.
|
# mind-exploding: carefully manage the reference and memory.
|
||||||
with torch.cuda.graph(cudagraph, pool=self.graph_pool):
|
with torch.cuda.graph(
|
||||||
|
cudagraph,
|
||||||
|
pool=self.graph_pool,
|
||||||
|
stream=torch.cuda.current_stream(),
|
||||||
|
):
|
||||||
# `output` is managed by pytorch's cudagraph pool
|
# `output` is managed by pytorch's cudagraph pool
|
||||||
output = self.runnable(*args, **kwargs)
|
output = self.runnable(*args, **kwargs)
|
||||||
if self.cudagraph_options.weak_ref_output:
|
if self.cudagraph_options.weak_ref_output:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user