Raw textto [B, T, 163840]
Specification
- Attention
- 64 heads; keys 128 + 64 rotary features, values 128; latents: query 1,536, key–value 512config.json 59, 76, 92–94, 165
- Feed-forward
- 384 routed + 1 shared experts; 8 routed chosen per token; 2,048 hidden features eachThe first layer has a dense SwiGLU of 18,432 hidden features instead.config.json 56, 69–73, 79
- Context
- 262,144 positions (
max_position_embeddings)config.json 66
Parameters1,026,408,232,448
1,026,408,232,448 parameters in Kimi K2.5
| Component | Calculation | Parameters |
|---|---|---|
| Token embedding | 163,840 × 7,168 | 1,174,405,120 |
| Layers | 1,024,059,415,040 | |
| Final RMSNorm | 7,168 | |
| Vocabulary projection | 7,168 × 163,840 | 1,174,405,120 |
| Model total | 1,026,408,232,448 | |
Counted from the pinned configuration and code, with each packed 4-bit value as one weight. The total matches the checkpoint’s tensors, apart from the 4-bit groups’ scales and stored shapes, the vision tower and the projector.
Sources
Direct evidence
The language model’s configuration (text_config): the DeepSeek-V3 architecture, width, 61 layers of which 1 dense, 64 heads, 384 routed experts and one shared, routing (sigmoid scores, one expert group, top-8, route scale 2.827), MLA ranks and head widths, vocabulary, 262,144 positions and YaRN RoPE (factor 64 over 4,096 original positions, β_fast 32, β_slow 1).
config.json 17–167 ↗ · moonshotai/Kimi-K2.5 @ 4d01dfe0332d
Excerpt
"text_config": {
"_name_or_path": "",
"add_cross_attention": false,
"architectures": [
"DeepseekV3ForCausalLM"
],
"attention_bias": false,
"attention_dropout": 0.0,
"auto_map": {
"AutoConfig": "configuration_deepseek.DeepseekV3Config",
"AutoModel": "modeling_deepseek.DeepseekV3Model",
"AutoModelForCausalLM": "modeling_deepseek.DeepseekV3ForCausalLM"
},
"aux_loss_alpha": 0.001,
"bad_words_ids": null,
"begin_suppress_tokens": null,
"bos_token_id": 163584,
"chunk_size_feed_forward": 0,
"cross_attention_hidden_size": null,
"decoder_start_token_id": null,
"diversity_penalty": 0.0,
"do_sample": false,
"dtype": "bfloat16",
"early_stopping": false,
"encoder_no_repeat_ngram_size": 0,
"eos_token_id": 163585,
"ep_size": 1,
"exponential_decay_length_penalty": null,
"finetuning_task": null,
"first_k_dense_replace": 1,
"forced_bos_token_id": null,
"forced_eos_token_id": null,
"hidden_act": "silu",
"hidden_size": 7168,
"id2label": {
"0": "LABEL_0",
"1": "LABEL_1"
},
"initializer_range": 0.02,
"intermediate_size": 18432,
"is_decoder": false,
"is_encoder_decoder": false,
"kv_lora_rank": 512,
"label2id": {
"LABEL_0": 0,
"LABEL_1": 1
},
"length_penalty": 1.0,
"max_length": 20,
"max_position_embeddings": 262144,
"min_length": 0,
"model_type": "kimi_k2",
"moe_intermediate_size": 2048,
"moe_layer_freq": 1,
"n_group": 1,
"n_routed_experts": 384,
"n_shared_experts": 1,
"no_repeat_ngram_size": 0,
"norm_topk_prob": true,
"num_attention_heads": 64,
"num_beam_groups": 1,
"num_beams": 1,
"num_experts_per_tok": 8,
"num_hidden_layers": 61,
"num_key_value_heads": 64,
"num_nextn_predict_layers": 0,
"num_return_sequences": 1,
"output_attentions": false,
"output_hidden_states": false,
"output_scores": false,
"pad_token_id": 163839,
"prefix": null,
"pretraining_tp": 1,
"problem_type": null,
"pruned_heads": {},
"q_lora_rank": 1536,
"qk_nope_head_dim": 128,
"qk_rope_head_dim": 64,
"quantization_config": {
"config_groups": {
"group_0": {
"input_activations": null,
"output_activations": null,
"targets": [
"Linear"
],
"weights": {
"actorder": null,
"block_structure": null,
"dynamic": false,
"group_size": 32,
"num_bits": 4,
"observer": "minmax",
"observer_kwargs": {},
"strategy": "group",
"symmetric": true,
"type": "int"
}
}
},
"format": "pack-quantized",
"ignore": [
"re:.*self_attn.*",
"re:.*shared_experts.*",
"re:.*mlp\\.(gate|up|gate_up|down)_proj.*",
"re:.*lm_head.*",
"re:vision_tower.*",
"re:mm_projector.*"
],
"kv_cache_scheme": null,
"quant_method": "compressed-tensors",
"quantization_status": "compressed"
},
"remove_invalid_values": false,
"repetition_penalty": 1.0,
"return_dict": true,
"return_dict_in_generate": false,
"rms_norm_eps": 1e-05,
"rope_scaling": {
"beta_fast": 32.0,
"beta_slow": 1.0,
"factor": 64.0,
"mscale": 1.0,
"mscale_all_dim": 1.0,
"original_max_position_embeddings": 4096,
"type": "yarn"
},
"rope_theta": 50000.0,
"routed_scaling_factor": 2.827,
"scoring_func": "sigmoid",
"sep_token_id": null,
"seq_aux": true,
"suppress_tokens": null,
"task_specific_params": null,
"temperature": 1.0,
"tf_legacy_loss": false,
"tie_encoder_decoder": false,
"tie_word_embeddings": false,
"tokenizer_class": null,
"top_k": 50,
"top_p": 1.0,
"topk_group": 1,
"topk_method": "noaux_tc",
"torchscript": false,
"transformers_version": "4.56.2",
"typical_p": 1.0,
"use_bfloat16": false,
"use_cache": true,
"v_head_dim": 128,
"vocab_size": 163840
},YaRN RoPE as the implementation builds it: the YaRN class and its defaults, the softmax scale (1/√192 times the square of the YaRN attention correction for mscale_all_dim), and the choice of YaRN whenever the configuration’s rope_scaling type is yarn.
modeling_deepseek.py 282–744 ↗ · moonshotai/Kimi-K2.5 @ 4d01dfe0332d
Excerpt
class DeepseekV3YarnRotaryEmbedding(DeepseekV3RotaryEmbedding):
def __init__(
self,
dim,
max_position_embeddings=2048,
base=10000,
device=None,
scaling_factor=1.0,
original_max_position_embeddings=4096,
beta_fast=32,
beta_slow=1,
mscale=1,
mscale_all_dim=0,
):
self.scaling_factor = scaling_factor
self.original_max_position_embeddings = original_max_position_embeddings
self.beta_fast = beta_fast
self.beta_slow = beta_slow
self.mscale = mscale
self.mscale_all_dim = mscale_all_dim
super().__init__(dim, max_position_embeddings, base, device)… lines 304–692 omitted …
self.softmax_scale = self.q_head_dim**(-0.5)
if self.config.rope_scaling is not None:
mscale_all_dim = self.config.rope_scaling.get("mscale_all_dim", 0)
scaling_factor = self.config.rope_scaling["factor"]
if mscale_all_dim:
mscale = yarn_get_mscale(scaling_factor, mscale_all_dim)
self.softmax_scale = self.softmax_scale * mscale * mscale… lines 700–700 omitted …
def _init_rope(self):
if self.config.rope_scaling is None:
self.rotary_emb = DeepseekV3RotaryEmbedding(
self.qk_rope_head_dim,
max_position_embeddings=self.max_position_embeddings,
base=self.rope_theta,
)
else:
scaling_type = self.config.rope_scaling["type"]
scaling_factor = self.config.rope_scaling["factor"]
if scaling_type == "linear":
self.rotary_emb = DeepseekV3LinearScalingRotaryEmbedding(
self.qk_rope_head_dim,
max_position_embeddings=self.max_position_embeddings,
scaling_factor=scaling_factor,
base=self.rope_theta,
)
elif scaling_type == "dynamic":
self.rotary_emb = DeepseekV3DynamicNTKScalingRotaryEmbedding(
self.qk_rope_head_dim,
max_position_embeddings=self.max_position_embeddings,
scaling_factor=scaling_factor,
base=self.rope_theta,
)
elif scaling_type == "yarn":
kwargs = {
key: self.config.rope_scaling[key]
for key in [
"original_max_position_embeddings",
"beta_fast",
"beta_slow",
"mscale",
"mscale_all_dim",
] if key in self.config.rope_scaling
}
self.rotary_emb = DeepseekV3YarnRotaryEmbedding(
self.qk_rope_head_dim,
max_position_embeddings=self.max_position_embeddings,
scaling_factor=scaling_factor,
base=self.rope_theta,
**kwargs,
)
else:
raise ValueError(f"Unknown RoPE scaling type {scaling_type}")The model embeds tokens (when handed IDs), numbers positions from the cached length, builds a 4D causal mask, applies all layers, normalizes and projects to vocabulary logits with an untied head, computing every position’s logits in float32.
modeling_deepseek.py 1344–1585 ↗ · moonshotai/Kimi-K2.5 @ 4d01dfe0332d
Excerpt
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size,
self.padding_idx)
self.layers = nn.ModuleList([
DeepseekV3DecoderLayer(config, layer_idx)
for layer_idx in range(config.num_hidden_layers)
])
self._use_flash_attention_2 = config._attn_implementation == "flash_attention_2"
self.norm = DeepseekV3RMSNorm(config.hidden_size,
eps=config.rms_norm_eps)… lines 1353–1399 omitted …
past_key_values_length = 0
if use_cache:
use_legacy_cache = not isinstance(past_key_values, Cache)
if use_legacy_cache:
past_key_values = DynamicCache.from_legacy_cache(
past_key_values)
past_key_values_length = get_usable_length(past_key_values,
seq_length)
if position_ids is None:
device = input_ids.device if input_ids is not None else inputs_embeds.device
position_ids = torch.arange(
past_key_values_length,
seq_length + past_key_values_length,
dtype=torch.long,
device=device,
)
position_ids = position_ids.unsqueeze(0)… lines 1418–1418 omitted …
if inputs_embeds is None:
inputs_embeds = self.embed_tokens(input_ids)… lines 1421–1421 omitted …
if self._use_flash_attention_2:
# 2d mask is passed through the layers
attention_mask = (attention_mask if
(attention_mask is not None
and 0 in attention_mask) else None)
else:
# 4d mask is passed through the layers
attention_mask = _prepare_4d_causal_attention_mask(
attention_mask,
(batch_size, seq_length),
inputs_embeds,
past_key_values_length,
)… lines 1435–1495 omitted …
self.lm_head = nn.Linear(config.hidden_size,
config.vocab_size,
bias=False)… lines 1499–1582 omitted …
hidden_states = outputs[0]
logits = self.lm_head(hidden_states)
logits = logits.float()