How Does Hybrid Attention Work in Open-Weight LLMs?
See which layers in Qwen3.8, Kimi K3.1 Pro, Gemma 4 and other open-weight LLMs can read early tokens. Read any model's config in three steps.
Say you paste a long source file into a language model and ask it to fix a bug in the last function. That function uses a type called User, and the code defining User sits near the top of the file, a few thousand tokens earlier. As the model processes the buggy function, it may need information from that earlier code to work out the fix.
If you learned attention from the original Transformer, that sounds easy. Every layer there can look back at every earlier token, so a token near the bug can access positions in the code defining User through any layer.
But only one of the nine open-weight models in this post, Granite 4.2 8B, still uses full attention in every layer. The other eight replace some or all of those layers with layers that read less. Some see only the last 128 to 1,024 tokens, some read only the positions an index picks out, and some never look back at individual tokens at all, because they carry a fixed-size summary forward instead. Gemma's and Qwen's model cards call this kind of mix hybrid attention.
So when the model processes a token near the bug, which layers let it look back at the code defining User? The answer changes from one model to the next, and even from one layer to the next, but each model writes it down in its config file.
By the end of this post, you'll be able to open one of those config files, tell which layers can reach a token from far back in the prompt, and see why model builders give up full attention in most of their layers, and what they risk when they do.
Full, sliding-window, sparse and linear attention side by side
Each kind of layer gives that token a different way to use information from the User definition, and each pays a different price in memory as the file gets longer.
| Layer type | What one layer reads | Memory as the file gets longer | Models in this post with at least one such layer |
|---|---|---|---|
| Full attention, also called softmax attention | Every earlier token | The key-value (KV) cache grows by one entry per token | Qwen3.8-27B, Gemma 4 12B IT, Granite 4.2 8B, LFM3-1.7B, Nemotron Bolt |
| Sliding-window attention | The most recent tokens, 1,024 of them in Gemma 4 12B IT | Stops growing at the window size | Gemma 4 12B IT, DeepSeek V4.1 Flash 1017, LFM3-1.7B |
| Sparse attention | The tokens or blocks its index picks, up to 2,048 tokens in Kimi K3.1 Pro | Keeps entries covering every earlier token, so the index can score them | Qwen3.8-Flash-Next, Kimi K3.1 Pro, MiniMax M3.1 Flash, DeepSeek V4.1 Flash 1017 |
| Running state (Gated DeltaNet, Kimi Delta Attention, Mamba-2) | A state it has updated at every token | Stays the same size | Qwen3.8-27B, Qwen3.8-Flash-Next, Kimi K3.1 Pro, Nemotron Bolt |
| Short convolution | Its own token and the six before it, in LFM3-1.7B | Stays the same size | LFM3-1.7B |
The first and fourth rows sit at opposite ends. A full-attention layer can access the earlier positions in the User definition, but it pays for that with a KV cache that grows with every token in the file. A running-state layer needs the same memory at token 10 as at token 10,000, but whatever it kept from the User definition has been squeezed into that fixed-size state. A systematic study of hybrids found that this is where recall suffers.
In its Figure 2, recall drops for most of the variants as full-attention layers get rarer, while the language-modeling score changes far less.
According to that same study, this trade-off is what led to hybrid models, which mix rows instead of picking one. Where the model puts those layers tells us when a token near the bug can access the earlier User definition. We can follow that layout in the config in three steps.
Read a config in three steps
We'll follow a token near the bug through Qwen3.8-27B and Kimi K3.1 Pro, asking which layers let it access positions in the earlier User definition. Both models change at the same layer. You can follow along with their configs open on Hugging Face.
Step 1. Find the list of layer types
Look for a list with one entry per layer. In Qwen3.8-27B's config, it's layer_types under text_config, and the first four entries read linear_attention, linear_attention, linear_attention and full_attention. Kimi K3.1 Pro's config splits the same information in two. Its kda_layers list holds the Kimi Delta Attention layers, and its dsa_layers list holds the sparse ones, starting at 4.
Step 2. Match each entry to a kind of layer
Both configs tell us that something changes at layer four. What we still want to know is whether that change lets the token near the bug look back at the code defining User. The model cards help us make sense of the names we just found.
Qwen's model card names its linear_attention layers Gated DeltaNet and writes the whole layout as 16 repeats of three Gated DeltaNet layers and one gated attention layer, the 3:1 pattern you see in the config. Kimi's model card calls its sparse layers gated DeepSeek Sparse Attention, and the config's index_topk of 2048 tells you how many earlier tokens each of them reads.
So in both models, layers 1 to 3 keep a running state, Gated DeltaNet in Qwen and Kimi Delta Attention in Kimi. As the tokens in the User definition pass through, each of those layers writes them into its state, and by the time the model reaches the bug, whatever is left of them is mixed in with everything written since.
Step 3. Find the first layer that can access the earlier code
For the token near the bug, the first direct path back to the User definition appears at layer four in both models. Qwen's full attention scores every earlier position, including those in the code defining User. Kimi's indexer also scores earlier positions, and its sparse attention reads only the 2,048 with the highest scores. Our file runs to a few thousand tokens, so the index has to choose. The token near the bug can read from the User definition at this layer if the relevant positions are selected.
Kimi K3 would have answered like Qwen. Its config lists full attention at the same 24 positions where K3.1 Pro has sparse layers, and the K3.1 Pro model card says those layers were replaced "for more efficient long-context modeling". Qwen3.8-Flash-Next made the same trade. It shares the 27B model's first three layers, but its layer four is Qwen Sparse Attention, which Qwen's architecture report says replaced full attention during continued pretraining. So two checkpoints with the Qwen3.8 name give different answers at the same layer.
The same report says why one layer in four was full attention to begin with. It keeps "the direct token-level retrieval that no finite-state memory reproduces exactly", which is the guarantee the sparse layers now trade for speed.
The report's Figure 1 draws Flash-Next's stack, three Gated DeltaNet layers and then one Qwen Sparse Attention layer, repeated.
If you pick layer 3 and then layer 4 in either grid, you can see how the selected layer reads earlier positions while the model processes a token near the bug. The strip labelled 'definition' marks the earlier code defining User. The previous and next buttons let you follow the stack one layer at a time, and either menu lets you choose another model.
Try it on nine open-weight models
The same three steps work on every checkpoint below. Each one is a released model with downloadable weights.
The field names change from lab to lab. Gemma 4 and LFM3 also use layer_types, Nemotron Bolt calls its list layers_block_type, and DeepSeek V4.1 Flash 1017 keeps it in compress_ratios, where a 0 marks a layer that has only the sliding window. Granite 4.2 8B has no list at all, because every layer is the same.
The 'First direct read of the User definition' column shows when a token near the bug can first look directly back at that earlier code in a single layer. For rows marked 'if picked', the relevant positions must be selected by the indexer. Nemotron Bolt lists its Mamba-2, mixture-of-experts feed-forward and attention components as separate blocks, giving its language stack 88 blocks in total.
If you pick a kind of block, its positions are highlighted across the layouts. You can then choose a model to see its layers beside another model in the comparison below the list.
| Model checkpoint | Language blocks | Layer layout | First direct read of the User definition | Sources |
|---|---|---|---|---|
| Qwen3.8-27B | 64 | Three Gated DeltaNet layers followed by one gated full-attention layer, repeated 16 times. | Layer 4 | Model card, config |
| Qwen3.8-Flash-Next | 48 | Three Gated DeltaNet layers followed by one Qwen Sparse Attention layer, repeated 12 times. | Layer 4, if picked | Model card, config |
| Kimi K3.1 Pro | 93 | Three Kimi Delta Attention layers followed by one gated DeepSeek Sparse Attention layer, repeated 23 times, then one final gated sparse layer. | Layer 4, if picked | Model card, config |
| MiniMax M3.1 Flash | 60 | MiniMax Sparse Attention in every layer. | Layer 1, if picked | Model card, config |
| DeepSeek V4.1 Flash 1017 | 40 | Layers 1 and 2 use sliding-window attention. Layers 3 to 40 keep that window and add a sparse read from farther back. | Layer 3, if the compressed entry is picked | Checkpoint config, architecture report |
| Gemma 4 12B IT | 48 | Five sliding-window layers followed by one full-attention layer, repeated eight times. | Layer 6 | Model card, config |
| Granite 4.2 8B | 40 | Full causal grouped-query attention in all 40 layers. | Layer 1 | Architecture overview, config |
| LFM3-1.7B | 24 | 13 gated short-convolution layers interleaved with five sliding-window and six full-attention layers. | Layer 3 | Architecture overview, config |
| Nemotron 3.5 Bolt 74B-A9B BF16 | 88 | 40 Mamba-2 blocks, 40 mixture-of-experts feed-forward blocks and eight full-attention blocks. | Block 8 | Model card, config |
For the token near the bug, Granite 4.2 8B provides access to the User definition from layer 1, because all 40 layers use full attention. In LFM3-1.7B, that direct access first appears at layer 3. Its first two layers are gated short convolutions, each mixing the current token with only the six before it. Gemma 4 12B IT reaches back to the earlier code at layer 6. Its first five layers have a 1,024-token window, so the User definition a few thousand tokens back falls outside their direct reach.
Information from farther back can still arrive indirectly. In Figure 1 of the Mistral 7B paper, each layer lets information move one more window forward, up to k times the window after k layers. What the window takes away is the direct read.
Nemotron Bolt waits longest. Its first seven blocks alternate between Mamba-2, which carries a running state much like Gated DeltaNet, and feed-forward blocks, which work on each position on its own. For the token near the bug, block 8 is the first with direct access to positions in the User definition.
For the sparse layers, access to the User definition also depends on which positions the indexer selects. Flash-Next and Kimi first make that selection at layer four. MiniMax M3.1 Flash picks from layer 1, choosing up to 16 blocks of 128 tokens and always keeping the block the current token sits in. DeepSeek V4.1 Flash 1017 keeps a 128-token window in every layer and adds its sparse read from layer 3.
MiniMax's paper draws that selection in its Figure 1. An index branch scores the earlier blocks, and the main branch attends only to the ones it picks.
Check what you can do
-
The
Usertype is defined 3,000 tokens before the bug. In Gemma 4 12B IT, the first five layers each have a 1,024-token window, and the sixth uses full attention. At which layer can a token near the bug first look directly at the tokens that defineUser?[!faq]- Show answer
Layer 6. Information from the definition can travel part of the way through one window and farther through the next. Layer 6 is the first where the token near the bug can look all the way back to those earlier positions in a single step. Gemma config, Mistral 7B, Figure 1 -
Kimi K3 and Kimi K3.1 Pro both have a special layer at position 4. Which of the two gives the token near the bug access to every position in the
Userdefinition there, and why?[!faq]- Show answer
Kimi K3. Its layer 4 is full attention, while K3.1 Pro's reads only the 2,048 tokens its index picks. Kimi K3 config, Kimi K3.1 Pro model card -
How much does a running-state layer's state grow between token 10 and token 10,000?
[!faq]- Show answer
It doesn't grow. The state has a fixed size, which is also why details from theUserdefinition can get lost in it. Wang et al., 2025 -
Nemotron Bolt's
layers_block_typestarts withmamba,moe,mamba,moe,mamba,moe,mambaandattention. Which block first lets the token near the bug access theUserdefinition, and why don't themoeblocks count?[!faq]- Show answer
Block 8. Themoeblocks are feed-forward blocks, which work on each position on its own, so they never look back at earlier tokens. Nemotron Bolt config, Vaswani et al., 2017, Section 3.3
Continue from the part that slowed you down
If one row of the table still feels fuzzy, pick the part that slowed you down and continue in the course. Then come back to a config and run the three steps again.
| If you got stuck on | Continue with |
|---|---|
| How full attention scores every earlier token | Matching Queries with Keys |
| Why a token can only read earlier positions | Preventing Future Leakage with Masking |
| Why the KV cache grows with every token | Sharing Keys and Values |
| What a running state keeps and what it loses | The Compression Bottleneck |
| How a delta-rule layer updates its state | DeltaNet |
| Kimi Delta Attention and Kimi's 3:1 hybrid | Kimi Linear and Kimi Delta Attention |
| Nemotron's Mamba-2 blocks | Mamba-2 |
| Nemotron's mixture-of-experts blocks | Mixture of Experts |
Sliding-window and sparse attention aren't in the course yet. Until they are, Section 2 of the Mistral 7B paper shows how a window keeps its cache from growing, and Section 2.1 of the DeepSeek-V3.2 paper shows how an index picks the tokens a layer reads.
Try another model
Open the config of an open-weight model you already use and run the three steps on it. If you can't find a list of layer types, check whether every layer is the same, the way it is in Granite 4.2 8B.