diff --git a/python/sglang/srt/utils/hf_transformers_utils.py b/python/sglang/srt/utils/hf_transformers_utils.py index bafff0464..31dfaadad 100644 --- a/python/sglang/srt/utils/hf_transformers_utils.py +++ b/python/sglang/srt/utils/hf_transformers_utils.py @@ -543,6 +543,27 @@ def get_config( else: raise + if ( + config.architectures is not None + and config.architectures[0] == "GlmMoeDsaForCausalLM" + ): + # GlmMoeDsaConfig.__init__ has no **kwargs, so HF drops raw config.json + # fields the DSA / IndexCache path reads via getattr (index_topk_freq, + # index_topk_pattern, index_skip_topk_offset) and may clobber + # qk_rope_head_dim. Re-read them from config.json and restore. + # (upstream PR #27114) Remove once transformers >= 5.10 (HF PR #46338). + raw_config, _ = PretrainedConfig.get_config_dict(model, revision=revision) + for key in ( + "qk_rope_head_dim", + "index_topk_freq", + "index_topk_pattern", + "index_skip_topk_offset", + ): + if key in raw_config: + setattr(config, key, raw_config[key]) + if hasattr(config, "qk_head_dim") and hasattr(config, "qk_nope_head_dim"): + config.qk_head_dim = config.qk_nope_head_dim + config.qk_rope_head_dim + if ( config.architectures is not None and config.architectures[0] == "Phi4MMForCausalLM"