archdb

LLM architectures and pretraining recipes, with sources.

Gemma-4-31B

Google DeepMind · base checkpoint

Open in the comparison table Hugging Face ↗ Paper ↗

KV calculations use one sequence at 131,072 tokens and 16-bit cache elements. They include bounded sliding-window caches. This is retained cache payload, not peak prefill memory. The comparison table also offers sourced mixed-precision layouts, including quantization scales.

Release

Released

2026-04-02

Source: blog · Gemma 4 launch post header
Gemma 4: Byte for byte, the most capable open models Apr 02, 2026

Date the weights (or, if earlier, the technical report) were first made public, YYYY-MM-DD, as dated by the publisher. A Hugging Face repository creation date is used only when no dated publisher page exists, with a note.

License

apache-2.0

Source: model-card · README.md; YAML front matter
license: apache-2.0

License of the released weights as declared by the publisher (model card metadata or license file), e.g. apache-2.0, mit, or the name of a custom license.

Input modalities

text + image

Source: model-card · README.md; Dense Models table (31B Dense column)
| **Supported Modalities** | Text, Image, Audio | Text, Image, Audio | Text, Image, Audio | Text, Image |

The card also lists video understanding as processing sequences of frames; audio is limited to E2B, E4B and 12B.

Input modalities of the released checkpoint as the publisher states them, from: text, image, video, audio, joined with ' + ' in that order ("text", "text + image + video").

Parameters

Total params

30.7B parameters

Source: model-card · README.md; Dense Models table
11.95B | 30.7B

Total parameter count as reported by the publisher. See params.note for whether embeddings, MTP heads or vision towers are included.

Active params

30.7B parameters

Inferred from the source; see the explanation below.

Source: model-card · README.md; Dense Models table
11.95B | 30.7B

Dense model; active equals the stated total.

Parameters used per token in the forward pass, as reported by the publisher.

Active non-embedding (stated)

29.29B parameters

Source: paper · PDF page 2; Table 1
31B - 550M 1,410M 29,290M 500M

Einsums column of the dense model; the tied 1,410M embedder is counted separately.

Active parameters excluding the input embedding and the output head (unembedding). Stated by the publisher, or computed from params.active by subtracting vocab × d_model for each of the embedding and output head that params.active is stated to include (basis inferred, note with the arithmetic). Not disclosed when the scope of params.active is not stated.

Counted total params

30.7B parameters

Calculated: embedding + output head + all experts + other weights, google/gemma-4-31B@5bbc2fb safetensors headers; reproduces stated total (backbone) and active (with embedding)

Parameters of the text backbone counted from the released checkpoint's safetensors headers (embedding, output head, all experts and other weights; excluding MTP modules, vision/audio towers and n-gram lookup tables). Shown only when the counts reproduce the publisher's stated total and active parameters within 5% under some scope.

Counted embedding + head

1.409B parameters

Calculated: input embedding + output head, google/gemma-4-31B@5bbc2fb safetensors headers

Input embedding plus output head (once if tied), counted from the checkpoint.

Non-emb. params (counted)

29.29B parameters

Calculated: dense + routed backbone weights; excludes input embedding, output head, lookup tables, MTP and other modalities, google/gemma-4-31B@5bbc2fb safetensors headers; reproduces stated total (backbone) and active (with embedding)

Language backbone weights excluding input embeddings, output head, lookup/Engram tables, MTP modules and vision/audio towers. Equals params.counted_total minus params.counted_embedding. Same validation as params.counted_total.

Largest layer (counted)

534M parameters

Calculated: max(sum of dense and routed weights sharing a full layers.<index> tensor path), all experts included, google/gemma-4-31B@5bbc2fb safetensors headers

Largest group of language-backbone weights sharing a full layers.<index> tensor path, including every routed expert. Excludes lookup/Engram tables, embeddings, output head, MTP and other modalities. Hybrid checkpoints may store mixers and FFNs as separate layers. All-gather volume also depends on wrapping, sharding and dtype.

Active non-emb. (counted)

29.29B parameters

Calculated: all weights except embedding and output head, google/gemma-4-31B@5bbc2fb safetensors headers; reproduces stated total (backbone) and active (with embedding)

Active parameters per token excluding the input embedding and output head, counted from the checkpoint as all non-expert weights plus routed-expert weights × top_k / experts. Same validation as params.counted_total.

Counting scope

Language model only (1,410M embedder + 29,290M einsums). Excludes the 550M frozen vision encoder and the 500M MTP drafter.

Source: paper · PDF page 2; Table 1
31B - 550M 1,410M 29,290M 500M

What the publisher's counts include or exclude (MTP modules, embeddings, vision encoder, n-gram tables).

Embedding params

