inference/research
verifiedmedium · 0.80updated 2026-10-04

Gemma 4 12B (unified multimodal)

dense 11.96B

Fields

id
models/gemma-4-12b
Family
gemma
Vendor
Google
Release year
2026
Architecture
dense
Params (B)
11.96
Active params (B)
11.96
Hidden size
3,840
Layers
48
KV heads
8
Head dim
256
GQA ratio
2
Max context
262,144
Context scaling
per-layer-type rope (full_attention theta 1e6 proportional / sliding_attention theta 1e4 default)
Context scaling method
native
Activation
gelu
Attention variant
GQA + sliding-window/global hybrid with separate global head geometry (global_head_dim 512, num_global_key_value_heads 1)
Attention layer indices
511172329354147
Layer types
sliding_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionfull_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionfull_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionfull_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionfull_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionfull_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionfull_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionfull_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionsliding_attentionfull_attention
KV cache (bytes/token)
344,064
FLOPs per active token
23,920,000,000
Open weights
yes
License
Gemma Terms of Use
notes
KV GEOMETRY, NOW DERIVED (was null). Gemma 4 uses TWO head geometries in one stack, so the single-formula field is the sum of two terms, both explicit in config: sliding layers = num_layers_sliding x num_key_value_heads x head_dim x 2 x bytes; full layers = num_layers_full x num_global_key_value_heads x global_head_dim x 2 x bytes. DERIVATION for Gemma 4 12B: 40 sliding layers x 8 kv_heads x 256 head_dim x 2 (K+V) x 2 bytes (bf16) = 327,680 B PLUS 8 full-attention layers x 1 global kv_heads x 512 global_head_dim x 2 x 2 = 16,384 B, TOTAL 344,064 B/token (336.0 KiB). layer_types enumerates the split explicitly (40 sliding_attention + 8 full_attention, full at 0-based indices 5,11,17,23,29,35,41,47). attention_k_eq_v is true and num_kv_shared_layers is 0, so no layer shares cache with a neighbour. PARAMS: 11.96B is the safetensors count across text plus the unified vision and audio towers. ARCHITECTURE FLAG: model_type is gemma4_unified, not gemma4. Google's doc says the unified 12B is an ENCODER-FREE model for multimodal tasks, replacing the vision and audio encoders with direct linear projections of the input. There is therefore no ViT whose FLOPs dominate prefill for this model, which is the opposite of the usual VLM story and is exactly why it is worth its own record. head_dim 256 with 8 KV heads on sliding layers versus global_head_dim 512 with 1 global KV head, across 8 global layers of 48. Audio is native on the 12B per Google's doc, which adds an audio-tower prefill cost not present in the text-and-image models. Ships with an MTP draft model. SERVICEABILITY JOIN (added 2026-10-03; the architecture x engine matrix this record was missing, with a citation per cell in docs/13-model-compatibility.md): FAMILY=sliding-window. REQUIRED KERNEL CLASS: a local/windowed attention decode kernel plus per-layer-type cache management. The kernel requirement is not cosmetic: flop/sliding-window-hybrid-attention records that a local layer's decode cost is constant in context (it reads exactly w KV entries) so its arithmetic intensity stays at ~1 flop/byte forever, while the global layers' bytes still grow linearly - the two layer classes have opposite scaling and one kernel must serve both. SUPPORTED BY (cited): vLLM lists sliding attention inside its fallback envelope - 'Attention types: full attention and/or sliding attention' - but ALSO has native rows for the specific SWA architectures: GptOssForCausalLM, Gemma3ForCausalLM, Gemma4ForCausalLM, Olmo3ForCausalLM, GraniteMoeSWAForCausalLM, GraniteSWAForCausalLM [[mdl2-vllm-supported-models-2026-10]]. SGLang's generative table names GPT-OSS as 'hybrid sliding-window-attention MoE model ... with per-layer-type RoPE (YARN on full-attention layers, default on sliding-attention layers) and a softplus per-head attention gate', and lists granite-swash SWA models [[mdl2-sglang-generative-models]]. llama.cpp exposes SWA as first-class KV keys rather than a flag: %%s.attention.sliding_window and %%s.attention.sliding_window_pattern exist as distinct keys per architecture class, alongside SWA-specific width keys, which is direct evidence that SWA changes the cache layout rather than adding an attention flag [[mdl2-llamacpp-arch-class-registry]]. THE PER-CELL CONSEQUENCE: an engine WITHOUT local-attention support does not fail, it silently allocates a full-context cache for every layer. docs/13-model-compatibility.md tabulates this as the KV overpay table; for this model the naive figure in kv_cache_bytes_per_token is the worst case and the effective figure is what the windowed layers actually hold. TWO HARD GATES THAT ARE NOT ABOUT WINDOW SIZE. (1) TensorRT-LLM publishes a per-architecture 'Sliding Window Attention' column and it is NOT uniformly Yes: Yes for DeepseekV4ForCausalLM, Gemma4ForConditionalGeneration, Gemma4UnifiedForConditionalGeneration and Step3p7ForConditionalGeneration, and explicitly No for Qwen3NextForCausalLM, while the DeepSeek-V3/V3.2/GLM/GPT-OSS/Llama-4/Qwen3.5/Kimi-K3/Nemotron-H rows read N/A [[mdl2-trtllm-supported-models]]. (2) On B200 with vLLM 0.23.1rc1.dev843 + flashinfer-python 0.6.14, a 50-of-60-layer SWA Gemma-4 checkpoint with --kv-cache-dtype fp8_e4m3 and MTP spec-decode (k=7) produces fluent output containing sporadic wrong tokens and short repetition loops once seq_len passes the 1024-token window, because flashinfer's trtllm spec-as-decode kernel mis-computes sliding-window attention for BF16-Q + FP8-KV at certain seq_len/page alignments and vLLM's scale bookkeeping double-applies k/v scales - gotcha-flashinfer-bf16q-fp8kv-spec-decode-corrupts-swa, severity BLOCKER. FP8-Q + spec is clean; BF16-Q + no spec is clean; either drop quantized KV, drop spec decode, or drop the disable_flashinfer_q_quantization flag. This is the cleanest statement in the repo that quantized KV and speculative decoding are not independently safe on an SWA model. (3) FlashInfer also rejects large head sizes at engine init, which is a separate SM120 gap from the page-block one: head_size not supported for gemma-4-31b-it's head_dim 256 / global_head_dim 512 on RTX PRO 6000 [[flashinfer-rejects-large-head-dim]]. (4) On Hopper, vLLM 0.30.0's vllm_flash_attn silently ignores num_splits on SM90, costing 48% per-token decode at batch 1 for Gemma-4 26B-A4B-it global layers (1 query token, 2 KV heads, 2 of an H100's 132 SMs with work), with TRITON_ATTN recovering ~70% [[fa4-num-splits-ignored-sm90]]. (5) vLLM's own scheduler granularity interacts with SWA groups: issue #53786 asks for fine-grained prefix hits for sliding-window groups, and hybrid reconciliation already caps the combined hit at the shorter boundary [[eagle-prefix-cache-last-block-drop]]. (6) On Apple Silicon the class is a cache-CLASS problem, not a kernel problem: mlx-lm's sliding-window layers use RotatingKVCache, which had no quantized implementation, so --kv-bits passes a hasattr presence check and raises NotImplementedError on the first request instead of at startup; the fix (PR 1584) adds RotatingQuantizedKVCache, and the commonly-recommended monkeypatch silently gives up the max_kv_size window bound and yields an unbounded cache [[mlx-kv-bits-crashes-on-first-request-for-hybrid-attention]] [[mdl2-mlxlm-pr1584-rotating-quantized-kv]]. KV OVERPAY NOT COMPUTABLE FROM THIS RECORD: kv_cache_bytes_per_token is null here, and the reason is structural. This checkpoint has SEPARATE GLOBAL HEAD GEOMETRY (global_head_dim 512 with num_global_key_value_heads 1, against head_dim 256 with 8 local KV heads), so the local and global layers have different per-token widths and the naive num_layers x num_kv_heads x head_dim x 2 x 2 formula does not have a single answer. The overpay factor for it is bounded by the local:global layer ratio but the byte total is not derivable from the fields this schema carries. Flagged as an unknown in docs/13-model-compatibility.md rather than estimated. CONTEXT_SCALING_METHOD (native): SCHEME RECLASSIFIED (2026-10-04): was 'per-layer-type rope' read as a scaling method. config carries rope_parameters PER LAYER TYPE (full_attention: rope_theta 1e6 / rope_type proportional; sliding_attention: rope_theta 1e4 / rope_type default) and NO factor. That is per-layer RoPE geometry, not context extension: max_position_embeddings 262144 is reached with no scaling block. LAYER LAYOUT (gemma-4-12b): layer_types read verbatim from config, one entry per layer; attention_layer_indices are the 0-based positions of the full-attention entries.

