Causal mask
×supplied
Current and earlier key positions for every query.
- shape
- [1 query, 1001 keys]
The mask is still added (modeling_deepseek.py 825–831). A causal mask for the one new query, built by Transformers from the call at 1452–1457 and not pinned here, permits every cached position when nothing is padded, so it changes nothing.
Sources
In codeattention_mask
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 825–831 ↗ · moonshotai/Kimi-K2-Instruct @ fd1984e2b7a3
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