[Platform] Replace torch.cuda.Event with torch.Event (#47140)

Signed-off-by: Kunshang Ji <kunshang.ji@intel.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Kunshang Ji
2026-06-30 08:39:59 -07:00
committed by GitHub
co-authored by Harry Mellor
parent fcaa84efa7
commit e840f0d3f5
31 changed files with 60 additions and 70 deletions
-1
View File
@@ -47,7 +47,6 @@ def get_memory_info(*args: Any, **kwargs: Any) -> tuple[int, int]:
torch.Event = _EventPlaceholder
torch.cuda.Event = _EventPlaceholder
torch.cuda.Stream = _StreamPlaceholder
torch.cuda.set_stream = noop
torch.cuda.current_stream = lambda *args, **kwargs: _StreamPlaceholder()
+2 -2
View File
@@ -24,7 +24,7 @@ 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()
self.copy_event = torch.Event()
with stream(copy_stream, main_stream):
copy_stream.wait_stream(main_stream)
@@ -81,7 +81,7 @@ 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()
self.copy_event = torch.Event()
with stream(copy_stream, main_stream):
copy_stream.wait_stream(main_stream)
+1 -1
View File
@@ -17,7 +17,7 @@ from vllm.v1.worker.gpu.input_batch import InputBatch
class PendingRecv:
"""Per-step slot data for a deferred postprocess on the main stream."""
event: torch.cuda.Event
event: torch.Event
sampled_tokens: torch.Tensor # [num_reqs, max_sample_len]
num_sampled: torch.Tensor # [num_reqs]
+1 -1
View File
@@ -12,7 +12,7 @@ class DraftTokensHandler:
def __init__(self, device: torch.device | None = None):
self.device = device
self.copy_stream = torch.cuda.Stream(device)
self.copy_event = torch.cuda.Event()
self.copy_event = torch.Event()
self.req_ids: list[str] = []
self.draft_tokens_np: np.ndarray | None = None
+2 -2
View File
@@ -839,7 +839,7 @@ class GPUModelRunner(
# N-gram GPU path: async D2H buffer/event for per-request valid draft counts.
self._num_valid_draft_tokens: torch.Tensor | None = None
self._num_valid_draft_tokens_cpu: torch.Tensor | None = None
self._num_valid_draft_tokens_event: torch.cuda.Event | None = None
self._num_valid_draft_tokens_event: torch.Event | None = None
self._num_valid_draft_tokens_copy_stream: torch.cuda.Stream | None = None
if (
self.speculative_config is not None
@@ -848,7 +848,7 @@ class GPUModelRunner(
self._num_valid_draft_tokens_cpu = torch.empty(
self.max_num_reqs, dtype=torch.int32, pin_memory=PIN_MEMORY
)
self._num_valid_draft_tokens_event = torch.cuda.Event()
self._num_valid_draft_tokens_event = torch.Event()
self._num_valid_draft_tokens_copy_stream = torch.cuda.Stream()
self._draft_token_req_ids: list[str] | None = None
-1
View File
@@ -45,7 +45,6 @@ def _torch_cuda_wrapper():
torch.cuda.default_stream = torch.xpu.current_stream
torch.cuda.current_stream = torch.xpu.current_stream
torch.cuda.stream = torch.xpu.stream
torch.cuda.Event = torch.Event
torch.cuda.set_stream = torch.xpu.set_stream
if supports_xpu_graph():
torch.cuda.graph = torch.xpu.graph