Gemma 4 31B IT (v2 Bare-Metal + MTP Assistant + Vision) for Blackhole QuietBox 2
Self-contained bare-metal C++20 inference engine (gemma4-tt) with embedded Blackhole BRISC/TRISC/ERISC1 firmware — zero Python, zero PyTorch, zero TT-Metal, zero Docker, zero JIT warmup, zero chip resets between overlays — packaged as a tt-model-manager v6 bundle with the complete inspectable C++20 and firmware source tree in extra_code/gemma4_regen/.
Combines 5-RISC 32-row decode (85.6 t/s/u raw @ B=1 8K = 95.6% DRAM BW, 495.9 t/s raw @ B=8 8K), 4-layer MTP assistant speculative decoding with BFP4 LM head and exact global Top-64 (G4_LM_FLAG_TOP64_RAW) Leviathan sampling (226.2–236.8 t/s/u decode @ B=1 8K, 380.1 t/s agg / 407.7 t/s steady @ B=8 8K, 273.6 t/s/u decode @ 1K), 950 MHz Prefill DVFS with full 120-core co-resident chunk-4096 prefill grids and zero static NOPs (1.16 s TTFT @ 8K, 4.11 s @ 32K, 8.59 s @ 64K, 20.20 s @ 128K = 3.14× faster than RTX PRO 6000 vLLM), 128-token L1 paged KV with CoW prefix caching up to 262K context, 480-core Vision Tower (PCC 0.9983), strict on-device JSON schema PDA across <|thought|>...<thought|> transitions, and full OpenAI tool_choice="required" / named / multi-turn thinking tool calling on a 4-chip QuietBox 2 (2× p300c). Prefill operates at 950 MHz (via TT_SMC_MSG_SET_ASIC_HOST_FMAX with automatic 800 MHz KMD SET_POWER_STATE fallback; ARC 0x10u emergency throttle active) and snaps back to 1,350 MHz for Decode & Vision in < 2.2 ms — verified across a 3-minute continuous thermal soak (1.32M prompt tokens) and hot-silicon 1,000 Hz (1 ms) captures (35,117 samples: ≤ 516.9 W/card 5 s sustained, ≤ 1,023 W dual-card 5 s / 1,061 W 1 s, 0 dual-card spikes ≥ 1,600 W, ≤ 62.3 °C, 0 PCIe AER, 0 board_power throttles during pure prefill) with 0% decode regression.
Quickstart (tt-model-manager v6)
No Docker, Python runtime, PyTorch, TT-Metal, or SFPI toolchain is required on the host — only a Tenstorrent Blackhole QuietBox 2 (4× p300c) with KMD ≥ 2.11.0 and tt-model:
# Pull the ~18 MB v6 bare-metal bundle (+ pre-quantized weights ~27 GB from moconnor/Gemma-4-31B-IT-QB2-ttq):
tt-model pull moconnor/gemma4-31b-qb2-regen --with-weights
# Launch the OpenAI-compatible server on http://127.0.0.1:20000 (defaults: --users 8 --context 262144 --max-tokens 262144):
tt-model serve moconnor/gemma4-31b-qb2-regen
# Verify with tt-model check (text, tools, or vision):
tt-model check "Explain how sliding-window and global attention combine in Gemma 4."
tt-model check --tools
tt-model check --task image-text-to-text
# Cleanly stop and release all 4 chips:
tt-model stop moconnor/gemma4-31b-qb2-regen
Upgrading from the earlier v5.1 container release: run
tt-model pull moconnor/gemma4-31b-qb2-regen --force. The pinned weights revision (a37f443c) is unchanged, andrun.shautomatically reuses any existing weights cached under$HF_HUB_CACHE,$HF_HOME/hub, or~/.cache/huggingface/hub.LAN binding:
gemma4-ttbinds127.0.0.1:<port>directly by default. To expose on all interfaces, pass-- --host 0.0.0.0(uses hostsocatif installed).
Inspectable Source Code (extra_code/gemma4_regen/)
This v6 bundle ships the complete, unmodified C++20 host engine, Blackhole RISC-V BRISC/TRISC/ERISC1 firmware, SFPU microkernels, paged KV manager, MTP speculative decoder, 480-core Vision Tower, and OpenAI HTTP server source at commit 0412f2fb under extra_code/gemma4_regen/:
extra_code/gemma4_regen/src/— All 231 C++20, RISC-V firmware, SFPU, andg4dpprefill source filesextra_code/gemma4_regen/make.py&rules.py— Standalone build rulesbin/gemma4-tt+runtime/*— Prebuilt Linuxx86_64binary with embedded firmware and bundledglibc/libstdc++loader, verified bySHA256SUMS
Quantization & Precision
For apples-to-apples comparison against other stacks (e.g., GPU W4A16/AWQ/GPTQ/MXFP4/FP8 or GGUF), this release uses hardware-native mixed 4-bit / 8-bit Block Floating-Point (BFP) quantized single-pass round-to-nearest (RTN) directly from official upstream HuggingFace BF16 safetensors (google/gemma-4-31B-it) — zero double-quantization, no calibration dataset, and no AWQ/GPTQ/imatrix tuning — paired with a BFP8 KV cache and FP32 accumulation.
Block Floating-Point Formats
Blackhole Tensix tiles (32×32 = four 16×16 faces) group 16 elements per shared 8-bit IEEE exponent (64 exponent bytes per 32×32 tile):
- BFP4 (
BFP4_b, 4.50 bits/weight): 16 elements share one 8-bit exponent (0.50bits/weight) + 4-bit sign-magnitude mantissa (1 sign + 3 magnitude bits;576 Bper32×32tile). - BFP8 (
BFP8_b, 8.50 bits/weight): 16 elements share one 8-bit exponent (0.50bits/weight) + 8-bit sign-magnitude mantissa (1 sign + 7 magnitude bits;1,088 Bper32×32tile).
Weight Quantization Breakdown (moconnor/Gemma-4-31B-IT-QB2-ttq)
| Component | File | Format | Effective bpw | Params (Share) | Footprint (4 Chips / Per Chip) |
|---|---|---|---|---|---|
60× MLP (gate_proj, up_proj, down_proj — all 50 sliding + 10 global layers; pre_ffn_norm folded) |
gemma4-31b-v2-bfp4mlp.ttq |
BFP4_b (RTN) | 4.50 | 20.81B (67.8%*) | 11.71 GB (2,926.3 MB/chip) |
60× Attention (50 sliding q/k/v/o + 10 global q/kv/o with tied K=V; input_norm & global k_norm folded) |
gemma4-31b-v2-bfp4mlp.ttq |
BFP8_b (RTN) | 8.50 | 8.48B (27.6%*) | 9.01 GB (2,251.9 MB/chip) |
LM Head (262,144 × 5,376, tied from embed_tokens, materialized with output_norm / 30.0 folded) |
gemma4-31b-v2-bfp4mlp.ttq |
BFP8_b (RTN) | 8.50 | 1.41B | 1.50 GB (374.3 MB/chip) |
| Total Streamed Decode Weights (TP=4 across 4× Blackhole ASICs) | gemma4-31b-v2-bfp4mlp.ttq |
Mixed BFP4 / BFP8 | 5.79 (linear) | 30.70B linear | 22.21 GB (5,552.5 MB/chip) |
Token Embeddings (262,144 × 5,376, scaled by √5376), RMSNorms, Q/K norms, layer scalars, prefill norms |
gemma4-31b-v2-bfp4mlp.ttq |
BF16 | 16.00 | 1.41B (4.6%*) | 2.82 GB |
| Main 31B Language Model Archive Total | gemma4-31b-v2-bfp4mlp.ttq |
Mixed BFP4 / BFP8 / BF16 | 6.24 (stored) | 30.70B unique | 25.04 GB (23.32 GiB) |
MTP Speculative Drafter (google/gemma-4-31B-it-assistant, 4 layers, d=1024, ffn=8192) |
gemma4-31b-mtp-folded.safetensors |
BFP8_b (q/o/down/m_proj/h_proj) + BFP4_b (up/gate & lm_head) + BF16 (embed_proj/norms), packed at load |
4.50 / 8.50 / 16 | — | 1.46 GB on disk (219.6 MB/chip on device) |
Vision Encoder (27-block SigLIP ViT + 3×3 spatial pooler + embed_vision, 480 Tensix cores) |
gemma4-31b-vision-bfp8.ttq |
BFP8_b linear / BF16 & FP32 embed, norms, biases | 8.50 | — | 634 MB (605 MiB) |
*Share of the 30.70B unique text-model parameters (HF ties lm_head to embed_tokens; the v2 .ttq materializes a separate BFP8 lm_head for decode/prefill alongside BF16 embeddings).
KV Cache & Compute Precision
| Path | Precision | Details |
|---|---|---|
Global Attention KV Cache (10 of 60 layers, 4 tied K=V heads, head_dim=512, 25% partial RoPE) |
BFP8_b (paged, 128-tok blocks) | Exploits Gemma 4's K=V + 25% partial RoPE (rotary_dim=128) in a merged 640-col tile layout (512 shared V/non-rotary + 128 rotary K = 20 BFP8_b tiles per 32-token row = 680 B/tok/chip/layer = 26.56 KiB/tok across all 10 global layers on 4 chips). Cuts global KV footprint and DRAM bandwidth by 37.5% vs separate K/V (3.01× smaller than BF16 separate K/V). Supports zero-copy CoW prefix caching (G4_COMMAND_KV_COPY). |
Sliding-Window KV Cache (50 of 60 layers, window=1,024, 16 KV heads, head_dim=256) |
BFP8_b (paged, 128-tok blocks) | Separate K/V (2,176 B/tok/chip/layer) in a fixed 10-page (1,280-token) sliding ring per active user — recycled automatically so sliding KV stays constant (132.8 MiB/chip/user) regardless of context length up to 262K. |
| MTP Drafter KV Cache (4 layers: 3 sliding + 1 global) | Shared Target KV (0 B extra) | Cross-attends directly into the target model's existing BFP8_b KV cache (layers 58 & 59); lossless Leviathan rejection sampling guarantees exact target-distribution fidelity regardless of drafter precision. |
| Inter-op Activations & Residual Stream | BF16 | All hidden states between projections and across 4-chip ERISC1 collectives. |
| Matrix Multiply (Tensix FPU) | BFP4×BF16 / BFP8×BF16 (LoFi) |
Decode and prefill linear projections accumulate in full FP32 Dst registers before packing to BF16. SDPA uses HiFi2 for sliding attention, normalization, and tree merges (LoFi on global QKᵀ/P·V). |
| Non-linearities & Reductions (Tensix SFPU) | FP32 | RMSNorm, partial RoPE, GeGLU, logit softcap (30·tanh(x/30)), online SDPA softmax, and Top-64 sampling run in FP32. |
Summary for benchmark comparisons: the main 31B text model has an effective linear weight footprint of 5.79 bpw (5,552.5 MB/chip streamed across 4 chips: 4-bit BFP4 MLP, 8-bit BFP8 attention & LM head, BF16 embeddings/norms) with an 8-bit BFP8 paged KV cache (37.5% smaller on global layers via merged 640-col K=V packing), FP32 accumulation, lossless MTP speculative decoding, and an 8-bit BFP8 vision tower (0.9983 PCC vs HF FP32). Live accuracy matches upstream HF BF16 with zero degradation: AIME 2025 90.0% (vs 89.2% HF BF16 ref), GPQA Diamond 90.0%, GSM8K 98.0%, MMLU 88.0%, and 2K–128K 4-needle recall 100.0% (24/24).
Performance & Accuracy
Accuracy (Clean HF-BF16 gemma4-31b-v2-bfp4mlp.ttq, live serve --users 8 --context 163840)
| Benchmark | Score | Notes |
|---|---|---|
AIME 2025 (n=30) |
90.0% (27/30) | T=1.0, top_p=0.95, top_k=64, thinking ON, max_tokens=24576, 0.0% trunc, 12.1 s/prob (HF BF16 ref: 89.2%) |
GPQA Diamond (n=60) |
90.0% (54/60) | T=1.0, top_p=0.95, top_k=64, thinking ON, max_tokens=24576, 0.0% trunc, 9.2 s/prob |
| GSM8K-100 | 98.0% (98/100) | T=0, non-think, 367.4 tok/s live decode, 0 rejected |
| MMLU-100 | 88.0% (88/100) | T=0, non-think, 57 subjects |
| Long-Context 4-Needle (2K–128K) | 100.0% (24/24) | 2K / 8K / 16K / 32K / 64K / 128K (4 needles each); 100% recall across all depths |
Thinking + JSON Schema / Object (C=8) |
100.0% (8/8) | Concurrent thinking + strict schema enforcement across `<thought |
| OpenAI Tool Calling & Exacto Compliance | 20/20 & 60/61 | Full tool_choice="required" / named / auto / none, parallel & multi-turn thinking tool calls |
| 480-Core Vision Tower vs HF FP32 | PCC 0.998277 | 134.6 ms total / 119.7 ms device @ 280 soft tokens; mid-prefill overlay guarded |
Official Apples-to-Apples SPEED-Bench (0412f2fb, 950 MHz Prefill DVFS, Zero Env Overrides)
Measured on physical Blackhole QuietBox 2 (--users 8 --context 163840 --max-tokens 1024 --mtp --vision, low_entropy, thinking ON, T=1.0, top_p=0.95, top_k=64, max_tokens=1024, prefix cache OFF): verified across a 3-minute continuous thermal soak + hot-silicon 1,000 Hz (1 ms) captures (35,117 samples: 516.9 W/card max 5 s sustained ≤ 550 W, 1,023.0 W dual-card max 5 s / 1,061 W 1 s, 0 dual-card spikes ≥ 1,600 W OCP threshold [≤ 1,491 W hot 1 ms max], 62.3 °C max silicon, 0 PCIe AER).
| Workload | E2E (t/s/u) | Decode (t/s/u) | Aggregate (t/s) | TTFT p50 | Whole-Board Power (tt_board_2x_p300c) |
ASIC Core Power (tt_asic_core_4x_p300c) |
|---|---|---|---|---|---|---|
8K · B=1 |
190.3 | 236.8 | 189.1 | 1.16 s | 735.7 W (max 1,112.0 W) | 229.0 W (max 519 W) |
8K · B=2 |
123.4 | 148.4 | 229.9 (249.7 steady) |
1.30 s | 731.2 W (max 1,075.5 W) | 235.8 W (max 582 W) |
8K · B=4 |
78.6 | 92.0 | 294.4 (318.5 steady) |
1.40 s | 735.1 W (max 1,057.0 W) | 256.6 W (max 588 W) |
8K · B=8 |
49.9 | 56.6 | 380.1 (407.7 steady) |
1.42 s | 776.1 W (max 1,143.5 W) | 267.8 W (max 626 W) |
1K · B=1 |
246.5 | 273.6 | 243.8 | 0.41 s | 745.5 W (max 792.0 W) | 226.6 W (max 415 W) |
2K · B=1 |
206.8 | 225.4 | 205.9 | 0.41 s | 734.7 W (max 861.0 W) | 225.8 W (max 490 W) |
8K · B=1 (seq) |
179.6 | 226.2 | 178.1 | 1.17 s | 772.8 W (max 1,113.5 W) | 254.5 W (max 577 W) |
16K · B=1 |
162.1 | 233.6 | 160.1 | 1.96 s | 811.9 W (max 1,295.0 W) | 259.6 W (max 554 W) |
32K · B=1 |
120.8 | 232.1 | 120.3 | 4.11 s | 780.0 W (max 974.0 W) | 297.9 W (max 612 W) |
64K · B=1 |
75.5 | 201.3 | 75.2 | 8.59 s | 863.2 W (max 1,174.5 W) | 326.0 W (max 588 W) |
128K* · B=1 |
38.9 | 153.8 | 38.9 | 20.20 s | 926.8 W (max 1,260.0 W) | 365.7 W (max 621 W) |
Standalone Raw Decode (No TTFT, No Spec Decode, g4 decode-batch)
B=1 @ 8K: 85.56 t/s/u (11.69 ms/step,489.4 GB/s=95.6%of 512 GB/s DRAM);@ 100K: 77.60 t/s/u (96.2%BW)B=8 @ 8K: 61.98 t/s/u (495.9 t/s agg,16.13 ms/step,427.2 GB/s);B=16 @ 8K: 48.73 t/s/u (779.6 t/s agg)- Live
servewithTT_G4_NO_MTP=1(8Kthinking):B=176.93 t/s/udec (2.84×–3.00×MTP speedup),B=839.34 t/s/u/280.0 t/sagg
Artifacts & Provenance
- Schema:
tt-model-managerv6 (thin bare-metal bundle — no Docker container required) - Engine commit:
0412f2fb(main: 950 MHz Prefill DVFS + full 120-core prefill grids + zero static NOPs + ARC0x10udynamic throttling + OpenAItool_choice/thinking/vision; qualification5591e73d) - Inspectable source:
extra_code/gemma4_regen/(snapshot at0412f2fb) - Binary SHA-256 (
bin/gemma4-tt):1aafee0a97327be89a0eb12bac6f79876854883fae2e6323a7b257ec044064f3(seeSHA256SUMS&PROVENANCE.json) - Weights repo:
moconnor/Gemma-4-31B-IT-QB2-ttq@a37f443c6514c4699d3ede0ef3dc2aefda22dc4d
Known Limitations
Blackhole QuietBox 2 (4× p300c) on Linux x86_64 only; requires KMD ≥ 2.11.0. logit_bias, use_beam_search, prompt_logprobs, and n != 1 are not supported. With Leviathan MTP active (--mtp), seeded requests (seed=...) are distribution-exact to target sampling (matching vLLM speculative decoding), not seed-for-seed bit-exact across different batch sizes or --mtp on/off (set TT_G4_NO_MTP=1 for strict cross-schedule seed determinism).