Notes

KV GEOMETRY, NOW DERIVED (was null). Gemma 4 uses TWO head geometries in one stack, so the single-formula field is the sum of two terms, both explicit in config: sliding layers = num_layers_sliding x num_key_value_heads x head_dim x 2 x bytes; full layers = num_layers_full x num_global_key_value_heads x global_head_dim x 2 x bytes. DERIVATION for Gemma 4 12B: 40 sliding layers x 8 kv_heads x 256 head_dim x 2 (K+V) x 2 bytes (bf16) = 327,680 B PLUS 8 full-attention layers x 1 global kv_heads x 512 global_head_dim x 2 x 2 = 16,384 B, TOTAL 344,064 B/token (336.0 KiB). layer_types enumerates the split explicitly (40 sliding_attention + 8 full_attention, full at 0-based indices 5,11,17,23,29,35,41,47). attention_k_eq_v is true and num_kv_shared_layers is 0, so no layer shares cache with a neighbour. PARAMS: 11.96B is the safetensors count across text plus the unified vision and audio towers. ARCHITECTURE FLAG: model_type is gemma4_unified, not gemma4. Google's doc says the unified 12B is an ENCODER-FREE model for multimodal tasks, replacing the vision and audio encoders with direct linear projections of the input. There is therefore no ViT whose FLOPs dominate prefill for this model, which is the opposite of the usual VLM story and is exactly why it is worth its own record. head_dim 256 with 8 KV heads on sliding layers versus global_head_dim 512 with 1 global KV head, across 8 global layers of 48. Audio is native on the 12B per Google's doc, which adds an audio-tower prefill cost not present in the text-and-image models. Ships with an MTP draft model.

