Last updated: 2026-11-17

Inference Runtime

Attention Window

All API Sections

Causal sliding-window bounds, independent of a GPU API.

Share model-layer selection and causal bounds between single-query decode and batched prefill, so every query sees the same intended token history.

2 exports 0 methods src/gpu/attention_window.zig

2 exports shown

function

forLayer

#
pub fn forLayer(config: ModelConfig, layer_head_dim: u32) u32

Gemma 4's sliding layers use the smaller head width and SWA RoPE base.

Global layers retain the complete prefix even though the model has a window.

src/gpu/attention_window.zig:11

function

start

#
pub fn start(seq_len: u32, window_size: u32) u32

`seq_len` includes the query token.

The pinned reference STANDARD mask excludes a key when query_position - key_position >= window_size.

src/gpu/attention_window.zig:20