1.41B parameters

Source: paper · PDF page 2; Table 1
31B - 550M 1,410M 29,290M 500M

Parameters in input embedding and output head, as reported.

Non-embedding params

29.29B parameters

Source: paper · PDF page 2; Table 1
31B - 550M 1,410M 29,290M 500M

Parameters excluding embedding and output head, as reported.

Shape

Layers

60

Source: config · /text_config/num_hidden_layers

Number of transformer blocks in the main backbone (attention or token mixer plus FFN), excluding MTP modules.

d_model

5,376

Source: config · /text_config/hidden_size

Residual stream width.

Vocab

262,144

Source: config · /text_config/vocab_size

Embedding table rows (vocab_size in config, may include padding).

Tied embeddings

Yes

Source: config · /text_config/tie_word_embeddings

Input embedding and output head share weights.

Tokenizer

SentencePiece, same as Gemini: split digits, preserved whitespace, byte-level encodings

Source: paper · PDF page 3; §2.4 Tokenizer
digits, preserved whitespace, and byte-level en

Tokenizer type and lineage as described by the publisher (e.g. byte-level BPE shared with an earlier model).

d_model / layers

89.6

Calculated: d_model / layers

Width-to-depth ratio, d_model divided by the number of blocks.

Attention

Token mixers

GQA, SWA

Source: model-card · README.md; Models Overview
interleaves local sliding window attention with full global attention, ensuring the final layer is always global.

Global layers reuse keys as values (attention_k_eq_v: no v_proj; V is the K projection before RoPE and k_norm). use_bidirectional_attention vision: image tokens attend bidirectionally, text is causal.

Token-mixing layer types in the backbone, e.g. GQA, MLA, SWA, Gated DeltaNet, Mamba-2, DSA (DeepSeek sparse attention).

Layer layout

5 SWA : 1 global

Inferred from the source; see the explanation below.

Source: config · config.json; /text_config/layer_types
"layer_types": [ "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention" ]

Ordered 60-layer backbone from /text_config/layer_types; auxiliary modules are excluded.

Token-mixer order, summarized as a pattern or layer positions. The fact's optional sequence lists each mixer in order; a ratio alone does not establish the order. Auxiliary prediction modules and standalone FFNs are excluded.

Global-attention layers

10

Source: config · /text_config/layer_types | count full_attention

Layers whose KV cache grows with full context (dense or sparse global attention, MLA). Excludes sliding-window and linear/recurrent layers.

SWA : global

5

Calculated: attn.local_layers / attn.global_layers

attn.local_layers divided by attn.global_layers, the sliding-window to global interleave ratio (5 for '5 SWA : 1 global').

Sliding-window layers

50

Source: config · /text_config/layer_types | count sliding_attention

Layers with a fixed attention window.

Query heads

32

Source: config · /text_config/num_attention_heads

Query heads in the global-attention layers.

KV heads

4

Source: config · /text_config/num_global_key_value_heads

Key/value heads in the global-attention layers. Not applicable to MLA, whose cache is a shared latent.

Heads × head dim

16,384

Calculated: heads × head_dim

attn.heads × attn.head_dim, the query projection width of global layers.

Q heads / KV head

8

Calculated: heads / kv_heads

attn.heads divided by attn.kv_heads in global layers.

QK head dim

512

Source: config · /text_config/global_head_dim

Global layers only; sliding-window layers use head_dim 256.

Query/key dimension per head in global-attention layers (for MLA, nope + rope dims).

Window

1.024K tokens

Source: config · /text_config/sliding_window

Sliding-window size of the local layers.

SWA KV heads

16

Source: code · configuration_gemma4.py; Gemma4TextConfig.__post_init__
num_key_value_heads = num_global_key_value_heads if getattr(self, "attention_k_eq_v", True) else None

This override is applied only to full_attention layers, so sliding layers use /text_config/num_key_value_heads = 16.

KV heads in sliding-window layers (stated even when equal to attn.kv_heads).

SWA query heads

32

Source: config · /text_config/num_attention_heads

Same num_attention_heads attribute for both layer types (Gemma4TextAttention).

Query heads in sliding-window layers (stated even when equal to attn.heads).

SWA QK head dim

256

Source: config · /text_config/head_dim

configuration_gemma4.py overrides head_dim (global_head_dim) and num_key_value_heads (num_global_key_value_heads) only for full_attention layers; sliding layers keep head_dim, num_key_value_heads and num_attention_heads.

Query/key head dimension in sliding-window layers. Value head dimensions may differ; see attn.local_v_head_dim.

Positional encoding

partial RoPE (global, p-RoPE p=0.25), RoPE (SWA)

Source: paper · PDF page 2; §2 Long-context efficiency
with p-RoPE with p = 0.25 on global attention

