[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>
Jakub Byczkowski committed
Aug 18, 2026 at 01:54 UTC
c296cf8259ed834b7174c59a2ee1f2f25967a87b
1 file changed
+12
vllm/model_executor/layers/rotary_embedding/xdrope.py
+12
@@ -137,6 +137,18 @@ class XDRotaryEmbedding(DynamicNTKAlphaRotaryEmbedding):
137
key = torch.cat((key_rot, key_pass), dim=-1).reshape(key_shape)
138
return query, key
139
140
+ def forward_xpu(
141
+ self,
142
+ positions: torch.Tensor,
143
+ query: torch.Tensor,
144
+ key: torch.Tensor | None = None,
145
+ offsets: torch.Tensor | None = None,
146
+ ) -> tuple[torch.Tensor, torch.Tensor | None]:
147
+ # No fused XPU kernel for XD-sectioned RoPE; the base
148
+ # RotaryEmbedding.forward_xpu calls the generic C++ kernel, which
149
+ # rejects the 2-D [4, num_tokens] xdrope positions. Use the native path.
150
+ return self.forward_native(positions, query, key, offsets)
151
+
152
@staticmethod
153
def get_next_input_positions(
154
context_len: int,