[New Model] GLM4.7-Flash (#17247)

Co-authored-by: zRzRzRzRzRzRzR <2448370773@qq.com>
Co-authored-by: JustinTong0323 <justinning0323@gmail.com>
Co-authored-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
Co-authored-by: Baizhou Zhang <sobereddiezhang@gmail.com>
This commit is contained in:
Qiaolin Yu
2026-01-20 23:44:16 +08:00
committed by GitHub
co-authored by zRzRzRzRzRzRzR JustinTong0323 Xinyuan Tong Baizhou Zhang
parent 612026ad2c
commit 76b06bee03
6 changed files with 842 additions and 12 deletions
+19 -9
View File
@@ -269,7 +269,10 @@ class ModelConfig:
):
self.hf_config.architectures[0] = "DeepseekV3ForCausalLMNextN"
if is_draft_model and self.hf_config.architectures[0] == "Glm4MoeForCausalLM":
if is_draft_model and self.hf_config.architectures[0] in [
"Glm4MoeForCausalLM",
"Glm4MoeLiteForCausalLM",
]:
self.hf_config.architectures[0] = "Glm4MoeForCausalLMNextN"
if (
@@ -375,6 +378,7 @@ class ModelConfig:
or "DeepseekV32ForCausalLM" in self.hf_config.architectures
or "DeepseekV3ForCausalLM" in self.hf_config.architectures
or "DeepseekV3ForCausalLMNextN" in self.hf_config.architectures
or "Glm4MoeLiteForCausalLM" in self.hf_config.architectures
or "LongcatFlashForCausalLM" in self.hf_config.architectures
or "LongcatFlashForCausalLMNextN" in self.hf_config.architectures
or "DotsVLMForCausalLM" in self.hf_config.architectures
@@ -394,15 +398,21 @@ class ModelConfig:
else None
)
# Handle rope scaling with yarn
self.scaling = 1 / math.sqrt(self.qk_nope_head_dim + self.qk_rope_head_dim)
if self.hf_config.rope_scaling:
mscale_all_dim = self.hf_config.rope_scaling.get(
"mscale_all_dim", False
if "Glm4MoeLiteForCausalLM" in self.hf_config.architectures:
self.scaling = 1
self.hf_config.rope_scaling = None
else:
# Handle rope scaling with yarn
self.scaling = 1 / math.sqrt(
self.qk_nope_head_dim + self.qk_rope_head_dim
)
scaling_factor = self.hf_config.rope_scaling["factor"]
mscale = yarn_get_mscale(scaling_factor, float(mscale_all_dim))
self.scaling = self.scaling * mscale * mscale
if self.hf_config.rope_scaling:
mscale_all_dim = self.hf_config.rope_scaling.get(
"mscale_all_dim", False
)
scaling_factor = self.hf_config.rope_scaling["factor"]
mscale = yarn_get_mscale(scaling_factor, float(mscale_all_dim))
self.scaling = self.scaling * mscale * mscale
elif "MiniCPM3ForCausalLM" in self.hf_config.architectures:
self.head_dim = 128