Skip to content

Commit 711ae16

Browse files
docs(adr0014): root-cause Mac batched-recall break — ruled out RotatingKVCache/rotation + cache type; it's an upstream mlx_lm gemma-4 batch>1 decode bug (prefill correct, decode diverges, cache-independent)
Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>
1 parent d0cd21f commit 711ae16

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

docs/adr/0014-agent-connection-capacity-and-cross-host-topology-tests.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,29 @@ batching) — recall is the bottom line. Note also the Mac speedup ceiling is lo
266266
even nominally (M4 saturates at small batch — 2.7× vs CUDA's 8.45×). The
267267
validated batched scheduler is **CUDA-only** today.
268268

269+
**Root-cause of the Mac batched-recall break (investigated).** The
270+
`RotatingKVCache` / sliding-window-mask line was investigated and **ruled out**:
271+
272+
| Mac diagnostic | batched per-session recall | what it isolates |
273+
| --- | --- | --- |
274+
| short prompt (ctx 339 < sliding window → **no rotation**) | 0.25 | **not** rotation |
275+
| concat-based Kakeya `SinkWindowKVCache` (no in-place buffer assign) | 0.25 | **not** the cache (in-place or concat) |
276+
| per-row first decoded token vs serialized | **matches** (all rows) | batched **prefill is correct** |
277+
278+
So the break is **cache-independent and prefill-correct**: batched **decode**
279+
diverges only *after* the first token, with both mlx_lm's in-place cache and
280+
Kakeya's concat cache. That localizes it to **mlx_lm 0.31.3's gemma-4
281+
batched (batch>1) decode forward** (RoPE-offset / mask / shared-KV path), an
282+
**upstream MLX limitation** — not a Kakeya cache or rotation issue, and not
283+
present on CUDA (HF transformers batched decode is correct → §3.5/§3.7's 8.04×
284+
/ 8.45×, recall 1.0). Evidence:
285+
`results/research/k3_mlx_batched_{diag_short,kakeya_cache}_mac.json`.
286+
287+
**Status:** recall-safe Mac multi-tenant = **serialized** (recall 1.0). Mac
288+
**batched** throughput needs an upstream mlx_lm gemma-4 batched-decode fix (or a
289+
custom batched gemma decode kernel) — tracked as a follow-up; CUDA is the
290+
recall-safe batched path today.
291+
269292
## 4. Case 2 — cross-host proposer/verifier (FEASIBILITY VERDICT)
270293

271294
### 4.1 Verdict: the requested topology is not implementable today, and is architecturally bounded out
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"kind": "mlx_batched_multitenant",
3+
"config": {
4+
"sessions": 4,
5+
"modal_prompt_len": 339,
6+
"max_new_tokens": 16,
7+
"verifier_path": "/Users/fluffy314/kakeya-models/gemma-4-26B-A4B-it-mlx-4bit"
8+
},
9+
"serialized": {
10+
"aggregate_tps": 25.241,
11+
"recall": 1.0
12+
},
13+
"batched": {
14+
"aggregate_tps": 23.945,
15+
"recall": 0.25
16+
},
17+
"batched_speedup_vs_serialized": 0.95
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"kind": "mlx_batched_multitenant",
3+
"config": {
4+
"sessions": 8,
5+
"modal_prompt_len": 1149,
6+
"max_new_tokens": 24,
7+
"verifier_path": "/Users/fluffy314/kakeya-models/gemma-4-26B-A4B-it-mlx-4bit"
8+
},
9+
"serialized": {
10+
"aggregate_tps": 25.801,
11+
"recall": 1.0
12+
},
13+
"batched": {
14+
"aggregate_tps": 7.879,
15+
"recall": 0.25
16+
},
17+
"batched_speedup_vs_serialized": 0.31
18+
}

0 commit comments

Comments
 (0)