mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-13 13:35:36 +08:00
[Model Runner V2][BugFix] Keep reference to GPU tensors in AsyncOutput (#29623)
Signed-off-by: Woosuk Kwon <woosuk.kwon@berkeley.edu>
This commit is contained in:
parent
a5345bf49d
commit
ae0ce1be27
@ -21,6 +21,9 @@ class AsyncOutput(AsyncModelRunnerOutput):
|
|||||||
copy_stream: torch.cuda.Stream,
|
copy_stream: torch.cuda.Stream,
|
||||||
copy_event: torch.cuda.Event,
|
copy_event: torch.cuda.Event,
|
||||||
):
|
):
|
||||||
|
# NOTE(woosuk): We must retain references to the GPU tensors,
|
||||||
|
# as the copy operations are performed on a different CUDA stream than
|
||||||
|
# the one where the tensors were created.
|
||||||
self.model_runner_output = model_runner_output
|
self.model_runner_output = model_runner_output
|
||||||
self.sampler_output = sampler_output
|
self.sampler_output = sampler_output
|
||||||
self.num_sampled_tokens = num_sampled_tokens
|
self.num_sampled_tokens = num_sampled_tokens
|
||||||
@ -51,7 +54,9 @@ class AsyncOutput(AsyncModelRunnerOutput):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.logprobs_tensors = None
|
self.logprobs_tensors = None
|
||||||
self.num_sampled_tokens = num_sampled_tokens.to("cpu", non_blocking=True)
|
self.num_sampled_tokens_cpu = num_sampled_tokens.to(
|
||||||
|
"cpu", non_blocking=True
|
||||||
|
)
|
||||||
self.prompt_logprobs_dict: dict[str, LogprobsTensors | None] = {}
|
self.prompt_logprobs_dict: dict[str, LogprobsTensors | None] = {}
|
||||||
if self.model_runner_output.prompt_logprobs_dict:
|
if self.model_runner_output.prompt_logprobs_dict:
|
||||||
for k, v in self.model_runner_output.prompt_logprobs_dict.items():
|
for k, v in self.model_runner_output.prompt_logprobs_dict.items():
|
||||||
@ -63,7 +68,7 @@ class AsyncOutput(AsyncModelRunnerOutput):
|
|||||||
|
|
||||||
def get_output(self) -> ModelRunnerOutput:
|
def get_output(self) -> ModelRunnerOutput:
|
||||||
self.copy_event.synchronize()
|
self.copy_event.synchronize()
|
||||||
num_sampled_tokens_np = self.num_sampled_tokens.numpy()
|
num_sampled_tokens_np = self.num_sampled_tokens_cpu.numpy()
|
||||||
|
|
||||||
# NOTE(woosuk): The following code is to ensure compatibility with
|
# NOTE(woosuk): The following code is to ensure compatibility with
|
||||||
# the existing model runner.
|
# the existing model runner.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user