Scale scores
×Scale similarities for the 192-feature head width and the extended context.
- in
- [B batch, 64 heads, 1 query, 1001 keys]
- out
- [B batch, 64 heads, 1 query, 1001 keys]
Explanation
Beyond , the factor is YaRN’s correction for a context extended 32-fold; the implementation applies it because the configuration sets the correction’s mscale_all_dim (modeling_deepseek.py 690–696).
Sources
In code* self.softmax_scale
Direct evidence
MLA owns a query down-projection, query RMSNorm and up-projection, a joint key–value down-projection that also emits the shared rotary key, a latent RMSNorm, a key–value up-projection and an output projection.
modeling_deepseek.py 662–688 ↗ · moonshotai/Kimi-K2-Instruct @ fd1984e2b7a3
Excerpt
self.q_a_proj = nn.Linear(
self.hidden_size, config.q_lora_rank, bias=config.attention_bias
)
self.q_a_layernorm = DeepseekV3RMSNorm(config.q_lora_rank)
self.q_b_proj = nn.Linear(
config.q_lora_rank, self.num_heads * self.q_head_dim, bias=False
)
self.kv_a_proj_with_mqa = nn.Linear(
self.hidden_size,
config.kv_lora_rank + config.qk_rope_head_dim,
bias=config.attention_bias,
)
self.kv_a_layernorm = DeepseekV3RMSNorm(config.kv_lora_rank)
self.kv_b_proj = nn.Linear(
config.kv_lora_rank,
self.num_heads
* (self.q_head_dim - self.qk_rope_head_dim + self.v_head_dim),
bias=False,
)
self.o_proj = nn.Linear(
self.num_heads * self.v_head_dim,
self.hidden_size,
bias=config.attention_bias,
)
self._init_rope()