--- license: gemma base_model: google/gemma-4-E4B-it tags: - coreml - apple-neural-engine - ane - gemma4 - vision - multimodal - quantized - int6 --- # Gemma 4 E4B Vision — Stateless CoreML (Apple Neural Engine) Pre-compiled, **100% stateless Apple Neural Engine (ANE)** CoreML bundle of [`google/gemma-4-E4B-it`](https://huggingface.co/google/gemma-4-E4B-it) with **high-accuracy INT6 LUT palettization**, **Delta-KV batched prefill (`T=64`)**, and **lazy on-demand Vision encoding**. ## Highlights - **Zero `MLState` ops** — Pure stateless explicit-I/O Delta-KV attention across all compiled `.mlmodelc` graphs; reliable across iOS 18–27 and compatible with locked-screen / background ANE execution (zero Metal GPU dependency). - **High-Accuracy Mixed-Precision INT6 Quantization (`5.75 GB` total)**: - `ple_proj`, `chunk_0..5` (layers 0–35), `lm_head_0..3` (4 vocab slices), and `vision_encoder`: **INT6 (`fast_kmeans`, `group_size=32`)** — deterministic `D²`-weighted k-means++ LUT palettization preserving outlier channels. - `chunk_6` (layers 36–41, final KV-shared layers): **INT6 (`kmeans`, `group_size=32`)** — globally optimal C++ `kmeans1d` LUT palettization (`0.9985` cosine vs FP16). - Token embeddings: mmap `INT8` (`embed_tokens_q8.bin`, zero active RAM). - Per-Layer Embeddings (PLE): mmap `INT4` (`embed_ple_q4.bin`, zero active RAM). - **Weight-Sharing Multifunction Graphs (`prefill` `T=64` + `decode` `T=1`)**: - Fast batched prompt processing on ANE (up to `500+ tok/s` on A18 Pro) while sharing a single `weight.bin` per chunk. - Supports chunk-major streaming prefill to keep active iOS memory usage low (~3.4 GB). - **Lazy On-Demand Vision (`vision_encoder.mlmodelc`)**: - Standalone `480×480 → 100 soft tokens` ViT encoder (`INT6`). Stays unloaded (`0 MB` RAM) during text-only chat and loads on demand when an image is attached. - **Native Gemma 4 Architecture Support**: - Heterogeneous sliding (`head_dim=256`, `window=512`, `theta=10,000`) + full (`global_head_dim=512`, proportional `0.25` RoPE, `theta=1,000,000`) attention. - Native KV-sharing for the upper 18 layers (`layers 24–41`). - Native thinking (`<|channel>thought` / ``) and multilingual instruction-tuned (`IT`) capabilities from `google/gemma-4-E4B-it`. ## Bundle Layout | File | Description | | --- | --- | | `model_config.json` | Manifest (`bubo_coreml_v1`, `kv_mode: delta`, `architecture_family: gemma4`) | | `ple_proj.mlmodelc` | Per-Layer Embedding projector (`decode` + `prefill` `T=64`, INT6) | | `chunk_0..6.mlmodelc` | 7 weight-sharing multifunction transformer chunks (layers 0–41, INT6) | | `lm_head_0..3.mlmodelc` | 4 vocab-sliced LM head chunks (262,144 vocab, INT6) | | `vision_encoder.mlmodelc` | Lazy on-demand Vision encoder (`480×480 → 100` soft tokens, INT6) | | `embed_tokens_q8.bin` + `embed_tokens_scales.bin` | Zero-RAM mmap INT8 token embeddings | | `embed_ple_q4.bin` + `embed_ple_scales.bin` | Zero-RAM mmap INT4 Per-Layer Embeddings | | `hf_model/` | Tokenizer & Hugging Face model metadata | ## License Derived from [`google/gemma-4-E4B-it`](https://huggingface.co/google/gemma-4-E4B-it) and subject to the [Gemma Terms of Use](https://ai.google.dev/gemma/terms).