BuboAI's picture
Upload BuboCoreML v1 pre-compiled stateless Delta-KV ANE bundle
1c760bf verified
|
Raw History Blame Contribute Delete
3.39 kB
---
license: gemma
base_model: google/gemma-4-E4B-it
tags:
- coreml
- apple-neural-engine
- gemma4
- vision-language-model
- multimodal
- ios
- stateless
---
# Gemma 4 E4B Vision β€” Compact CoreML (Stateless ANE, Unified T=16)
A compact, storage- and memory-friendly **100% stateless CoreML** conversion of [`google/gemma-4-E4B-it`](https://huggingface.co/google/gemma-4-E4B-it) engineered for **Apple Neural Engine (ANE)** execution on 8 GB iPhones (iPhone 15 Pro, iPhone 16 / 16 Pro / 17 series) and Apple Silicon Macs.
## Why This Compact Variant?
Compared to dual-function (`multifunction`) CoreML LLM bundles, this variant uses a **single unified `T=16` graph per chunk** plus **weight-sensitivity-guided mixed INT4/INT6 palettization (`exact kmeans1d`)**:
- **~50% smaller on-device ANE compilation cache (`e5bundlecache`)**: ~2.4 GB instead of ~6.8 GB, because CoreML compiles one function per chunk instead of duplicating weights for separate `decode` and `prefill` functions.
- **Smaller download**: **5.04 GB** total (down from 5.75 GB), with ~3.58 GB active runtime footprint when text-only.
- **Zero `MLState` ops**: Uses explicit Delta-KV tensor I/O (`past_k/v` + `new_k/v`) so ANE compilation succeeds cleanly across iOS 18–27 and supports locked-screen / background execution.
- **Lazy Vision Encoder**: `vision_encoder.mlmodelc` (480Γ—480 β†’ 100 soft visual tokens) stays unloaded (0 MB RAM) until an image is attached.
- **Minimal quality delta**: Sensitive first/last transformer chunks (`chunk_0` layers 0–5 and `chunk_6` layers 36–41), `lm_head`, `ple_proj`, and `vision_encoder` are kept at **INT6**, while middle transformer chunks (`chunk_1`–`chunk_5`, layers 6–35) use **exact 1D k-means (`kmeans1d` C++ DP) INT4 palettization** (`group_size=32`).
## Quantization Layout
| Component | Precision | Method | Notes |
| --- | --- | --- | --- |
| `chunk_0` (L00–L05) | INT6 | Palettize (`kmeans1d`, g32) | Highest outlier ratio (20.2Γ—) preserved at INT6 |
| `chunk_1`–`chunk_5` (L06–L35) | INT4 | Palettize (`kmeans1d`, g32) | Optimal 1D k-means LUTs per 32-element group |
| `chunk_6` (L36–L41) | INT6 | Palettize (`kmeans1d`, g32) | Final residual & output projection preserved at INT6 |
| `lm_head_0..3` (4 slices) | INT6 | Palettize (`fast_kmeans`, g32) | 262,144 vocab split into 4 Γ— 65,536 |
| `ple_proj` | INT6 | Palettize (`fast_kmeans`, g32) | Per-Layer Embeddings projection |
| `vision_encoder` | INT6 | Palettize (`fast_kmeans`, g32) | Lazy 480Γ—480 β†’ 100 soft tokens |
| `embed_tokens_q8.bin` | INT8 | Row-wise symmetric | External CPU table (640 MB) |
| `embed_ple_q4.bin` | INT4 | Row-wise packed | External CPU PLE table (1.3 GB) |
## Technical Specs
- **Format**: Pre-compiled `.mlmodelc` packages (`MLComputeUnits.cpuAndNeuralEngine`)
- **Execution Mode**: `unified` (`prefill_batch_size = 16`, `decode_batch_size = 16`, default function `nil`)
- **Context Length**: `2048` (512 sliding-window local layers + 2048 global attention layers, 18 KV-shared upper layers)
- **Total Bundle Size**: `5.04 GB` (`5,037,283,477` bytes)
- **Recommended Device**: iPhone with β‰₯ 8 GB RAM and β‰₯ 3.5 GB free storage beyond the model download for first-run ANE specialization.
## License
Derived from Google's `google/gemma-4-E4B-it`. Usage is governed by the [Gemma Terms of Use](https://ai.google.dev/gemma/terms).