Files
vLLM/vllm/transformers_utils/configs/k3_dspark.py
T
+13 aeeb36b1f1 [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>
2026-07-30 03:49:58 -07:00

78 lines
2.7 KiB
Python

# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from transformers import DeepseekV2Config
class K3DSparkConfig(DeepseekV2Config):
"""Configuration for a dense MLA DSpark draft model."""
model_type = "k3_dspark"
has_no_defaults_at_init = True
def __init__(
self,
mla_use_nope: bool = False,
mla_use_output_gate: bool = False,
mla_use_qk_norm: bool = False,
rope_theta: float = 50000.0,
**kwargs,
) -> None:
# DeepseekV2Config defaults to a MoE topology. Zero these fields so
# generic vLLM config logic also recognizes this draft as dense.
kwargs.setdefault("n_routed_experts", 0)
kwargs.setdefault("n_shared_experts", 0)
kwargs.setdefault("num_experts_per_tok", 0)
rope_parameters = kwargs.get("rope_parameters")
if rope_parameters is None:
kwargs["rope_parameters"] = {
"rope_type": "default",
"rope_theta": rope_theta,
}
else:
rope_parameters = dict(rope_parameters)
rope_parameters.setdefault("rope_type", "default")
rope_parameters.setdefault("rope_theta", rope_theta)
kwargs["rope_parameters"] = rope_parameters
super().__init__(**kwargs)
self.mla_use_nope = mla_use_nope
self.mla_use_output_gate = mla_use_output_gate
self.mla_use_qk_norm = mla_use_qk_norm
unsupported = [
name
for name in (
"mla_use_nope",
"mla_use_output_gate",
"mla_use_qk_norm",
"dspark_bonus_anchor",
)
if getattr(self, name, False)
]
if self.q_lora_rank is None:
unsupported.append("q_lora_rank=None")
if unsupported:
raise ValueError(
"MLA DSpark does not support " + ", ".join(unsupported) + "."
)
self.draft_vocab_size = (
getattr(self, "draft_vocab_size", None) or self.vocab_size
)
if self.draft_vocab_size != self.vocab_size:
raise ValueError(
"MLA DSpark requires draft_vocab_size to equal vocab_size when "
"sharing the target embedding and LM head."
)
target_layer_ids = getattr(self, "target_layer_ids", None)
if not target_layer_ids or getattr(self, "num_target_layers", None) != len(
target_layer_ids
):
raise ValueError(
"MLA DSpark requires non-empty target_layer_ids and a matching "
"num_target_layers."
)