HiramKHackenbacker commited on
Commit
f9efe59
Β·
verified Β·
1 Parent(s): 1998b7e

docs: refresh measured performance (local retest 2026-08-18)

Browse files
Files changed (1) hide show
  1. README.md +121 -139
README.md CHANGED
@@ -18,19 +18,25 @@ tags:
18
  # Gemma 4 E4B β€” Core AI (.aimodel)
19
 
20
  `google/gemma-4-E4B-it-qat-q4_0-unquantized` converted to Core AI `.aimodel` bundles for
21
- Apple silicon by the [Visible](https://visible.cx) project. **Derivative artifacts**:
22
- Google's QAT-trained weights rounded onto the int4 grid they were trained for and
23
- re-expressed as a Core AI graph.
24
-
25
- Gemma 4 E4B uses **Per-Layer Embeddings**, so the working bundles here take a large
26
- embedding gather table as a *static graph input* rather than carrying it in the graph. That
27
- table ships in this repo (`ios-frontend/`) and **the bundles do not run without it** β€” see
28
- Contents and Requirements, because a missing table produces a bare input-arity error that
29
- mentions nothing about tables.
30
-
31
- This model does grammar-constrained structured output correctly (10/10 enum-clean on
32
- Visible's schema) and it is **slow and memory-bound on a 16 GB Mac**. Both facts are
33
- measured below.
 
 
 
 
 
 
34
 
35
  ## Provenance
36
 
@@ -44,7 +50,7 @@ measured below.
44
  | Producer fingerprint | `coreai-core 1.0.0b2` on every inner asset `metadata.json` |
45
  | Weight format | **int4, per-block-32** (`int4lin`, symmetric-with-clipping) β€” the ggml q4_0 grid the QAT checkpoint was trained on |
46
  | Vocab | 262,144 |
47
- | Conversion | 241 s / 44.0 GB peak RSS (decode); 196 s / 42.7 GB (pf64); Linux x86_64 |
48
 
49
  "QAT-unquantized" means QAT-*trained*, stored full width; the int4 rounding happens at
50
  export onto the grid training already targeted.
@@ -57,27 +63,29 @@ entrypoint, `prefill`, with a static query width of 64
57
 
58
  ### Bundles
59
 
60
- | Path | Bytes | Context | Functions | Status |
61
- |---|---:|---|---|---|
62
- | `gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64` | 3,989,986,858 | 4096 | main + prefill | the working bundle |
63
- | `ctx8192/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64` | 3,989,986,830 | 8192 | main + prefill | same weights, wider manifest |
64
- | `ctx16384/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64` | 3,989,986,844 | 16384 | main + prefill | same weights, wider manifest |
65
- | `gpu-pipelined/gemma4_e4b_qat_decode_int4lin` | 3,989,205,604 | 4096 | main | **BLOCKED β€” see below** |
66
- | `w4a8/gemma4_e4b_qat_decode_int4lin_a8_tbl_pf64` | 3,990,690,638 | 16384 | main + prefill | **EXPERIMENTAL β€” see below** |
67
 
68
  Each folder holds `<name>.aimodel/` (`main.mlirb` β‰ˆ 3.96 GB, `main.hash`, asset
69
  `metadata.json`), a bundle-level `metadata.json`, and `tokenizer/` (`tokenizer.json`
70
  32,169,626 B, `tokenizer_config.json`, `generation_config.json`, `chat_template.jinja`
71
- 18,569 B). The `w4a8` folder additionally ships its `calibration_corpus.jsonl`
72
- (35,045 B).
 
 
 
 
 
73
 
74
- **The three `_tbl_pf64` folders are the same weights.** `--max-ctx` does not change the
75
- exported graph β€” identical function signatures, identical state descriptors, identical
76
- export peak RSS at every value. It changes exactly one thing:
77
- `language.max_context_length` in the bundle manifest. This was proved with a same-config
78
- control re-export whose `main.mlirb` differed from its twin by *more* bytes than a
79
- 4096β†’8192 pair does. Pick the folder whose manifest integer matches the window you intend
80
- to run; a future context bump is a manifest edit, not a conversion.
81
 
82
  ### The PLE gather-table sidecar β€” required, not optional
83
 
@@ -96,26 +104,22 @@ to run; a future context bump is a manifest edit, not a conversion.
96
  | `meta.json` | 231 |
97
 
98
  Every `_tbl` bundle binds `ple_table` (from `embed_per_layer.i8`) and `ple_scale` (from
99
- `embed_per_layer.scale.f32`) as **static** graph inputs. Without them the bundle fails to
100
- load with a bare input-arity error naming `ple_table`/`ple_scale` and saying nothing about
101
- tables β€” a diagnosis this project got wrong once already. The sidecar is published here so
102
- the repo is self-contained for both loading and a pf64 rebuild.
103
 
104
  ## Requirements
105
 
106
  - **Apple silicon Mac**, Core AI runtime.
107
  - **Engine contract: 4 inputs** β€” `input_ids`, `position_ids`, plus the static `ple_table`
108
- and `ple_scale`. Two engines can take that:
109
  - **Pipelined engine** β€” binds the static inputs zero-copy over the caller's buffer, but
110
- **does not support logits**, so no grammar-constrained decoding.
111
- - **Sequential engine** β€” the only logits-capable engine, and therefore the only one
112
- guided decoding can run on. It requires the static-input binding that accepts `>= 2`
113
- inputs and binds everything beyond `input_ids`/`position_ids` from
114
- `EngineOptions.staticInputBuffers`; an extra input with no buffer is rejected by name.
115
- It pays a **one-time copy of every constant input at load β€” 2.69 GB for E4B** β€” because
116
- its submission path materialises a foreign buffer-backed view on every pass otherwise
117
- (measured: binding the table as a raw view drove peak footprint to 14.9 GB and
118
- segfaulted the runtime mid-prefill).
119
  - **States:** `keyCache` / `valueCache` `Float16, 24 Γ— 1 Γ— 2 Γ— ? Γ— 512`. Dynamic sequence
120
  dim β†’ `GrowingKVCache` (initial 256, doubling).
121
  - **KV cost: 98,304 bytes per token** (fp16) β€” 403 MB at 4096, 805 MB at 8192, 1.61 GB at
@@ -129,86 +133,96 @@ the repo is self-contained for both loading and a pf64 rebuild.
129
  | Base | **6.78 GB** |
130
  | Affordable context, fp16 KV | **~39,900 tokens** |
131
 
132
- So KV was never the ceiling at this tier β€” 16384 costs 1.61 GB against 3.92 GB of
133
- headroom. **The real constraint is the PLE table**, which dwarfs the KV cache at any
134
- context worth shipping. Measured peak footprint on a guided run was **10.7 GB**, i.e.
135
- right at the working-set edge.
136
- - **Run one E4B campaign per process.** Wired memory from a Gemma campaign is not reclaimed
137
- until the process exits; a second full E4B run in the same session drove wired memory to
138
- 13.2 GB and left the machine with 63 MB free.
 
139
  - Sliding-window note: E4B interleaves 20 sliding and 4 full attention layers across 42
140
  layers collapsed to 24 KV slots. The export models the window in the *mask*, not in
141
  memory β€” sliding layers ride full-length slots and zero-pad head_dim 256οΏ½οΏ½οΏ½512, so 83.3% of
142
- KV bytes sit in windowed slots and 41.7% is dead padding. A ring-buffered sliding cache
143
- would be ~6Γ— cheaper per token. That is model authoring, not a flag, and it is not needed
144
- at this tier.
145
- - `runtime_env COREAI_CHUNK_THRESHOLD=1` travels with the recipe. (Both engines now derive
146
- the static query width from the graph, so the older host-side rules about warmup length
147
- and chunk threshold are retired.)
148
 
149
- ## Measured performance
150
 
151
- Measured on a **16 GB M2 Pro Mac (macOS 27 beta)** with the out-of-process `coreai-repro`
152
- harness: 10 real enrichment rows (5 POST, 5 COMMENT), the app's live `app_litert` JSON
153
- schema, greedy decoding through `respondJSON(to:schema:)`, `reset()` per row, **sequential
154
- engine with the PLE tables bound as static inputs**, 128-token cap.
155
 
156
  `gemma4_e4b_qat_decode_int4lin_tbl_pf64`:
157
 
158
  | | |
159
  |---|---|
160
- | Load | 26.1 s |
161
  | Guided JSON parse | **10/10** |
162
  | Enum-clean | **10/10** |
163
- | s/row | **21.89** (POST) / **12.36** (COMMENT) |
164
- | Decode | 6.7–15.9 tok/s, mean **10.2** |
165
- | TTFT | 2.8–9.7 s |
166
- | Peak footprint | 10.7 GB |
167
- | Stop token | `<turn\|>`, clean self-stop on every row |
 
 
 
 
 
168
 
169
  **The grammar is close to free; prefill is the cost.** Decode throughput is essentially
170
- unchanged from unguided pipelined measurements (9.3–11.0 β†’ 10.2 tok/s). Guided rows cost
171
- ~25% more than unguided ones because the sequential engine's prefill is step-synchronous,
172
- not because of the constraint.
 
 
 
 
 
 
 
173
 
174
- **Enum conformance is entirely the grammar's doing, and it is decisive.** Unguided, this
175
- model invented an off-schema `motivation` value in **all ten** rows (`empowerment`,
176
- `advocacy`, `informative`…, none of them schema members). Guided, all ten are correct β€” not
177
- because the model improved, but because an off-enum token is unsamplable.
178
 
179
- **Context for the cost.** On the same harness and machine, LFM2.5-1.2B runs 1.77/1.30 s/row
180
- and Gemma 4 E2B runs 7.06/4.27. This bundle is roughly **12Γ— the 1.2B's cost per row** and
181
- is memory-bound at 10.7 GB peak. Published Mac figures of ~55.8 tok/s for E4B decode should
182
- be read as bigger-Mac figures.
183
 
184
- Nothing was measured above 4096 tokens. The `ctx8192`/`ctx16384` folders carry the 4096
185
- graph, so throughput should be unchanged, but quality at depth is a real open question:
186
- beyond ~4k the long-range signal rides on 4 full-attention layers, and widening the manifest
187
- does not widen the sliding layers' 512-token window.
188
 
189
- ## Qualification status
 
 
 
 
 
 
190
 
191
  | Artifact | Status |
192
  |---|---|
193
- | `gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64` (ctx 4096) | **QUALIFIED β€” measured, viable, not a default.** 10/10 parse, 10/10 enum-clean on the harness above. Slow and memory-bound at the 16 GB tier; it earns a slot only where Gemma's output specifically is wanted. |
194
- | `ctx8192/…_tbl_pf64` | **QUALIFIED BY EQUIVALENCE, UNMEASURED AT DEPTH** β€” same weights, same graph, wider manifest integer. No run above 4096 tokens. |
195
- | `ctx16384/…_tbl_pf64` | **QUALIFIED BY EQUIVALENCE, UNMEASURED AT DEPTH** β€” as above. |
196
- | `w4a8/gemma4_e4b_qat_decode_int4lin_a8_tbl_pf64` | **EXPERIMENTAL β€” built, unmeasured.** Gate: a Mac-side oracle/parity check plus a device benchmark, neither of which has been run. Do not route production traffic to it. |
197
- | `gpu-pipelined/gemma4_e4b_qat_decode_int4lin` | **BLOCKED β€” does not load on any current code path.** |
198
 
199
  ### About the `w4a8` bundle
200
 
201
  Same QAT int4 per-block-32 weights and the same graph as
202
  `gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64`; the difference is an int8
203
  quantize/dequantize pair on the inputs of every `F.linear`, calibrated on 128 synthetic
204
- social-media-style samples (the corpus ships in the folder). It was built as a prefill/TTFT
205
- lever, and its manifest context is 16384.
206
 
207
- The caveat is load-bearing and comes from the compression toolchain's own documentation: the
208
- runtime fast path is `W_INT8 Γ— A_INT8`, and a float weight path executes in floating point
209
- *regardless* of activation quantization. These weights use int4 scale-multiply dequant, not
210
- an int8 LUT, so the expected TTFT gain may be **zero or negative**. This bundle exists to be
211
- measured, not because a win is predicted.
212
 
213
  ### Why the non-`tbl` decode bundle is blocked
214
 
@@ -219,43 +233,16 @@ LOAD FAILED: invalidInputType("Expected 2 inputs, got 3:
219
  [\"input_ids\", \"position_ids\", \"ple_tokens\"]")
220
  ```
221
 
222
- `ple_tokens`, not `ple_table`/`ple_scale`. The Gemma architecture description in the kit
223
- knows only the pair (`ple_table` β†’ `embed_per_layer.i8`, `ple_scale` β†’
224
- `embed_per_layer.scale.f32`), so **no code path binds `ple_tokens`** and the table sidecar
225
- in this repo does not help. It is unusable as exported. The fix is a re-export with `--tbl`
226
- so E4B decode and prefill are the same graph family, not an extension to the kit; until
227
- then, use the `_tbl_pf64` bundle, which is a strict superset (it carries both `main` and
228
- `prefill`).
229
-
230
- It is kept published rather than deleted because it is a fingerprinted, immutable artifact
231
- that earlier revisions pin, and because the failure it demonstrates is worth documenting.
232
-
233
- ## Verification
234
-
235
- - **Producer fingerprint:** every inner `<name>.aimodel/metadata.json` reads
236
- `producer: "coreai-core 1.0.0b2"`. `coreai-torch 0.4.0` / `coreai-core 1.0.0b1` produce
237
- ODIE-poisoned bundles that abort **in-process** at load, taking the host application down
238
- uncatchably. The field is in the **inner asset** metadata; the bundle manifest never
239
- carries a `producer` field, so checking the manifest condemns every good bundle.
240
- - **Stop token, verified per folder:** all four declare `eos_token = "<turn|>"`. Gemma 4
241
- ends a *turn* with `<turn|>` (id 106); the raw upstream `<eos>` ends the whole sequence,
242
- and a host stopping on it overruns every reply. The exporter copies the upstream tokenizer
243
- config verbatim and does **not** apply this correction β€” it is a post-export patch, and it
244
- was checked on these bundles rather than assumed. `generation_config.json` independently
245
- lists `eos_token_id: [1, 106, 50]`.
246
- - **`pf64` is worth 7.7Γ— on time-to-first-token, measured.** The A/B was run on the E2B
247
- sibling (same prompt, same weights, differing only in whether the `prefill` function was
248
- exported): TTFT 35.74 s β†’ 4.65 s, s/row 45.04 β†’ 8.83. The non-`pf64` variant also failed
249
- partway through a ten-row campaign with the runtime's footprint ballooning past 37 GB
250
- across ~2,800 single-token passes β€” it is not merely slower, it is not durable. Prefer
251
- `_pf64` everywhere; that is why no plain `_tbl` E4B bundle exists here.
252
- - **Determinism:** `.aimodel` conversion is not byte-reproducible; the same command twice on
253
- one box gives different `main.mlirb` bytes. Integrity rests on per-file SHA-256 of the
254
- exact published artifact, never on rebuilding.
255
- - **No oracle gate has been run on this model.** The 10/10 results above are behavioural
256
- (parse rate, enum conformance, clean stop) on Visible's own task. A decode oracle against
257
- an fp32 reference β€” the gate that would catch an int4 or kernel-level numerics error β€” has
258
- not been run on any Gemma 4 bundle in this catalog.
259
 
260
  ## License
261
 
@@ -266,9 +253,4 @@ model and **the Gemma terms apply downstream**, which is why this repo declares
266
  [Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy) and the
267
  [Gemma 4 license](https://ai.google.dev/gemma/docs/gemma_4_license). Those obligations
268
  travel with any redistribution of these bundles, including the gather-table sidecar, which
269
- is derived from the same weights. Visible's contribution is the conversion, not the weights.
270
-
271
- ---
272
-
273
- *Additional variants may land in this repo after this card was written; the tables above
274
- describe its contents as listed at the time of writing.*
 
18
  # Gemma 4 E4B β€” Core AI (.aimodel)
19
 
20
  `google/gemma-4-E4B-it-qat-q4_0-unquantized` converted to Core AI `.aimodel` bundles for
21
+ Apple silicon by [visible-cx](https://huggingface.co/visible-cx). These are derivative
22
+ artifacts: Google's QAT-trained weights rounded onto the int4 grid they were trained for
23
+ and re-expressed as a Core AI graph. They load through Core AI on macOS and are not usable
24
+ by PyTorch, GGUF or MLX.
25
+
26
+ Gemma 4 E4B uses **Per-Layer Embeddings**, so the working bundles take a large embedding
27
+ gather table as a *static graph input* rather than carrying it in the graph. That table
28
+ ships in `ios-frontend/` and **the bundles do not load without it**; a missing table
29
+ produces a bare input-arity error naming `ple_table`/`ple_scale`.
30
+
31
+ > ⚠️ **Known issue β€” unguided generation.** On the current reference engine
32
+ > implementation, free-form (unguided) decoding exhibits unbounded Metal memory growth:
33
+ > approximately **80 MB of process `phys_footprint` per generated token**, on both the
34
+ > sequential and pipelined engines, scaling with prompt length. E4B is the more severe of
35
+ > the two Gemma variants: 16.91 GB after 64 generated tokens at 3.4k of context, and
36
+ > 31.33 GB after 32 tokens at 8k. **Constrained/guided decoding is unaffected** and
37
+ > plateaus at 8–10 GB. A fix is in progress. Until it lands, use these bundles for
38
+ > guided/constrained generation only. A fixed token cap is not a reliable mitigation,
39
+ > because the safe cap shrinks as the prompt grows.
40
 
41
  ## Provenance
42
 
 
50
  | Producer fingerprint | `coreai-core 1.0.0b2` on every inner asset `metadata.json` |
51
  | Weight format | **int4, per-block-32** (`int4lin`, symmetric-with-clipping) β€” the ggml q4_0 grid the QAT checkpoint was trained on |
52
  | Vocab | 262,144 |
53
+ | Export functions | `main` (S=1 decode) and, in `_pf64` bundles, `prefill` (S=64 chunked prefill) |
54
 
55
  "QAT-unquantized" means QAT-*trained*, stored full width; the int4 rounding happens at
56
  export onto the grid training already targeted.
 
63
 
64
  ### Bundles
65
 
66
+ | Path | Bytes | Context | Functions |
67
+ |---|---:|---|---|
68
+ | `gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64` | 3,989,986,858 | 4096 | main + prefill |
69
+ | `ctx8192/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64` | 3,989,986,830 | 8192 | main + prefill |
70
+ | `ctx16384/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64` | 3,989,986,844 | 16384 | main + prefill |
71
+ | `gpu-pipelined/gemma4_e4b_qat_decode_int4lin` | 3,989,205,604 | 4096 | main β€” **does not load**, see Status |
72
+ | `w4a8/gemma4_e4b_qat_decode_int4lin_a8_tbl_pf64` | 3,990,690,638 | 16384 | main + prefill |
73
 
74
  Each folder holds `<name>.aimodel/` (`main.mlirb` β‰ˆ 3.96 GB, `main.hash`, asset
75
  `metadata.json`), a bundle-level `metadata.json`, and `tokenizer/` (`tokenizer.json`
76
  32,169,626 B, `tokenizer_config.json`, `generation_config.json`, `chat_template.jinja`
77
+ 18,569 B). The `w4a8` folder additionally ships its `calibration_corpus.jsonl` (35,045 B).
78
+
79
+ **The three `_tbl_pf64` folders hold the same weights and the same graph.** `--max-ctx`
80
+ changes exactly one thing: `language.max_context_length` in the bundle manifest. Function
81
+ signatures, state descriptors and export peak RSS are identical at every value. Pick the
82
+ folder whose manifest integer matches the window you intend to run; a context bump is a
83
+ manifest edit, not a conversion.
84
 
85
+ **Stop token:** every bundle declares `eos_token = "<turn|>"` (id 106), which is the turn
86
+ terminator Gemma 4 emits. `generation_config.json` independently lists
87
+ `eos_token_id: [1, 106, 50]`. A host that stops on the raw upstream `<eos>` instead will
88
+ overrun every reply.
 
 
 
89
 
90
  ### The PLE gather-table sidecar β€” required, not optional
91
 
 
104
  | `meta.json` | 231 |
105
 
106
  Every `_tbl` bundle binds `ple_table` (from `embed_per_layer.i8`) and `ple_scale` (from
107
+ `embed_per_layer.scale.f32`) as **static** graph inputs.
 
 
 
108
 
109
  ## Requirements
110
 
111
  - **Apple silicon Mac**, Core AI runtime.
112
  - **Engine contract: 4 inputs** β€” `input_ids`, `position_ids`, plus the static `ple_table`
113
+ and `ple_scale`. Two engines accept that:
114
  - **Pipelined engine** β€” binds the static inputs zero-copy over the caller's buffer, but
115
+ does not support logits, so no grammar-constrained decoding.
116
+ - **Sequential engine** β€” the only logits-capable engine, and therefore the only path for
117
+ guided decoding. It accepts `>= 2` inputs and binds everything beyond
118
+ `input_ids`/`position_ids` from `EngineOptions.staticInputBuffers`; an extra input with
119
+ no buffer is rejected by name. It pays a **one-time copy of every constant input at
120
+ load β€” 2.69 GB for E4B**, because its submission path otherwise materialises a foreign
121
+ buffer-backed view on every pass. Binding the table as a raw view instead drives peak
122
+ footprint to 14.9 GB and faults the runtime mid-prefill.
 
123
  - **States:** `keyCache` / `valueCache` `Float16, 24 Γ— 1 Γ— 2 Γ— ? Γ— 512`. Dynamic sequence
124
  dim β†’ `GrowingKVCache` (initial 256, doubling).
125
  - **KV cost: 98,304 bytes per token** (fp16) β€” 403 MB at 4096, 805 MB at 8192, 1.61 GB at
 
133
  | Base | **6.78 GB** |
134
  | Affordable context, fp16 KV | **~39,900 tokens** |
135
 
136
+ KV is not the ceiling at this tier; the PLE table is. Measured peak footprint on a guided
137
+ run: **9.99 GB**, max RSS 9.63 GB β€” right at the working-set edge. **Minimum practical
138
+ machine memory: 16 GB with nothing else resident**, for guided decoding only; 24 GB or
139
+ more is the comfortable tier. Free-form generation does not fit this envelope on any
140
+ machine β€” see the known issue above.
141
+ - **Run one E4B session per process.** Wired memory is not reclaimed until the process
142
+ exits; a second full run in the same process drives wired memory to 13.2 GB on a 16 GB
143
+ machine.
144
  - Sliding-window note: E4B interleaves 20 sliding and 4 full attention layers across 42
145
  layers collapsed to 24 KV slots. The export models the window in the *mask*, not in
146
  memory β€” sliding layers ride full-length slots and zero-pad head_dim 256οΏ½οΏ½οΏ½512, so 83.3% of
147
+ KV bytes sit in windowed slots and 41.7% is dead padding.
148
+ - The bundle manifest declares `runtime_env COREAI_CHUNK_THRESHOLD=1`. Both engines derive
149
+ the static query width from the graph.
 
 
 
150
 
151
+ ## Performance
152
 
153
+ Measured on a **16 GB Apple silicon Mac (M2 Pro, macOS 27 beta)**: 10-sample harness,
154
+ guided JSON-constrained decoding against a fixed schema, greedy, sequential engine with the
155
+ PLE tables bound as static inputs, `reset()` between samples, 128-token cap. Load excluded
156
+ from `s/row`; sample 1 excluded as a cache-warm outlier.
157
 
158
  `gemma4_e4b_qat_decode_int4lin_tbl_pf64`:
159
 
160
  | | |
161
  |---|---|
162
+ | Load | 16.7 s |
163
  | Guided JSON parse | **10/10** |
164
  | Enum-clean | **10/10** |
165
+ | s/row (long samples) | **14.70** |
166
+ | s/row (short samples) | **5.93** |
167
+ | Decode | **9.5–26.4 tok/s** (mean 17.8) |
168
+ | TTFT | **1.23–6.51 s** |
169
+ | Peak footprint | 9.99 GB |
170
+ | Max RSS | 9.63 GB |
171
+ | Stop token | `<turn\|>`, clean self-stop on every sample |
172
+
173
+ E4B is memory-bound at the 16 GB tier, and its per-sample cost is sensitive to what else is
174
+ resident on the machine β€” expect roughly 2Γ— these figures when the model has to share.
175
 
176
  **The grammar is close to free; prefill is the cost.** Decode throughput is essentially
177
+ unchanged from unguided pipelined measurements. Guided samples cost ~25% more than unguided
178
+ ones because the sequential engine's prefill is step-synchronous, not because of the
179
+ constraint.
180
+
181
+ **Enum conformance is entirely the grammar's doing.** Unguided, this model emits an
182
+ off-schema enum value in all ten samples. Guided, all ten are correct, because an off-enum
183
+ token is unsamplable.
184
+
185
+ Published Mac figures of ~55.8 tok/s for E4B decode should be read as larger-machine
186
+ figures.
187
 
188
+ ### Unguided workload β€” memory-capped
 
 
 
189
 
190
+ Free-form generation from a fixed prompt. **Every generation length below is a memory cap,
191
+ not a model stop** β€” see the known issue.
 
 
192
 
193
+ | depth | prompt tokens | TTFT | decode | generated | wall | peak footprint |
194
+ |---|---|---|---|---|---|---|
195
+ | 3.4k | 3314 | 68.46 s | 0.78 tok/s | 64 (capped) | 151.6 s | **16.91 GB** |
196
+ | 8k | 7907 | 159.1 s | 0.52 tok/s | 32 (capped) | 218.8 s | **31.33 GB** |
197
 
198
+ Output quality up to the cap is sound; the limit is memory, not capability.
199
+
200
+ **Needle-in-haystack recall at 8k: β‰₯2/3.** Three distinctive facts planted at 10/50/90% of
201
+ the filler; the 32-token memory cap truncated the answer mid-fact-2, so fact 3 was never
202
+ reachable. 15k was not attempted.
203
+
204
+ ## Status
205
 
206
  | Artifact | Status |
207
  |---|---|
208
+ | `gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64` (ctx 4096) | **QUALIFIED FOR GUIDED GENERATION** β€” measured: 10/10 parse, 10/10 enum-clean, 14.70/5.93 s/row, 9.5–26.4 tok/s, 9.99 GB peak footprint. Not qualified for free-form generation on the current reference engine implementation. |
209
+ | `ctx8192/…_tbl_pf64` | **QUALIFIED BY EQUIVALENCE** β€” same weights and graph, wider manifest integer. Free-form at this depth is measured-unsafe (31.33 GB under a 32-token cap). |
210
+ | `ctx16384/…_tbl_pf64` | **QUALIFIED BY EQUIVALENCE** β€” as above; free-form at this depth was not attempted. |
211
+ | `w4a8/gemma4_e4b_qat_decode_int4lin_a8_tbl_pf64` | **EXPERIMENTAL** β€” built, unmeasured. Gate: a Mac-side oracle/parity check plus a device benchmark. |
212
+ | `gpu-pipelined/gemma4_e4b_qat_decode_int4lin` | **BLOCKED** β€” does not load on any current code path. |
213
 
214
  ### About the `w4a8` bundle
215
 
216
  Same QAT int4 per-block-32 weights and the same graph as
217
  `gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64`; the difference is an int8
218
  quantize/dequantize pair on the inputs of every `F.linear`, calibrated on 128 synthetic
219
+ samples (the corpus ships in the folder). Manifest context 16384.
 
220
 
221
+ The caveat comes from the compression toolchain's own documentation: the runtime fast path
222
+ is `W_INT8 Γ— A_INT8`, and a float weight path executes in floating point *regardless* of
223
+ activation quantization. These weights use int4 scale-multiply dequant, not an int8 LUT, so
224
+ the expected TTFT gain may be zero or negative. This bundle exists to be measured, not
225
+ because a win is predicted.
226
 
227
  ### Why the non-`tbl` decode bundle is blocked
228
 
 
233
  [\"input_ids\", \"position_ids\", \"ple_tokens\"]")
234
  ```
235
 
236
+ `ple_tokens`, not `ple_table`/`ple_scale`. The Gemma architecture description in the
237
+ runtime knows only the pair (`ple_table` β†’ `embed_per_layer.i8`, `ple_scale` β†’
238
+ `embed_per_layer.scale.f32`), so no code path binds `ple_tokens` and the table sidecar does
239
+ not help. Use the `_tbl_pf64` bundle, which is a strict superset (it carries both `main`
240
+ and `prefill`). The bundle is retained because it is an immutable artifact that earlier
241
+ revisions pin.
242
+
243
+ **No numerics gate has been run on any bundle in this repo.** The 10/10 results are
244
+ behavioural (parse rate, enum conformance, clean stop); a decode oracle against an fp32
245
+ reference has not been run.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
 
247
  ## License
248
 
 
253
  [Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy) and the
254
  [Gemma 4 license](https://ai.google.dev/gemma/docs/gemma_4_license). Those obligations
255
  travel with any redistribution of these bundles, including the gather-table sidecar, which
256
+ is derived from the same weights. The contribution here is the conversion, not the weights.