You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(models): compute Llama 4 chunked attention without a dense mask #3100
Llama 4's MoE (local) layers use chunked attention: a query attends causally only to keys in its own attention_chunk_size block (8192 for llama-4-scout). The prefill builds this as one dense create_chunked_attention_mask(seq_len, start_position, offset, chunk) array (src/models/llama4.rs around 1192 and 1266) and hands it to every MoE layer. After #3097, this mask is what sets Llama 4's peak:
The mask is block-diagonal and causal, so it can be computed without the dense array: run causal-mode SDPA per chunk over that chunk's keys only, or use a window equal to the chunk where that is equivalent.
Acceptance Criteria
Llama 4 MoE-layer prefill no longer builds a dense chunked mask. Each query chunk attends to its own block in causal mode, including a prefill piece that starts mid-chunk behind a cache. The array path stays for padded, batched or caller-masked cases.
Unit tests on tiny random weights compare the new path with the dense-mask path for offsets 0, mid-chunk and across a chunk boundary.
Record llama-4-scout peak, prefill and greedy output at single pass and 2048 chunks, main against branch. If outputs differ, report the teacher-forced logit trace.
Activity
perf(models): compute Llama 4 chunked attention without a dense mask
perf(models): keep the Llama 4 chunk mask where causal mode does not …
docs: record the Llama 4 chunked-attention measurements
fix(models): keep Llama 4 chunked decode inside the query's chunk
fix(models): keep Llama 4 chunked decode inside the query's chunk (#3117
perf(models): compute Llama 4 chunked attention without a dense mask (l…