Gemma 4 26B-A4B BITCOS Mixed-Ternary for Intel Arc (OpenVINO GPU, 256k FP16 KV + Hybrid PLD/MTP + v1.1 Vision)
Built from google/gemma-4-26B-A4B-it by Google DeepMind (Apache 2.0).
Intel-Only Build (OpenVINO 2026.4.1 + Custom OpenCL Kernels) — Near-lossless BITCOS mixed-ternary MoE with full 262,144-token lossless Unified FP16 KV, lossless Hybrid PLD + Split-K=128 MTP speculative decoding, and live v1.1 Multimodal Vision & .mp4 Video on a single consumer Intel Arc A770 16 GB.
- Decode Speed (Hybrid PLD+MTP, Split-K=128):
104.43 tok/scold isolated smoke ·108.13–117.83 tok/swarm sustained (up to182.45 tok/speak) ·83.10 tok/s@ 32k ·76.28 tok/s@ 64k ·62.62 tok/s@ 128k ·54.72 tok/s@ 192k ·47.58 tok/s@ 252k - Pure
M=1Base Decode (No Draft Heads):80.89 tok/sshort ·69.32 tok/s@ 32k ·64.90 tok/s@ 64k ·57.29 tok/s@ 128k ·45.97 tok/s@ 252k - v1.1 Multimodal Vision & Video (INT8 ViT + Projector,
batch=1):235 mssingle image (280tok) ·318 ms2-image comparison ·849 ms5s.mp4clip (1 fps,70tok/frame) ·cos_sim = 0.9993(f32) /0.9959(f16) vs. reference ·0NaNs - Flat VRAM Ceiling (Full
256kContext):12.92 GBtext-only (12.60 GBpureM=1) ·13.07 GiBsteady /13.62 GiBpeak (14.62 GB) single-card all-in-one (26B MoE + 256k FP16 KV + MTP + INT8 Vision on one 16 GB A770) ·0.000 GBmodel shared spill - Long-Context & Fidelity Gates:
256kNIAH PASS (COBALT-7492-FALCON@252,067tokens, ~50% depth) ·KL = 0.181–0.183vs. 52 GB BF16 teacher ·0NaNs · 100% exact greedy parity between pureM=1, Hybrid PLD+MTP, and v1.1 Vision server
Why This Release Exists
Uniform 1.58-bit dense quantization often trades away reasoning stability (run-on loops, constraint drift, excess token burn), while most long-context local builds either crush VRAM, spill to system RAM, or stall past 32k.
This build pairs a mixed-precision sparse MoE layout (google/gemma-4-26B-A4B-it, 25.2B total / 3.8B active parameters per token, 8/128 routed experts + 1 shared expert) with custom OpenCL kernels so the ~52 GB BF16 model runs end-to-end inside a single 16 GB Intel Arc A770 at full 262,144 context:
- Near-lossless mixed-precision weights (
KL = 0.181–0.183vs. 52 GB BF16 teacher):- 24 routed MoE layers: Intel BITCOS v5 mixed-ternary + unmerged rank-4 LoRA
- 6 sensitive MoE layers (
L10, L12, L13, L22, L27, L29): INT4 (OSV32) + unmerged rank-4 LoRA - Attention Q/K/V/O (30 layers): 100% INT8 (
OSV32custom OpenCL kernels) - Dense shared MLP &
lm_head: W4G64 (Gemma4MGUGeGLUOSV32F32/FullyConnectedCompressed) - Residual stream, routers, RMSNorms, RoPE: FP32
- 100% lossless Unified FP16 KV cache (
262,144tokens): 25 sliding layers (1,024window,ring-1280forM=4verification) + 5 global layers (262,144window) with zero KV quantization and zero VRAM growth past allocation. - Lossless Hybrid PLD + Split-K=128 MTP (
v1.0-sprint9.1): Combines anO(1)Prompt Lookup Decoding (PLD) scanner with a302.5 MBMulti-Token Prediction (MTP) assistant powered by 3 register-spill-free Split-K=128 OpenCL kernels—beating pureM=1at every single measured context from50to252,067tokens with exact greedy output parity.
Verified 256k Speed & Flat VRAM Curve (Single Intel Arc A770 16 GB)
Measured from an isolated cold start (GPU.0, empty OpenVINO cache, ctx=262144, temperature=0.0, OpenVINO 2026.4.1-63022 + custom OpenCL ops, 0 GPU Reorders, 0 NaNs). Defaults: --mtp auto --mtp-k 3 --pld auto --pld-k 5 --pld-ngram 5 --pld-min-ngram 5.
| Context | Prompt Toks | Prefill | Split-K=128 Hybrid PLD+MTP | Pure M=1 (--mtp "" --pld off) | Old 16-WG MTP | Tok / Step | MTP Acc (prop / bb) | PLD Acc (scan) | GPU.0 VRAM (ded / sh*) | 256k NIAH (~50%) |
|---|---|---|---|---|---|---|---|---|---|---|
Short (binary_search) | 50 | — | 104.43 tok/s (108.13 warm / 182.45 peak) | 80.89 tok/s | 108.13 tok/s | 3.61 | 85.2% (566 ms / 1881 ms) | 72.5% (1.3 ms) | 12.909 / 0.026 GB | — |
| 32k | 32,811 | 358.4 tok/s | 83.10 tok/s | 69.32 tok/s | 64.68 tok/s | 3.56 | 96.3% (533 ms / 1324 ms) | 34.5% (67.4 ms) | 12.919 / 0.026 GB | — |
| 64k | 65,588 | 312.8 tok/s | 76.28 tok/s | 64.90 tok/s | 47.58 tok/s | 3.64 | 91.0% (561 ms / 1469 ms) | 60.0% (66.3 ms) | 12.919 / 0.026 GB | — |
| 128k | 131,130 | 248.7 tok/s | 62.62 tok/s | 57.29 tok/s | 30.30 tok/s | 3.40 | 86.8% (618 ms / 1815 ms) | 50.0% (68.4 ms) | 12.919 / 0.026 GB | — |
| 192k | 196,665 | 206.2 tok/s | 54.72 tok/s | — | 22.67 tok/s | 3.48 | 88.6% (692 ms / 2160 ms) | 50.0% (68.2 ms) | 12.919 / 0.026 GB | — |
| 252k | 252,067 | 180.2 tok/s | 47.58 tok/s | 45.97 tok/s | 17.95 tok/s | 3.37 | 79.9% (934 ms / 2946 ms) | 67.9% (87.5 ms) | 12.919 / 0.026 GB | PASS |
*0.026 GB is the idle Windows GPU adapter driver baseline (0.000 GB model shared spill). All VRAM numbers use OpenVINO GPU_MEMORY_STATISTICS (usm_device / usm_shared) in decimal GB.
Cold first-ever OpenCL JIT compile: 226.2s boot + 56.3s M=128 warmup. Subsequent warm cache reloads: ~10–15s.
Throughput Perspective: Single Consumer GPU vs. Cloud APIs (Dec 2, 2026)
Decode speed & latency comparison only—Gemini 3.8 Flash is a closed, datacenter-hosted 1M-context frontier reasoning model. Numbers below show what single-card local OpenCL/OpenVINO decode looks like next to real-world cloud API serving speeds.
| Setup | Hardware / Host | Decode Speed | Short-Prompt Start | API Cost (In / Out per 1M) |
|---|---|---|---|---|
This Build (Pure M=1) | 1× Intel Arc A770 16 GB (Local) | 80.89 tok/s | ~0.71s prefill | $0 |
| This Build (Sprint 9.1 Hybrid PLD+MTP) | 1× Intel Arc A770 16 GB (Local) | 104.43–108.13 tok/s (up to 182.45 peak) | ~0.37s prefill | $0 |
| Gemini 3.8 Flash (OpenRouter Live) | Google AI Studio / Vertex Cloud | 66–74 tok/s P50 (82–96 avg) | 2.19–2.94s latency | $0.75 / $3.75 (doubles Jan 2027) |
| Gemini 3.8 Flash — High (Artificial Analysis) | Google Cloud TPUs | 99 tok/s (237–305 burst ceiling) | 24.63s TTFA (incl. thinking) | $0.75 / $3.75 (doubles Jan 2027) |
Sources: OpenRouter live provider telemetry (google/gemini-3.8-flash) and Artificial Analysis (gemini-3-8-flash), checked December 2, 2026. Cloud speeds vary by tier, region, load, and thinking effort.
v1.1 Multimodal Vision & .mp4 Video (gemma4_server.py)
gemma4_server.py now serves OpenAI-compatible multimodal /v1/chat/completions (image_url base64 data URI / HTTP URL / local path + video_url / .mp4 via OpenCV 1 fps sampling, auto-scaled to cap at <= 60 frames for clips > 60s with interleaved [0.0s], [1.0s] timestamp markers).
- Zero backbone regression: An in-memory graph rewrite replaces only the input embedding gather (
input_ids → inputs_embeds) at startup, splicing projected2816-dim vision embeddings intoM=128prefill chunks while leaving all BITCOS MoE, 256k FP16 KV, and Split-K=128 MTP kernels completely untouched. PLD and MTP automatically ignore media placeholder token IDs (255999,258880,258882,258884). - Flexible device placement (
--vision-device): Defaults toGPU.1(auto-falls back toGPU.0on single-GPU machines), or pass--vision-device GPU.0for all-in-one single-card execution,CPU, oroff. Sequentialbatch=1static[1, 2520, 768]execution prevents ViT activation spikes regardless of image/frame count. - Encoder parity vs.
vision_ref_io.npz(GPU.1):f32:cos_sim = 0.999346(mask_exact = True,0NaNs) ·f16(default):cos_sim = 0.995914(mask_exact = True,0NaNs,3.85sdriver-warm compile).
| Placement | Test | Vision Encode | Prefill | TTFT | Decode Speed | Active VRAM (Peak Ded / Sh) | Spill |
|---|---|---|---|---|---|---|---|
Single-Card GPU.0 (headless, 1× A770 16 GB) | Single Image (266 tok) | 234.6 ms | 942.8 ms | 1,177.4 ms | 96.69 tok/s | 14.031 GB (13.07 GiB) steady / 14.621 GB (13.62 GiB) peak / 0.059 GB sh | 0.000 GB |
Single-Card GPU.0 (headless, 1× A770 16 GB) | Multi-Image (2 imgs, 512 tok) | 317.6 ms | 1,510.1 ms | 1,827.7 ms | 98.35 tok/s | (same flat ceiling — 2.38 GiB free headroom) | 0.000 GB |
Single-Card GPU.0 (headless, 1× A770 16 GB) | 5s .mp4 Video (5 frm @ 70 tok) | 848.6 ms | 988.4 ms | 1,837.0 ms | 100.30 tok/s | (same flat ceiling — 0 NaNs, exact [0.0s]–[4.0s]) | 0.000 GB |
Single-Card GPU.0 (headless, 1× A770 16 GB) | Text-Only (binary_search) | 0 ms | 287.6 ms | 287.6 ms | 109.28 tok/s | 14.031 GB (13.07 GiB) / 0.059 GB sh | 0.000 GB |
Dual-Card GPU.0 + GPU.1 | Single / Multi / 5s Video / Text | 260 / 314 / 859 ms | 960 / 1454 / 964 ms | 1.26 / 1.77 / 1.82s | 103.90–117.83 tok/s | GPU.0: 13.12–13.72 GB (0.045 sh) · GPU.1: +0.90 GB (0.079 sh) | 0.000 GB |
Inside Sprint 9.1: Hybrid PLD + Split-K=128 MTP
Earlier 16-workgroup MTP global cross-attention left half of the Arc A770's 32 Xe-cores idle past 24k, causing draft time to balloon to 52.58 ms per token at 252k. Sprint 9.1 replaces it with three ocloc-verified (0 B register spill / 128 GRF / SIMD16) kernels in mtp/kernels/:
gemma4_mtp_q_norm_rope_global_k.cl— 16 WGs, fusedq_norm+ Proportional RoPE (0.25) +k_norm_wfolding (16 KBL2-hot output).gemma4_mtp_global_xattn_splitk128_reg.cl— GQA-8 Split-K=128 (256WGs = 8 WGs/Xe-core; 8 Q heads share KV per WG for8×less DRAM traffic; inactive splits exit on line 1;4.20 MBFP32 partial scratch).gemma4_mtp_global_reduce128_dyn.cl— Dynamic reduction across active splits only.
Standalone Split-K=128 Parity & 1-Draft Speedup vs. Old 16-WG (GPU.0, 5/5 PASS):
kv_len | proj_max_diff | top1_logit_diff | top1_match | NaNs | Zero-Copy 1-Draft (old → new) | Speedup |
|---|---|---|---|---|---|---|
256 | 0.031250 | 0.000000 | True | 0 | 2.68 → 2.69 ms | 0.99× |
4,096 | 0.039062 | 0.000000 | True | 0 | — | — |
65,536 | 0.027344 | 0.015625 | True | 0 | 16.21 → 5.21 ms | 3.11× |
131,072 | 0.031250 | 0.015625 | True | 0 | 30.14 → 5.14 ms | 5.86× |
252,000 | 0.023438 | 0.000000 | True | 0 | 52.58 → 5.98 ms | 8.79× |
- End-to-end 252k gain:
2.65×faster live decode (17.95 → 47.58 tok/s) and8.17×faster MTP propose (7,632 → 934 ms). - PLD CPU scan (
max_window=32768): FlatO(1)at~1.5–1.7 ms/stepacross32k → 252k(1.697 ms@ 32k,1.707 ms@ 64k,1.675 ms@ 128k,1.706 ms@ 192k,1.702 ms@ 252k).
BF16 Teacher Parity (0–32k) & Long-Context Recall (56k + 256k)
Direct comparison against the upstream 52 GB BF16 google/gemma-4-26B-A4B-it teacher measured via per-token KL divergence and top-1 agreement across 0–32k, plus live multi-needle and 256k NIAH recall:
| Gate Check | Reference / Target | Measured Result | NaNs | Status |
|---|---|---|---|---|
live_8k_qa (8,785 tok) | Step 7A FP16-KV Ref (KL 0.1807 · 85.4%) | KL 0.1814 · top-1 85.5% (PPL 1.26) | 0 | PASS |
live_28k_qa (29,419 tok) | Step 7A FP16-KV Ref (KL 0.1825 · 87.2%) | KL 0.1825 · top-1 87.2% (PPL 1.36) | 0 | PASS |
model_32k (8 × 4k bands) | KL 0.345–0.448 · 76.0–78.3% | KL 0.350–0.447 · top-1 76.0–78.1% (8/8) | 0 | PASS |
Sliding wrap 1016..1056 | [0.3134, 0.4471, 0.4122] | [0.3072, 0.4376, 0.4047] (no wrap spike) | 0 | PASS |
Live 56k 3-Needle Recall (55,092 in) | Start + Middle + End passcodes (think ON) | 3 / 3 exact (ORBIT-7741, COBALT-3319, ZENITH-9082) | 0 | PASS |
Live 256k NIAH (252,067 in, ~50% depth) | Single hidden needle (Split-K=128 Hybrid) | Exact verbatim recall (COBALT-7492-FALCON) · 180.2 tok/s read · 47.58 tok/s write · 12.919 GB VRAM | 0 | PASS |
Raw Unharnessed Benchmarks (50-Problem Dev Subsets, pass@1)
Settings: --think on --think-budget 0 (unlimited thinking), temperature=1.0, top_p=0.95, top_k=64, pure base decode (no repetition penalty). Because these are 50-problem dev subsets at pass@1, expect ±several percentage points of sampling variance.
Benchmark Suite (n = 50) | Official pass@1 | Correct | Wrong (fin=stop) | Cut Off (fin=length) | Finished Acc | Avg Think / Ans Tok | Loops |
|---|---|---|---|---|---|---|---|
IFEval-50 | 96.0% strict / 98.0% loose (instr: 97.5% / 98.75%) | 48 / 49 | 2 / 1 | 0 | 96.0% / 98.0% | 3,348 / 193 | 0 |
LiveCodeBench-50 (32k cap) | 62.0% (31 / 50) | 31 | 11 | 8 (7 hard, 1 med) | 31 / 42 (73.8%) | 10,212 / 5,556 | 2 |
LiveCodeBench-50 (64k cap) | 62.0% (31 / 50) | 31 | 18 | 1 (abc396_f @ 64,927 tok) | 31 / 49 (63.3%) | — | 1 |
- Difficulty breakdown (
LiveCodeBench-50): Our dev subset is 50% Hard (25hard,19medium,6easy) — Easy6/6(100%), Medium16/19(84.2%), Hard9/25(36.0%) — so it is not directly comparable to upstream's full LCB v6 difficulty mix (77.1%BF16). - Reproducibility:
IFEvalscored via unmodifiedgoogle-research/instruction_following_eval;LiveCodeBenchscored in sandboxed WSL Ubuntu 24.04 (unshare -rn python -I dev_lcb_eval.py).
Optimization Progression (4.02×–4.17× Short / 4.73× at 32k)
| Milestone | Short Decode | 32k | 64k | 128k | 252k | Flat VRAM | Key Engineering Change |
|---|---|---|---|---|---|---|---|
0. Original Custom Kernels (DQ=64, ScatterUpdate) | 25.95 tok/s | — | — | — | — | — | Initial custom BITCOS IR (1,143 ops, 540 Reorders, 0 NaNs) |
| 1. Step 6A (Nemotron OpenVINO Pattern + PR #39378) | 65.08 tok/s | 17.57 | — | — | — | — | DQ=0, in-place KV, 0 Reorders, eliminated synchronous CPU fallback waits |
2. Step 7A–7D (Pack3, MGU_GeGLU, OSV32, SplitK64) | 69.77 tok/s | 42.76 | — | — | — | 10.35 GB | Fused post-attn/FFN + OSV32 INT8 QKV/O & W4G64 shared MLP (350 ops) |
3. Step 7E-64k (BCF half4 Split-K=128, 64k FP16 KV) | 69.18 tok/s | 55.86 | 50.72 | — | — | 11.04 GB | Eliminated 8-way SLM bank conflict; lossless FP16 beat u8 KV |
4. Sprint 7 256k Top-64 (256-GRF UKV, 6L INT4 OSV32) | 72.65 tok/s | — | 59.48 | 52.60 | — | 13.20 GB | Full 262,144 Unified FP16 KV + GPU Top-64 + OSV32 QKV dedup |
5. Sprint 9.1 Pure M=1 | 80.89 tok/s | 69.32 | 64.90 | 57.29 | 45.97 | 12.60 GB | Sprint 9 kernel & memory optimizations (ring-1280 sliding KV) |
| 6. Sprint 9.1 Hybrid PLD+MTP + Split-K=128 (SHIPPED) | 104.43–108.13 tok/s (182.45 peak) | 83.10 | 76.28 | 62.62 | 47.58 | 12.92 GB | O(1) PLD + 3-kernel 0 B-spill Split-K=128 MTP (2.65× @ 252k vs 16-WG, exact parity) |
Upstream OpenVINO Contribution & Engineering Workflow
- Upstream OpenVINO PR: Eliminated synchronous host waits in OpenVINO GPU's
ReadValue/AssignCPU fallback on in-order queues inopenvinotoolkit/openvino#39378(merged upstream). - Multi-Agent Engineering Workflow: Directed by Jonathan (
TheSanchezian) using a builder + adversarial-reviewer loop—Gemini Neon built the custom OpenCL kernels, OpenVINO IR rewrites, server, and verification harnesses; Claude Opus acted as the independent adversarial reviewer enforcing the0–32kBF16 teacher KL/top-1 gates, auditing every optimization for precision/speed regressions, and stress-testing claims and packaging.
Quickstart & Self-Contained Package (Intel Arc Only)
This repository is a self-contained Windows / Intel Arc package (52 canonical files, full SHA-256 checksums in MANIFEST.md), including the bundled Apache-2.0 OpenVINO 2026.4.1-63022 wheel and matching openvino_intel_gpu_plugin.dll.
See README_run.md for full try-#1 Windows Python 3.12 setup instructions and CHANGELOG_sprint9.md for the complete Sprint 9.1 engineering log.
Launch Modes
-
Default (Recommended — Sprint 9.1 Hybrid PLD+MTP + v1.1 Vision, 256k context):
start_gemma4_server.bat(Runs
gemma4_server.pywith--ctx 262144 --mtp auto --mtp-k 3 --pld auto --pld-k 5 --pld-ngram 5 --pld-min-ngram 5 --vision-device GPU.1 --vision-tokens 280 --video-tokens 70. Automatically falls back toGPU.0on single-GPU systems.) -
Single-Card All-in-One (
GPU.0Backbone + MTP + Vision,13.62 GiBPeak VRAM):start_gemma4_server.bat --vision-device GPU.0 -
Text-Only Mode (Disable Vision,
12.92 GBVRAM):start_gemma4_server.bat --vision-device off -
Pure
M=1Base Decode (Zero Draft Heads,12.60 GBVRAM):python gemma4_server.py --ctx 262144 --mtp "" --pld off --vision-device off
Actively maintained Intel-only build—if you run into any setup or runtime issues on Intel Arc hardware, open a Discussion tab post and let me know.
Roadmap & Vision
This flagship BITCOS mixed-ternary MoE was built to prove that Ternary Hybrid Architectures work at high accuracy and full 256k context—demonstrating that architecture and custom kernel efficiency can bring cloud-tier decode speeds down from datacenters to a single consumer GPU.
Shipped:
- v1.0-sprint9.1: Full 256k lossless FP16 KV + Adaptive GQA-8 Split-K=128 Hybrid PLD+MTP (
104–108 tok/sshort,47.58 tok/s@ 252k,256kNIAH PASS). - v1.1-vision: Live OpenAI-compatible image, multi-image, and
.mp4video support ingemma4_server.py(vision_int8_ov,batch=1, fits single 16 GB A770 at13.62 GiBpeak with0.000 GBspill and zero text-only speed regression).
Next up:
- v2 Post-Distillation & Full Eval Suite: Upstream reasoning/agentic/multimodal benchmarks (
GPQA Diamond,AIME 2026,Tau2,OmniDocBench) for clean v1 vs. v2 A/B tracking. - MustacheOS: Live local orchestration and persistent-memory showcase running on top of this OpenAI-compatible server.