From 15ff6982b94fad2fdf44607a040a146a5ae5d62c Mon Sep 17 00:00:00 2001 From: mrhaoxx Date: Thu, 27 Nov 2025 06:59:15 +0800 Subject: [PATCH] Support KTransformers for Qwen3-VL moe (#13983) --- python/sglang/srt/models/qwen3_vl_moe.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/sglang/srt/models/qwen3_vl_moe.py b/python/sglang/srt/models/qwen3_vl_moe.py index e810dae7e..e3e9e07d1 100644 --- a/python/sglang/srt/models/qwen3_vl_moe.py +++ b/python/sglang/srt/models/qwen3_vl_moe.py @@ -22,6 +22,7 @@ import torch import torch.nn as nn from sglang.srt.configs.qwen3_vl import Qwen3VLMoeConfig, Qwen3VLMoeTextConfig +from sglang.srt.eplb.expert_location import ModelConfigForExpertLocation from sglang.srt.layers.moe.fused_moe_triton.layer import FusedMoE from sglang.srt.layers.quantization.base_config import QuantizationConfig from sglang.srt.model_executor.forward_batch_info import ForwardBatch, PPProxyTensors @@ -326,5 +327,13 @@ class Qwen3VLMoeForConditionalGeneration(Qwen3VLForConditionalGeneration): # if isinstance(self.model.layers[layer_id].mlp, Qwen3MoeSparseMoeBlock) # } + @classmethod + def get_model_config_for_expert_location(cls, config): + return ModelConfigForExpertLocation( + num_layers=config.text_config.num_hidden_layers, + num_logical_experts=config.text_config.num_experts, + num_groups=None, + ) + EntryClass = Qwen3VLMoeForConditionalGeneration