Instructions to use google/gemma-4-12B-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/gemma-4-12B-it with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("google/gemma-4-12B-it") model = AutoModelForMultimodalLM.from_pretrained("google/gemma-4-12B-it", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- AMD Developer Cloud
Running Google’s Gemma-4 12B IT with Dual-Plane 8-Bit Effective NVFP4
What was converted. The 23.9 GB BF16 checkpoint was ingested into a 12.0 GB
NVFP4 artifact: 48 decoder layers (Q/K/V/O + GeGLU MLP), the tied embedding /
output table, four RMSNorm weights and one per‑layer scalar per layer, the
tokenizer and the chat template. Eleven multimodal tensors — a patch‑embedding
tower (vision_embedder.*) and a single 640→3840 audio projection — were
identified, counted and stripped; this engine is text‑only. The text decoder is
the same architecture as the larger 31B member of the family, so one converter,
one loader and one kernel set serve both, and each checkpoint is validated
against its own frozen geometry.
What the checkpoint forced into the engine (each of these is a way to get
plausible‑but‑wrong tokens):
- Attention is unscaled. The checkpoint normalises Q and K per head, so the
score scale is 1.0; applying1/sqrt(head_dim)— the usual default — silently
rescales every attention distribution. - K is V on the eight full‑attention layers.
attention_k_eq_vis set and
those layers ship nov_projat all. V is the raw K projection, taken before
K's normalisation and RoPE, and then passed through an unweighted per‑head
norm. - Two different RoPE encodings live in one model. The 40 sliding layers use
ordinary full‑width rotary with θ=10⁴; the 8 full layers use proportional
partial rotary (θ=10⁶, a quarter of the head's frequency pairs active, the rest
identity) over a 512‑wide head. A single‑θ implementation decodes garbage. - 5:1 hybrid pattern. Sliding layers carry window 1024; full layers attend
the whole prefix. Deriving the pattern from tensor shapes rather than trustinglayer_types(and erroring when the two disagree) is what keeps a re‑shipped
config from silently swapping them. - Embedding scale is a bf16‑rounded constant, per checkpoint. Upstream casts
sqrt(hidden_size)to the weight dtype before multiplying: 62.0 at width 3840,
73.5 at 5376. It is derived from the loaded geometry, never from a sibling's
constant — a shared 73.5 would scale every 12B embedding by 1.19. layer_scalaris BF16, not F32, and it multiplies the residual stream
at the end of each layer. A loader that size‑checks against F32 silently skips
it and the hidden states grow ~15×.- Soft‑capped logits.
logits = tanh(l/30)·30.
Two artifact‑level defects found in the checkpoint family, with suggestions to
the authors (both were found on the sibling 31B and had to be handled here
again):
- A
gemma4_unifiedtree and agemma4tree describe their multimodal
ballast with different tensor names.gemma4ships a vision transformer
(vision_tower.encoder.*);gemma4_unifiedships only a patch projection
(vision_embedder.patch_dense,pos_embedding) plusembed_audio.embedding_projection, and additionally carries anaudio_configblock describing a tower that the checkpoint does not contain.
Observed failure mode: a strict‑coverage converter refuses the whole
checkpoint ("unclassified tensor(s)"). Suggestion: keep one ballast naming
across the family, or drop a descriptor block when its weights are not
shipped — a consumer cannot tell "audio tower present" from "audio tower
described" without diffing tensor inventories. - The special‑token ids are split across three places and two nesting
levels.bos/pad/eoslive intext_config, the fulleosarray at the
top level, and a thirdeosid (<end_of_turn>, 50) only ingeneration_config.json. Observed failure mode: readingbosfrom the top
level yields −1, and using onlyconfig.json'seosset lets the model run
past the end of a turn. Suggestion: state the special‑token contract once.
The 4‑bit gate result, and what it cost. A single 4‑bit plane carries ~9.3 %
relative weight error (measured by decoding the written records on the host
against the source bytes: relL2 0.0926, cosine 0.996). That is enough for this
family: the model's own arithmetic answers sit on near‑ties — at one gate's fork
the source model itself prefers one token over the alternative by 0.556 logits
— so accumulated 4‑bit error decides them. Adding a second NVFP4 plane carrying
the per‑tensor residual (w − dequant(base), decoded as one more accumulating
GEMV: ~8 effective bits for 2× the projection bytes) took the formula gate from
1/3 to 2/3 and left the other two gates green. The artifact is 12.0 GB (+5.7 GB
over 4‑bit); a 12B fits that on a 32 GB card, which its 31B sibling does not.
Measured results (RTX 5090, release codegen, 2026‑11‑28):
| gate | result |
|---|---|
| SelfCheck ("Paris") | PASS, bit‑exact over 3 cycles, logits_hash 31d7a1672d89ccdc |
| tool‑call round‑trip | PASS — native `< |
| CODE parity | 3/3 |
| DET parity (3 runs each) | 3/3, deterministic |
| MCP payload parity (JSON-RPC 2.0) | 3/3 — tools/call, resources/read and a -32602 error response; byte-exact to the committed template. A required lifecycle stage (it stopped being a pilot the same day — see docs/open-tasks/2026-11-28-mcp-gate-rollout-closed.md) |
| FSI parity | 2/3 — FSI‑02 red, cause measured (below) |
| decode throughput | 59.85 t/s at the canonical 2048‑token protocol (TTFT 283 ms, 12.83 GB resident, ≈757 GB/s effective, 440 W avg / 461 W peak) |
The one open gate, stated honestly. FSI‑02 asks the model to restate a
formula symbolically; the source model does, this engine substitutes the given
numbers into the same structure. It is not a kernel defect and not a
quantization artefact that more precision fixes: at the fork the source's own
preference is 1 (21.61) vs Rate (21.05) — a 0.556‑logit margin — so the
gate is deciding a coin flip that any 8‑bit body can flip. Giving the 262 k‑row
output table its own residual plane was measured and did not move it (same
2/3, byte‑identical answer) for +0.6 GB, so that experiment was reverted. The
gate stays red as recorded debt.
What was not measured and why. A bit‑exact (kOff) throughput number exists
(48.77 t/s) and is 18 % below the auto‑policy number for a measured reason — the
head's K (3840) sits just under the shared streaming‑GEMV floor (K ≥ 4096), so in
the bit‑exact route the 540 MB/token output projection falls back to the scalar
path; the auto policy reaches the tensor‑core route and keeps the streaming GEMV.
Raising that floor is a change to a model‑neutral dispatcher shared by ~45
models, so it was recorded as a lever rather than taken here. No long‑context,
batched or multi‑turn measurements were made.
• Full Ingestion Report: https://github.com/Alex7MV/logestix/blob/main/docs/model-reports/2026-11-28-Gemma-4-12B-IT.md
• Repository: https://github.com/Alex7MV/logestix
Thanks for a field report this complete. The dual-plane result is the part worth underlining: a single 4-bit plane at ~9.3% relative weight error was enough to flip near-tie answers, and the second residual plane took the formula gate from 1/3 to 2/3 for +5.7 GB, with a 12.0 GB artifact from the 23.9 GB BF16 checkpoint. Leaving FSI-02 red is the honest call, and the measurement behind it matters: at the fork the source model itself prefers one token by only 0.556 logits, so the gate is deciding a coin flip, and the output-table residual experiment that did not move it was rightly reverted. The conversion warnings are just as useful: attention unscaled because Q and K are normalised per head, K serving as V on the eight full-attention layers, and two RoPE encodings in one model are exactly the plausible-but-wrong failure modes worth recording. The throughput figure completes the picture: 59.85 t/s at the 2048-token protocol, 12.83 GB resident on the 5090. We appreciate the gates, the costs, and the open debt all being stated plainly.
Thank you! Measuring the exact logit margin (0.556) on the source model made it clear where 8-bit effective quantization hits a genuine tie rather than a kernel bug—so keeping FSI-02 documented as open debt and reverting the zero-gain head residual was the only honest call.