[Perf] Use blocking CUDA events to avoid busy polling cuda driver lock (#47081)

Signed-off-by: Jingyi Yang <girasoleyang@gmail.com>
This commit is contained in:
Summer Yang
2026-07-07 09:36:10 +00:00
committed by GitHub
parent c85d72076a
commit d3e69fd671
3 changed files with 13 additions and 6 deletions
+4 -2
View File
@@ -24,7 +24,8 @@ class AsyncOutput(AsyncModelRunnerOutput):
self.model_runner_output = model_runner_output
self.sampler_output = sampler_output
self.num_sampled_tokens = num_sampled_tokens
self.copy_event = torch.cuda.Event()
# Blocking (sleep) event to avoid busy-polling the CUDA driver lock.
self.copy_event = torch.cuda.Event(blocking=True)
with stream(copy_stream, main_stream):
copy_stream.wait_stream(main_stream)
@@ -81,7 +82,8 @@ class AsyncPoolingOutput(AsyncModelRunnerOutput):
self.model_runner_output = model_runner_output
self.pooler_output = pooler_output
self.is_valid = is_valid
self.copy_event = torch.cuda.Event()
# Blocking (sleep) event to avoid busy-polling the CUDA driver lock.
self.copy_event = torch.cuda.Event(blocking=True)
with stream(copy_stream, main_stream):
copy_stream.wait_stream(main_stream)