Positional scheme in global layers: RoPE, partial RoPE, NoPE, or mixed per layer type.

RoPE base

1,000,000

Source: config · /text_config/rope_parameters/full_attention/rope_theta

RoPE base frequency of the global layers at release.

SWA RoPE base

10,000

Source: config · /text_config/rope_parameters/sliding_attention/rope_theta

rope_type default.

RoPE base frequency of the sliding-window layers (stated even when equal to attn.rope_theta).

Rotary fraction

0.25

Source: config · /text_config/rope_parameters/full_attention/partial_rotary_factor

Global layers use rope_type proportional (p-RoPE).

Fraction of each head's QK dimensions that are rotated.

QK norm

Yes

Source: paper · PDF page 2; §2
and QKNorm (Henry et al., 2020).

Queries and keys are normalized per head before the dot product.

Attention scaling

1.0 (no 1/sqrt(head_dim)); V RMS-normalized without learned scale

Source: code · modeling_gemma4.py; Gemma4TextAttention.__init__
self.num_key_value_groups = config.num_attention_heads // layer_config.num_key_value_heads self.scaling = 1.0

v_norm is Gemma4RMSNorm(head_dim, with_scale=False), applied in every attention layer.

Query-key scaling when it is not 1/sqrt(head_dim), e.g. query_pre_attn_scalar, length-dependent (SSMax-style) scaling, or value scaling.

QKV bias

No

Source: config · /text_config/attention_bias

Query/key/value projections have bias terms.

Feed-forward

Activation

GeGLU (tanh-approximate GELU)

Source: code · modeling_gemma4.py; Gemma4TextMLP.forward
down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))

act_fn = ACT2FN[/text_config/hidden_activation] = gelu_pytorch_tanh.

FFN activation (SwiGLU, GeGLU, ...).

Dense FFN dim

21,504

Source: config · /text_config/intermediate_size

Intermediate width of the dense FFN layers that are actually executed.

FFN bias

No

Source: code · modeling_gemma4.py; Gemma4TextMLP.__init__
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)

FFN projections have bias terms.

Dense FFN / d_model

4

Calculated: ffn.dim / d_model

ffn.dim divided by shape.d_model.

Multi-token prediction

MTP depth

Not disclosed

Additional future tokens predicted during pretraining (0 when the model was trained without MTP).

Normalization and stability

Norm

RMSNorm

Source: paper · PDF page 2; §2
with RMSNorm (Zhang and Sennrich, 2019),

Normalization layer type in the blocks.

Norm placement

sandwich

Source: paper · PDF page 2; §2
Our models have pre-norm and post-norm

Pre-norm, post-norm, or sandwich (pre and post).

Final logit softcap

30

Source: config · /text_config/final_logit_softcapping

tanh soft-capping value on output logits.

Norm epsilon

1e-06

Source: config · /text_config/rms_norm_eps

Epsilon of the block normalization layers.

Embedding scaling

× sqrt(d_model)

Source: code · modeling_gemma4.py; Gemma4TextModel.__init__
config.vocab_size, config.hidden_size, self.padding_idx, embed_scale=self.config.hidden_size**0.5

Scaling or normalization applied to input embeddings (e.g. × sqrt(d_model), RMSNorm after embedding).

Context length

Pretraining context

Not disclosed

Sequence length of the main pretraining stage.

Trained context

Not disclosed

Longest sequence length trained on after context extension.

Advertised context

262.1K tokens

Source: model-card · README.md; Dense Models table
Context Length | 128K tokens | 128K tokens | 256K tokens | 256K tokens

config max_position_embeddings is also 262144.

Longest context the publisher says the model supports, possibly beyond trained length via RoPE scaling.

Pretraining recipe

Pretraining tokens

Not disclosed

Tokens seen in pretraining including annealing and context extension, as reported.

Optimizer

Not disclosed

Optimizer used for the bulk of parameters.

Peak LR

Not disclosed

Peak learning rate of the main pretraining stage.

Final LR

Not disclosed

Learning rate at the end of the decay.

LR schedule

Not disclosed

Learning-rate schedule shape with phase boundaries.

Warmup

Not disclosed

Warmup length in steps or tokens.

Batch size

Not disclosed

Global batch size, including any batch-size ramp: sequences × sequence length (token total), or the token total alone when only that is stated.

Weight decay

Not disclosed

Decoupled weight decay coefficient.

Adam betas

Not disclosed

(beta1, beta2) of the Adam-family optimizer or its AdamW fallback.

Grad clip

Not disclosed

Global gradient-norm clipping threshold.

Training precision

Not disclosed

