[New model] Kimi K3 (#50000)
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com> Signed-off-by: Isotr0py <Isotr0py@outlook.com> Signed-off-by: Bugen Zhao <i@bugenzhao.com> Signed-off-by: Jee Jee Li <jeejeelee@inferact.ai> Signed-off-by: Yifan Qiao <yifanqiao@inferact.ai> Signed-off-by: Yongye Zhu <zyy1102000@gmail.com> Signed-off-by: wzhao18 <wzhao18.sz@gmail.com> Co-authored-by: Isotr0py <Isotr0py@outlook.com> Co-authored-by: Thien Tran <gau.nernst@yahoo.com.sg> Co-authored-by: Bugen Zhao <i@bugenzhao.com> Co-authored-by: Yongye Zhu <zyy1102000@gmail.com> Co-authored-by: Ziming Huang <zelda.huanghuang@gmail.com> Co-authored-by: Roger Wang <hey@rogerw.io> Co-authored-by: Isotr0py <mozf@inferact.ai> Co-authored-by: aoshen02 <aoshen02@users.noreply.github.com> Co-authored-by: Woosuk Kwon <woosuk@inferact.ai> Co-authored-by: Jee Jee Li <jeejeelee@inferact.ai> Co-authored-by: aoshen02 <aoshen@inferact.ai> Co-authored-by: Summer Yang <girasoleyang@gmail.com> Co-authored-by: Kevin H. Luu <khluu000@gmail.com> Co-authored-by: Bowen Wang <abmfy@icloud.com> Co-authored-by: gnovack <novackgm@gmail.com> Co-authored-by: Nick Hill <nickhill123@gmail.com> Co-authored-by: Yifan Qiao <yifanqiao@inferact.ai> Co-authored-by: xiaozhoupy <peiyuanzhou1994@gmail.com> Co-authored-by: Roy Wang <yasong.wang@inferact.ai> Co-authored-by: Jeff (Junze) Ma <93145857+majunze2001@users.noreply.github.com> Co-authored-by: Codex <codex@openai.com> Co-authored-by: Wei Zhao <51183510+wzhao18@users.noreply.github.com>
This commit is contained in:
co-authored by
Isotr0py
Thien Tran
Bugen Zhao
Yongye Zhu
Ziming Huang
Roger Wang
Isotr0py
aoshen02
Woosuk Kwon
Jee Jee Li
aoshen02
Summer Yang
Kevin H. Luu
Bowen Wang
gnovack
Nick Hill
Yifan Qiao
xiaozhoupy
Roy Wang
Jeff Ma
Codex
Wei Zhao
parent
0c64be8873
commit
aeeb36b1f1
@@ -339,6 +339,39 @@ class DeepseekV4ForCausalLMConfig(VerifyAndUpdateConfig):
|
||||
)
|
||||
|
||||
|
||||
class KimiK3ForConditionalGenerationConfig(VerifyAndUpdateConfig):
|
||||
"""Route MXFP4-checkpointed Kimi-K3 MoE experts to the MXFP4 interface.
|
||||
|
||||
Kimi-K3 ships its routed experts as compressed-tensors
|
||||
``mxfp4-pack-quantized`` (``quant_method="compressed-tensors"``), which
|
||||
lands them on ``CompressedTensorsW4A4Mxfp4MoEMethod`` and its narrow kernel
|
||||
selection. Rewriting ``quant_method`` to ``"mxfp4"`` selects ``Mxfp4Config``
|
||||
(hence ``Mxfp4MoEMethod``) with its full backend set, while any non-MXFP4
|
||||
checkpoint is left untouched. Covers both the main model and the MTP draft.
|
||||
|
||||
``model_arch_config.quantization_config`` is a separate dict, snapshotted in
|
||||
``ModelConfig.__init__`` before this hook runs, and it is what
|
||||
``_verify_quantization`` reads when resolving the quant method. Patch it
|
||||
alongside the hf configs so the rewrite lands before resolution; otherwise
|
||||
the main model still resolves to compressed-tensors.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def verify_and_update_model_config(model_config: "ModelConfig") -> None:
|
||||
for cfg in (
|
||||
model_config.hf_config,
|
||||
model_config.hf_text_config,
|
||||
model_config.model_arch_config,
|
||||
):
|
||||
quant_config = getattr(cfg, "quantization_config", None)
|
||||
if (
|
||||
isinstance(quant_config, dict)
|
||||
and quant_config.get("quant_method") == "compressed-tensors"
|
||||
and quant_config.get("format") == "mxfp4-pack-quantized"
|
||||
):
|
||||
quant_config["quant_method"] = "mxfp4"
|
||||
|
||||
|
||||
class GptOssForCausalLMConfig(VerifyAndUpdateConfig):
|
||||
@staticmethod
|
||||
def verify_and_update_model_config(model_config: "ModelConfig") -> None:
|
||||
@@ -884,6 +917,8 @@ MODELS_CONFIG_MAP: dict[str, type[VerifyAndUpdateConfig]] = {
|
||||
"JambaForSequenceClassification": JambaForSequenceClassificationConfig,
|
||||
"JinaForRanking": JinaForRankingConfig,
|
||||
"JinaVLForRanking": JinaVLForSequenceClassificationConfig,
|
||||
"KimiK3ForConditionalGeneration": KimiK3ForConditionalGenerationConfig,
|
||||
"KimiK3MTPModel": KimiK3ForConditionalGenerationConfig,
|
||||
"LlamaBidirectionalForSequenceClassification": LlamaBidirectionalConfig,
|
||||
"LlamaBidirectionalModel": LlamaBidirectionalConfig,
|
||||
"LlamaNemotronVLForSequenceClassification": LlamaNemotronVLConfig,
|
||||
|
||||
Reference in New Issue
Block a user