Views
No views yet
google/gemma-4-E2B-it. KV cache lives inside ANE via MLState + slice_update so the recurrent KV plumbing of the legacy bundle (see mlboydaisuke/gemma-4-E2B-coreml) is gone — Core ML manages the cache implicitly. Same model, smaller phys_footprint, faster cold start.chunk_1.mlmodelc/ # 155 MB weights — embed + L0–7
chunk_2.mlmodelc/ # 459 MB weights — L8–24 (merged middle)
chunk_3.mlmodelc/ # 527 MB weights — L25–34 + lm_head
embed_tokens_q8.bin 402 MB — INT8 token embeddings (262144 × 1536)
embed_tokens_scales.bin 512 KB
embed_tokens_per_layer_q8.bin 2.35 GB — INT8 PLE
embed_tokens_per_layer_scales.bin 512 KB
per_layer_projection.bin 27.5 MB
per_layer_norm_weight.bin 1 KB
cos_{full,sliding}.npy 8 MB / 4 MB — precomputed RoPE cos
sin_{full,sliding}.npy 8 MB / 4 MB — precomputed RoPE sin
model_config.json 620 B — runtime config
hf_model/{tokenizer.json, tokenizer_config.json, config.json}.mlmodelc chunks declare MLState inputs internally, so the Swift runtime only needs to call make_state() once per chunk and pass the same state object back on each step.phys_footprint. We mmap the raw bytes and dequant the few rows touched per token in pure Swift. That keeps the on-device footprint at ~700 MB resident even with the full PLE on disk.hf_model/. Or pull from upstream:1from transformers import AutoTokenizer
2tok = AutoTokenizer.from_pretrained("google/gemma-4-E2B-it")1from huggingface_hub import snapshot_download
2import coremltools as ct, json, numpy as np
3
4local = snapshot_download("mlboydaisuke/gemma-4-E2B-stateful-coreml")
5cfg = json.load(open(f"{local}/model_config.json"))
6
7chunks = [
8 ct.models.MLModel(f"{local}/chunk_{i}.mlmodelc")
9 for i in (1, 2, 3)
10]
11states = [m.make_state() for m in chunks]
12
13# RoPE tables (concrete arrays, no builder needed):
14cos_full = np.load(f"{local}/cos_full.npy")
15cos_sliding = np.load(f"{local}/cos_sliding.npy")Sources/CoreMLLLM/Gemma4StatefulEngine.swift — mirror it in Python by passing each chunk's state object through every predict(...) call.CoreMLLLMChat — it auto-downloads this repo and runs it via Gemma4StatefulEngine.| value | |
|---|---|
num_hidden_layers | 35 |
hidden_size | 1536 |
num_key_value_heads | 1 |
intermediate_size | 6144 |
num_kv_shared_layers | 20 |
| KV producers (sliding/full) | L13 / L14 |
| sliding window | 512 |
| context length | 1024 |
| vocab | 262144 |