[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:
co-authored by
Harry Mellor
parent
fcaa84efa7
commit
e840f0d3f5
@@ -272,7 +272,7 @@ class DeepseekV4Attention(nn.Module, AttentionLayerBase, ABC):
|
||||
# [0]: GEMM start / post-GEMM event0. [1..3]: GEMM done events;
|
||||
# [1] doubles as post-GEMM event1. Reuse is safe: GEMM fully joins
|
||||
# before post-GEMM starts.
|
||||
self.ln_events = [torch.cuda.Event() for _ in range(4)]
|
||||
self.ln_events = [torch.Event() for _ in range(4)]
|
||||
|
||||
assert cache_config is not None, "DeepseekV4 attention requires cache_config"
|
||||
# ---- Attention / KV-cache setup ----
|
||||
@@ -760,10 +760,7 @@ class DeepseekV4Indexer(nn.Module):
|
||||
|
||||
# None on ROCm — maybe_execute_in_parallel falls back to sequential.
|
||||
self.aux_stream = aux_stream
|
||||
self.ln_events: list[torch.cuda.Event] = [
|
||||
torch.cuda.Event(),
|
||||
torch.cuda.Event(),
|
||||
]
|
||||
self.ln_events: list[torch.Event] = [torch.Event(), torch.Event()]
|
||||
|
||||
def forward(
|
||||
self,
|
||||
|
||||
@@ -44,17 +44,6 @@ class DeepseekV4XPUAttention(DeepseekV4Attention):
|
||||
backend_cls = DeepseekV4XPUSparseBackend
|
||||
use_flashmla_fp8_layout = True
|
||||
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
# torch.cuda.Event() raises RuntimeError on XPU ("dummy base class").
|
||||
# The Base and DeepseekV4Indexer both create cuda Events in __init__, so
|
||||
# we temporarily redirect torch.cuda.Event → torch.xpu.Event.
|
||||
_orig_event = torch.cuda.Event
|
||||
torch.cuda.Event = torch.xpu.Event # type: ignore[misc]
|
||||
try:
|
||||
super().__init__(*args, **kwargs)
|
||||
finally:
|
||||
torch.cuda.Event = _orig_event # type: ignore[misc]
|
||||
|
||||
def _fused_qnorm_rope_kv_insert(self, q, kv, positions, attn_metadata):
|
||||
from typing import cast
|
||||
|
||||
|
||||
Reference in New Issue
Block a user