From ae6a6630e4febd8ba3aa4dc6d36b5090d6ed23b1 Mon Sep 17 00:00:00 2001 From: Xiaoyu Zhang <35585791+BBuf@users.noreply.github.com> Date: Sun, 7 Dec 2025 20:28:57 +0800 Subject: [PATCH] Add Expert Parallelism (EP) support for kimi-k2-thinking (#13725) --- .../compressed_tensors/compressed_tensors_moe.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python/sglang/srt/layers/quantization/compressed_tensors/compressed_tensors_moe.py b/python/sglang/srt/layers/quantization/compressed_tensors/compressed_tensors_moe.py index 8d0d475ac..4620d4506 100644 --- a/python/sglang/srt/layers/quantization/compressed_tensors/compressed_tensors_moe.py +++ b/python/sglang/srt/layers/quantization/compressed_tensors/compressed_tensors_moe.py @@ -714,6 +714,16 @@ class CompressedTensorsWNA16MoEMethod(CompressedTensorsMoEMethod): topk_weights, topk_ids, router_logits = topk_output + # Get expert_map for EP support + expert_map = None + global_num_experts = -1 + if hasattr(layer, "dispatcher") and hasattr( + layer.dispatcher, "local_expert_mapping" + ): + expert_map = layer.dispatcher.local_expert_mapping + if expert_map is not None: + global_num_experts = self.moe_runner_config.num_experts + output = fused_marlin_moe( x, layer.w13_weight_packed, @@ -723,6 +733,8 @@ class CompressedTensorsWNA16MoEMethod(CompressedTensorsMoEMethod): router_logits, topk_weights, topk_ids, + global_num_experts=global_num_experts, + expert_map=expert_map, g_idx1=layer.w13_weight_g_idx, g_idx2=layer.w2_weight_g_idx, sort_indices1=layer.w13_g_idx_sort_indices,