Matmul precision of pretraining (BF16, FP8 recipe, NVFP4 recipe) with the scaling granularity where disclosed. Never inferred from the released checkpoint dtype.

Data mix

Web documents (140+ languages), code, mathematics, images

Source: model-card · README.md; Training Dataset
The training dataset includes content in over 140 languages.

Pretraining data composition as disclosed (domain shares, synthetic fraction, repetition).

Data cutoff

January 2025

Source: paper · PDF page 3; §2.4 Training data
with a cutoff date of January 2025.

Pretraining data cutoff date.

Hardware

10,240 TPUv6e chips (16 data × 16 sequence × 40 replica)

Source: paper · PDF page 2; Table 2
31B v6e 10,240 16 16 40

Accelerators used for pretraining, count and duration where stated.

Accelerators

10,240 TPU v6e

Source: paper · PDF page 2; Table 2
31B v6e 10,240 16 16 40

Accelerator count and type for the main pretraining run, as the count with thousands separators and the chip's short name ("2,048 H800", "2,048 GH200"). A stated range or bound stays as stated ("2,048–4,096 GH200").

Parallelism

data16 · seq16 · replica40

Source: paper · PDF page 2; Table 2
31B v6e 10,240 16 16 40

Table 2 sharding axes (data, sequence, replica) as named by the report, not mapped to TP/CP/DP; §2.7 adds ZeRO-3 optimizer-state sharding.

Parallelism layout of the main pretraining run as stated, as degree-annotated terms in the order TP, PP, VPP, EP, CP, DP ("PP16 · EP64 · ZeRO-1 DP"); a term without a stated degree has none ("FSDP").

KV cache

KV bytes / token

88,320 bytes

Calculated: kv.bytes_at_context / 131072 tokens; uniform BF16, payload only; quantization overhead excluded. Global KV: 10 × (4096 × 16/8) B/entry; SWA KV: 50 × (8192 × 16/8) B/entry

Retained KV cache divided by context length, including bounded SWA caches and indexer keys. Exports use uniform BF16 at 131,072 tokens. The website can select uniform payload precision (no quantization overhead) or sourced component formats (including scales and documented padding). This is cache payload, not peak prefill memory or persistent prefix storage.

Global KV bytes / token

81,920 bytes

Calculated: 81920 B / 1 tokens (Global KV); uniform BF16, payload only; quantization overhead excluded. Global KV: 10 × (4096 × 16/8) B/entry; SWA KV: 50 × (8192 × 16/8) B/entry

Long-context global KV bytes per token, including indexer keys; excludes bounded SWA caches. Compression rates and cross-layer cache reuse are included. Exports use uniform BF16; the website's storage selector also applies here. This is the field to compare with global-KV figures in reports, using the matching storage recipe.

KV bytes / token / B active

2,877 bytes

Calculated: kv.bytes_per_token (131072 tokens) / (params.active / 1e9); uniform BF16, payload only; quantization overhead excluded. Global KV: 10 × (4096 × 16/8) B/entry; SWA KV: 50 × (8192 × 16/8) B/entry

kv.bytes_per_token divided by active parameters in billions (131,072 tokens in exports).

KV at context / B active

377,077,493 bytes

Calculated: kv.bytes_at_context (131072 tokens) / (params.active / 1e9); uniform BF16, payload only; quantization overhead excluded. Global KV: 10 × (4096 × 16/8) B/entry; SWA KV: 50 × (8192 × 16/8) B/entry

kv.bytes_at_context divided by active parameters in billions (131,072 tokens in exports).

KV at context

11,576,279,040 bytes

Calculated: 81920 B × 131072 (Global KV) + 819200 B × min(131072, 1024) (SWA KV); uniform BF16, payload only; quantization overhead excluded. Global KV: 10 × (4096 × 16/8) B/entry; SWA KV: 50 × (8192 × 16/8) B/entry

Retained KV cache for one sequence at the selected context, including SWA windows and indexer keys. Exports use uniform BF16 at 131,072 tokens. Excludes recurrent state, compressor tail state, draft/MTP caches, temporary prefill tensors, allocator metadata and persistent prefix snapshots. Does not estimate peak prefill or total serving memory.

Evaluations

AA Intelligence Index

15

Source: leaderboard · Artificial Analysis model page /models/gemma-4-31b, Wayback snapshot 2026-10-19
Gemma 4 31B (Reasoning) scores 15 on the Artificial Analysis Intelligence Index

Score of Gemma-4-31B-it, post-trained from this base. Variant: Gemma 4 31B (Reasoning). Index v4.3.2.

Artificial Analysis Intelligence Index v4.3.2 of the post-trained model, from a dated Wayback snapshot of its Artificial Analysis page. The note names the variant (reasoning setting).

All models · Link to this model