[XPU] Qwen3.8-flash-next enablement (#37213)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -250,9 +250,9 @@ def fused_mamba_state_scatter_with_mask(
|
||||
raise ValueError(
|
||||
f"dst and src must be on the same device. {dst.device=} {src.device=}"
|
||||
)
|
||||
if not dst.is_cuda or not src.is_cuda:
|
||||
if not (dst.is_cuda or dst.is_xpu) or dst.device != src.device:
|
||||
raise ValueError(
|
||||
"fused_mamba_state_scatter_with_mask only supports CUDA tensors."
|
||||
"fused_mamba_state_scatter_with_mask only supports CUDA/XPU tensors."
|
||||
)
|
||||
if dst.ndim < 2 or src.ndim < 3:
|
||||
raise ValueError(f"Unexpected tensor ranks: {dst.ndim=} {src.ndim=}")
|
||||
@@ -410,10 +410,10 @@ def fused_conv_window_scatter_with_mask(
|
||||
if total_requests == 0:
|
||||
return
|
||||
|
||||
if not (dst.is_cuda and src.is_cuda and dst.device == src.device):
|
||||
if not (dst.is_cuda or dst.is_xpu) or dst.device != src.device:
|
||||
raise ValueError(
|
||||
"fused_conv_window_scatter_with_mask requires dst and src to be CUDA "
|
||||
f"tensors on the same device ({dst.device=}, {src.device=})."
|
||||
"fused_conv_window_scatter_with_mask requires dst and src to be "
|
||||
f"CUDA/XPU tensors on the same device ({dst.device=}, {src.device=})."
|
||||
)
|
||||
if dst.ndim != 4 or src.ndim != 5:
|
||||
raise ValueError(f"Unexpected ranks: {dst.ndim=} (want 4) {src.ndim=} (want 5)")
|
||||
|
||||
@@ -95,6 +95,11 @@ def fused_sigmoid_gating_delta_rule_update(
|
||||
o=o,
|
||||
h0_source=initial_state_source,
|
||||
h0_indices=initial_state_indices,
|
||||
# Envelope-strided state pools (page-major / unified memory) have a
|
||||
# per-slot pitch != HV*K*V; contiguous pools pass exactly HV*K*V.
|
||||
stride_h0_source=(
|
||||
initial_state_source.stride(0) if initial_state_source is not None else 0
|
||||
),
|
||||
cu_seqlens=cu_seqlens,
|
||||
intermediate_states_buffer=intermediate_states_buffer,
|
||||
intermediate_state_indices=intermediate_state_indices,
|
||||
|
||||
@@ -519,13 +519,16 @@ class QSAIndexer(MultiPlatformOp):
|
||||
token_topk=self.token_topk,
|
||||
)
|
||||
|
||||
def forward_cuda(
|
||||
def _forward_impl(
|
||||
self,
|
||||
hidden_states: torch.Tensor,
|
||||
positions: torch.Tensor,
|
||||
forward_batch,
|
||||
indexer_metadata,
|
||||
) -> torch.Tensor:
|
||||
"""Portable orchestration shared by different platforms.
|
||||
Fast paths are gated per platforms inside kernel calls.
|
||||
"""
|
||||
forward_mode = forward_batch.forward_mode
|
||||
is_target_verify = getattr(forward_mode, "is_target_verify", lambda: False)()
|
||||
is_draft_extend = getattr(forward_mode, "is_draft_extend_v2", lambda: False)()
|
||||
@@ -628,6 +631,28 @@ class QSAIndexer(MultiPlatformOp):
|
||||
row_sequence_lengths,
|
||||
)
|
||||
|
||||
def forward_cuda(
|
||||
self,
|
||||
hidden_states: torch.Tensor,
|
||||
positions: torch.Tensor,
|
||||
forward_batch,
|
||||
indexer_metadata,
|
||||
) -> torch.Tensor:
|
||||
return self._forward_impl(
|
||||
hidden_states, positions, forward_batch, indexer_metadata
|
||||
)
|
||||
|
||||
def forward_xpu(
|
||||
self,
|
||||
hidden_states: torch.Tensor,
|
||||
positions: torch.Tensor,
|
||||
forward_batch,
|
||||
indexer_metadata,
|
||||
) -> torch.Tensor:
|
||||
return self._forward_impl(
|
||||
hidden_states, positions, forward_batch, indexer_metadata
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"QSAIndexer",
|
||||
|
||||
@@ -139,14 +139,14 @@ class GatedResidual(HyperConnectionBase):
|
||||
self.hidden_size * self.hc_count,
|
||||
self.config.hc_lowrank,
|
||||
bias=False,
|
||||
device=torch.cuda.current_device(),
|
||||
device=torch.get_device_module().current_device(),
|
||||
dtype=config.params_dtype,
|
||||
)
|
||||
self.input_mix_weight_up = nn.Linear(
|
||||
self.config.hc_lowrank,
|
||||
self.hc_count * self.hidden_size,
|
||||
bias=False,
|
||||
device=torch.cuda.current_device(),
|
||||
device=torch.get_device_module().current_device(),
|
||||
dtype=config.params_dtype,
|
||||
)
|
||||
lowrank = self.config.hc_lowrank
|
||||
@@ -166,7 +166,7 @@ class GatedResidual(HyperConnectionBase):
|
||||
self.hidden_size * self.hc_count,
|
||||
self.hc_count,
|
||||
bias=False,
|
||||
device=torch.cuda.current_device(),
|
||||
device=torch.get_device_module().current_device(),
|
||||
dtype=config.params_dtype,
|
||||
)
|
||||
# hc_combine rejects other shapes; device and dtype are checked per call.
|
||||
|
||||
Reference in New Issue
Block a user