[Bugfix] Add forward_xpu to XDRotaryEmbedding for HunyuanOCR on XPU (#52174)
Signed-off-by: Jakub Byczkowski <jakub.byczkowski@intel.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
parent
49fb2ee348
commit
c296cf8259
@@ -137,6 +137,18 @@ class XDRotaryEmbedding(DynamicNTKAlphaRotaryEmbedding):
|
|||||||
key = torch.cat((key_rot, key_pass), dim=-1).reshape(key_shape)
|
key = torch.cat((key_rot, key_pass), dim=-1).reshape(key_shape)
|
||||||
return query, key
|
return query, key
|
||||||
|
|
||||||
|
def forward_xpu(
|
||||||
|
self,
|
||||||
|
positions: torch.Tensor,
|
||||||
|
query: torch.Tensor,
|
||||||
|
key: torch.Tensor | None = None,
|
||||||
|
offsets: torch.Tensor | None = None,
|
||||||
|
) -> tuple[torch.Tensor, torch.Tensor | None]:
|
||||||
|
# No fused XPU kernel for XD-sectioned RoPE; the base
|
||||||
|
# RotaryEmbedding.forward_xpu calls the generic C++ kernel, which
|
||||||
|
# rejects the 2-D [4, num_tokens] xdrope positions. Use the native path.
|
||||||
|
return self.forward_native(positions, query, key, offsets)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_next_input_positions(
|
def get_next_input_positions(
|
||||||
context_len: int,
|
context_len: int,
|
||||||
|
|||||||
Reference in New Issue
Block a user