SERVICEABILITY JOIN (added 2026-10-03; the architecture x engine matrix this record was missing, with a citation per cell in docs/13-model-compatibility.md): FAMILY=sliding-window. REQUIRED KERNEL CLASS: a local/windowed attention decode kernel plus per-layer-type cache management. The kernel requirement is not cosmetic: flop/sliding-window-hybrid-attention records that a local layer's decode cost is constant in context (it reads exactly w KV entries) so its arithmetic intensity stays at ~1 flop/byte forever, while the global layers' bytes still grow linearly - the two layer classes have opposite scaling and one kernel must serve both. SUPPORTED BY (cited): vLLM lists sliding attention inside its fallback envelope - 'Attention types: full attention and/or sliding attention' - but ALSO has native rows for the specific SWA architectures: GptOssForCausalLM, Gemma3ForCausalLM, Gemma4ForCausalLM, Olmo3ForCausalLM, GraniteMoeSWAForCausalLM, GraniteSWAForCausalLM [[mdl2-vllm-supported-models-2026-10]]. SGLang's generative table names GPT-OSS as 'hybrid sliding-window-attention MoE model ... with per-layer-type RoPE (YARN on full-attention layers, default on sliding-attention layers) and a softplus per-head attention gate', and lists granite-swash SWA models [[mdl2-sglang-generative-models]]. llama.cpp exposes SWA as first-class KV keys rather than a flag: %%s.attention.sliding_window and %%s.attention.sliding_window_pattern exist as distinct keys per architecture class, alongside SWA-specific width keys, which is direct evidence that SWA changes the cache layout rather than adding an attention flag [[mdl2-llamacpp-arch-class-registry]]. THE PER-CELL CONSEQUENCE: an engine WITHOUT local-attention support does not fail, it silently allocates a full-context cache for every layer. docs/13-model-compatibility.md tabulates this as the KV overpay table; for this model the naive figure in kv_cache_bytes_per_token is the worst case and the effective figure is what the windowed layers actually hold. TWO HARD GATES THAT ARE NOT ABOUT WINDOW SIZE. (1) TensorRT-LLM publishes a per-architecture 'Sliding Window Attention' column and it is NOT uniformly Yes: Yes for DeepseekV4ForCausalLM, Gemma4ForConditionalGeneration, Gemma4UnifiedForConditionalGeneration and Step3p7ForConditionalGeneration, and explicitly No for Qwen3NextForCausalLM, while the DeepSeek-V3/V3.2/GLM/GPT-OSS/Llama-4/Qwen3.5/Kimi-K3/Nemotron-H rows read N/A [[mdl2-trtllm-supported-models]]. (2) On B200 with vLLM 0.23.1rc1.dev843 + flashinfer-python 0.6.14, a 50-of-60-layer SWA Gemma-4 checkpoint with --kv-cache-dtype fp8_e4m3 and MTP spec-decode (k=7) produces fluent output containing sporadic wrong tokens and short repetition loops once seq_len passes the 1024-token window, because flashinfer's trtllm spec-as-decode kernel mis-computes sliding-window attention for BF16-Q + FP8-KV at certain seq_len/page alignments and vLLM's scale bookkeeping double-applies k/v scales - gotcha-flashinfer-bf16q-fp8kv-spec-decode-corrupts-swa, severity BLOCKER. FP8-Q + spec is clean; BF16-Q + no spec is clean; either drop quantized KV, drop spec decode, or drop the disable_flashinfer_q_quantization flag. This is the cleanest statement in the repo that quantized KV and speculative decoding are not independently safe on an SWA model. (3) FlashInfer also rejects large head sizes at engine init, which is a separate SM120 gap from the page-block one: head_size not supported for gemma-4-31b-it's head_dim 256 / global_head_dim 512 on RTX PRO 6000 [[flashinfer-rejects-large-head-dim]]. (4) On Hopper, vLLM 0.30.0's vllm_flash_attn silently ignores num_splits on SM90, costing 48% per-token decode at batch 1 for Gemma-4 26B-A4B-it global layers (1 query token, 2 KV heads, 2 of an H100's 132 SMs with work), with TRITON_ATTN recovering ~70% [[fa4-num-splits-ignored-sm90]]. (5) vLLM's own scheduler granularity interacts with SWA groups: issue #53786 asks for fine-grained prefix hits for sliding-window groups, and hybrid reconciliation already caps the combined hit at the shorter boundary [[eagle-prefix-cache-last-block-drop]]. (6) On Apple Silicon the class is a cache-CLASS problem, not a kernel problem: mlx-lm's sliding-window layers use RotatingKVCache, which had no quantized implementation, so --kv-bits passes a hasattr presence check and raises NotImplementedError on the first request instead of at startup; the fix (PR 1584) adds RotatingQuantizedKVCache, and the commonly-recommended monkeypatch silently gives up the max_kv_size window bound and yields an unbounded cache [[mlx-kv-bits-crashes-on-first-request-for-hybrid-attention]] [[mdl2-mlxlm-pr1584-rotating-quantized-kv]]. KV OVERPAY NOT COMPUTABLE FROM THIS RECORD: kv_cache_bytes_per_token is null here, and the reason is structural. This checkpoint has SEPARATE GLOBAL HEAD GEOMETRY (global_head_dim 512 with num_global_key_value_heads 1, against head_dim 256 with 8 local KV heads), so the local and global layers have different per-token widths and the naive num_layers x num_kv_heads x head_dim x 2 x 2 formula does not have a single answer. The overpay factor for it is bounded by the local:global layer ratio but the byte total is not derivable from the fields this schema carries. Flagged as an unknown in docs/13-model-compatibility.md rather than estimated.

CONTEXT_SCALING_METHOD (native): SCHEME RECLASSIFIED (2026-10-04): was 'per-layer-type rope' read as a scaling method. config carries rope_parameters PER LAYER TYPE (full_attention: rope_theta 1e6 / rope_type proportional; sliding_attention: rope_theta 1e4 / rope_type default) and NO factor. That is per-layer RoPE geometry, not context extension: max_position_embeddings 262144 is reached with no scaling block.

LAYER LAYOUT (gemma-4-12b): layer_types read verbatim from config, one entry per layer; attention_layer_indices are the 0-based positions of the full-attention entries.

Cross-references

This record references no other records — it is a leaf. It is cited by 0.