From aaa682346ee562cf49e83e0a19f2c709a2fd8ff4 Mon Sep 17 00:00:00 2001 From: Aleksi Vesanto Date: Thu, 16 Apr 2026 10:29:23 +0300 Subject: [PATCH] [diffusion] model: Properly validate device for Mistral 3 attention (#22690) --- .../multimodal_gen/runtime/models/encoders/mistral_3.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/sglang/multimodal_gen/runtime/models/encoders/mistral_3.py b/python/sglang/multimodal_gen/runtime/models/encoders/mistral_3.py index f86c3460f..8d3ca5f14 100644 --- a/python/sglang/multimodal_gen/runtime/models/encoders/mistral_3.py +++ b/python/sglang/multimodal_gen/runtime/models/encoders/mistral_3.py @@ -41,6 +41,7 @@ from transformers.models.mistral.modeling_mistral import ( ) from sglang.multimodal_gen.runtime.loader.weight_utils import default_weight_loader +from sglang.multimodal_gen.runtime.platforms import current_platform from sglang.multimodal_gen.runtime.utils.logging_utils import init_logger logger = init_logger(__name__) @@ -426,7 +427,9 @@ class Mistral3ForConditionalGeneration(nn.Module): execution_tensor = input_ids if input_ids is not None else inputs_embeds sdpa_context = ( sdpa_kernel(SDPBackend.CUDNN_ATTENTION) - if execution_tensor is not None and execution_tensor.device.type == "cuda" + if execution_tensor is not None + and execution_tensor.device.type == "cuda" + and current_platform.is_cuda() else nullcontext() ) with sdpa_context: