Causal attention

Scale scores

×

Scale similarities for the 192-feature head width and the extended context.

S′=S⋅m2192{\htmlData{light=scaled scale}{S'}}={\htmlData{light=similarities similarity}{S}}\cdot\frac{m^2}{\sqrt{192}}
m=1+0.1ln⁡64m=1+0.1\ln 64
in
SS [B batch, 64 heads, T queries, T keys]
out
S′S' [B batch, 64 heads, T queries, T keys]
Explanation

Beyond 1/1921/\sqrt{192}, the factor m2≈2.005m^2\approx2.005 is YaRN’s correction for a context extended 64-fold; the implementation applies it because the configuration sets the correction’s mscale_all_dim (modeling_deepseek.py 693–699).

Sources

In code* self.softmax_scale

Open pinned code ↗

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 665–691 ↗ · moonshotai/Kimi-K2.5 @ 4d01dfe0332d

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()