From a3196d08b8f6de3017cb2ea059a7025ee4504c9d Mon Sep 17 00:00:00 2001 From: Chad Voegele Date: Wed, 18 Mar 2026 16:54:43 -0500 Subject: [PATCH] [MiniMax M2] Fix KV cache scale loading (#20870) Co-authored-by: Claude Sonnet 4.6 (1M context) --- python/sglang/srt/models/minimax_m2.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/sglang/srt/models/minimax_m2.py b/python/sglang/srt/models/minimax_m2.py index 30815d8fa..3c7b36496 100644 --- a/python/sglang/srt/models/minimax_m2.py +++ b/python/sglang/srt/models/minimax_m2.py @@ -1076,10 +1076,18 @@ class MiniMaxM2ForCausalLM(nn.Module): if spec_layer is not None: continue # skip spec decode layers for main model + _is_kv_scale = name.endswith(".k_scale") or name.endswith(".v_scale") + for param_name, weight_name, shard_id in stacked_params_mapping: # Skip non-stacked layers and experts (experts handled below). if weight_name not in name: continue + # Skip kv cache scales - maybe_remap_kv_scale_name expects the + # original checkpoint name (e.g. self_attn.k_proj.k_scale) to + # remap it to self_attn.attn.k_scale. Renaming k_proj -> qkv_proj + # here would break that pattern match. + if _is_kv_scale: + continue # We have mlp.experts[0].gate_proj in the checkpoint. # Since we handle the experts below in expert_params_mapping, # we need to skip here BEFORE we update the name, otherwise