google/gemma-4-31B in TheFormalEra.Spec.Registry. The constants below are transcribed from its published config.json, and the official transformers.Gemma4ForConditionalGeneration is checked against them.
At a glance
What to watch for
- Layer
iis global iffi % 6 = 5(gemma4_31b_pattern): 10 global layers, 50 sliding-window layers with a window of 1024. - Sliding layers: 32 query heads, 16 KV heads, head dim 256, RoPE θ = 10,000. Global layers: 32 query heads, 4 KV heads, head dim 512, values = keys, RoPE θ = 1,000,000 with only the first 64 frequencies active.
- Attention scale is 1. Values get an unweighted RMSNorm (
attn.v_norm). - Sandwich norms (
post_mix_norm,post_ffn_norm) and a learned per-layer scalar on the MLP residual. - GeGLU (
geluMul, tanh GELU). Embeddings are scaled by √5376. Logits are soft-capped:30 · tanh(z / 30). - Scope: the text-only path. The vision tower is out of scope.
Compute-graph nodes
Use these paths in Spec Keys:google/gemma-4-31B@1.0:layers[*].<node> for per-layer nodes, google/gemma-4-31B@1.0:<node> for the others.
Nodes listed twice have different constants in different layers (for example, sliding-window and global attention). A kernel annotated with
layers[*].<node> is verified against each variant.
Tensors of the main nodes
Conformance
The officialtransformers.Gemma4ForConditionalGeneration agrees with this spec, layer by layer in float64, to a maximum relative error of 8.6e-16 (reduced-width profile, 2 weight draws × 2 lengths).
Published configuration
The hyperparameters as the spec renders them (config.json form)
The hyperparameters as the spec renders them (config.json form)
