Multi-head latent attention

Causal mask

×

supplied

Current and earlier key positions for every query.

shape
MM [1 query, 1001 keys]

The mask is still added (modeling_deepseek.py 820–826). A causal mask for the one new query, built by Transformers from the call at 1429–1434 and not pinned here, permits every cached position when nothing is padded, so it changes nothing.

Sources

In codeattention_mask

Open pinned code ↗

Contextual evidence

The eager path requires a mask of shape (batch, 1, query length, cached length) and adds it to the scores.

modeling_deepseek.py 820–826 ↗ · moonshotai/Kimi-K2.5 @ 4d01dfe0332d

Excerpt
        assert attention_mask is not None
        if attention_mask is not None:
            if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
                raise ValueError(
                    f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
                )
            attn_weights = attn_weights + attention_mask