Causal mask
×supplied
Current and earlier key positions for every query.
- shape
- [1 query, 1001 keys]
The mask is still added (modeling_deepseek.py 871–877). A causal mask for the one new query, built by Transformers from the call at 1498–1503 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 871–877 ↗ · deepseek-ai/DeepSeek-V2 @ 4461458f186c
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