diff --git a/python/sglang/multimodal_gen/runtime/layers/attention/backends/xpu_backend.py b/python/sglang/multimodal_gen/runtime/layers/attention/backends/xpu_backend.py index 783010317b77..229a7b17d58b 100644 --- a/python/sglang/multimodal_gen/runtime/layers/attention/backends/xpu_backend.py +++ b/python/sglang/multimodal_gen/runtime/layers/attention/backends/xpu_backend.py @@ -119,3 +119,30 @@ def forward( result = out.reshape(bsz, seqlen_q, nheads_q, d) return result + + def forward_varlen( + self, + query: torch.Tensor, + key: torch.Tensor, + value: torch.Tensor, + *, + cu_seqlens: torch.Tensor, + max_seqlen: int, + cu_seqlens_host: tuple[int, ...] | None = None, + ) -> torch.Tensor: + del cu_seqlens_host + q_ = query.contiguous() + k_ = key.contiguous() + v_ = value.contiguous() + output = flash_attn_func( + q=q_, + k=k_, + v=v_, + cu_seqlens_q=cu_seqlens, + cu_seqlens_k=cu_seqlens, + max_seqlen_q=max_seqlen, + max_seqlen_k=max_seqlen, + softmax_scale=self.softmax_scale, + causal=self.causal, + ) + return output[0] if isinstance(output, tuple) else output diff --git a/python/sglang/multimodal_gen/runtime/managers/memory_managers/component_manager.py b/python/sglang/multimodal_gen/runtime/managers/memory_managers/component_manager.py index 7984fd51ed98..e7dfc71167da 100644 --- a/python/sglang/multimodal_gen/runtime/managers/memory_managers/component_manager.py +++ b/python/sglang/multimodal_gen/runtime/managers/memory_managers/component_manager.py @@ -908,6 +908,7 @@ def _module_on_supported_device(self, module: nn.Module | None) -> bool: current_platform.is_cuda() or current_platform.is_rocm() or current_platform.is_npu() + or current_platform.is_xpu() ) return is_supported_platform and current_platform.is_device_type( self._module_device(module) diff --git a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/keyframe_encoding.py b/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/keyframe_encoding.py index 49d74ae63727..11d55015dd69 100644 --- a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/keyframe_encoding.py +++ b/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/keyframe_encoding.py @@ -48,6 +48,7 @@ def minimax_h3_scoped_encode_rng(seed: int, device: torch.device | None = None): current_platform.is_cuda() or current_platform.is_rocm() or current_platform.is_npu() + or current_platform.is_xpu() ) if ( device is not None diff --git a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/denoising.py b/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/denoising.py index 93ec9c2f214d..5d5901b24b2f 100644 --- a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/denoising.py +++ b/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/denoising.py @@ -679,9 +679,10 @@ def _run_full_loop(self, batch: Req, server_args: ServerArgs) -> None: or current_platform.is_cpu() or current_platform.is_mps() or current_platform.is_npu() + or current_platform.is_xpu() ): raise RuntimeError( - "MiniMax H3 full-loop denoise requires CPU, CUDA, MPS, or Ascend NPU" + "MiniMax H3 full-loop denoise requires CPU, CUDA, MPS, XPU, or Ascend NPU" ) device = current_platform.get_local_torch_device()