Skip to main content
conformance ✓ spec 1.0 gemma4 The Model Spec of google/gemma-4-12B in TheFormalEra.Spec.Registry. The constants below are transcribed from its published config.json, and the official transformers.Gemma4UnifiedForConditionalGeneration is checked against them.

At a glance

What to watch for

  • Layer i is global iff i % 6 = 5 (gemma4_12b_pattern): 8 global layers, 40 sliding-window layers with a window of 1024.
  • Sliding layers: 16 query heads, 8 KV heads, head dim 256, RoPE θ = 10,000. Global layers: 16 query heads, 1 KV head, head dim 512, values = keys, RoPE θ = 1,000,000 with only the first 64 frequencies active.
  • Attention scale is 1 (the q/k norms take its place). Values get an unweighted RMSNorm (attn.v_norm).
  • Sandwich norms: post_mix_norm after attention and post_ffn_norm after the MLP; the MLP residual has a learned per-layer scalar.
  • GeGLU with the tanh approximation of GELU (geluMul). Embeddings are scaled by √3840. Logits are soft-capped: 30 · tanh(z / 30).
  • Scope: the text-only path. The vision and audio towers are out of scope.

Compute-graph nodes

Use these paths in Spec Keys: google/gemma-4-12B@1.0:layers[*].<node> for per-layer nodes, google/gemma-4-12B@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 official transformers.Gemma4UnifiedForConditionalGeneration agrees with this spec, layer by layer in float64, to a maximum relative error of 6.7e-16 (reduced-width profile, 2 weight draws × 2 lengths).

Published configuration