Skip to content

Commit 9bcf99e

Browse files
diag(mac): per-row batched-vs-serialized first-token logging + short-prompt preset (isolate RotatingKVCache rotation-under-batch)
Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>
1 parent 7a96615 commit 9bcf99e

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

inference_engine/bridge/manifest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,27 @@ def _harness_preset(
131131
),
132132
timeout_minutes=60,
133133
),
134+
Preset(
135+
name="mlx-batched-diag-short",
136+
description="Diagnostic: MLX batched multi-tenant on SHORT prompts "
137+
"(haystack 8, below the sliding window so no "
138+
"RotatingKVCache rotation) — isolates whether the "
139+
"batched-recall bug is rotation-under-batch. Logs "
140+
"per-row batched-vs-serialized first tokens.",
141+
command_templates=(
142+
(
143+
"python3", "scripts/research/mlx_batched_multitenant_bench.py",
144+
"--verifier-path", "${ENV:KAKEYA_MAC_VERIFIER_PATH}",
145+
"--sessions", "4",
146+
"--haystack-lines", "8",
147+
"--max-new-tokens", "16",
148+
"--output",
149+
"results/research/k3_mac_bridge_mlx_batched_diag_short.json",
150+
),
151+
),
152+
timeout_minutes=60,
153+
validate_reports=False,
154+
),
134155
Preset(
135156
name="mlx-batched-multitenant",
136157
description="Mac analog of the §3.7 batched scheduler: N sessions "

scripts/research/mlx_batched_multitenant_bench.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ def decode_batched(cache, logits, max_tokens):
134134
serial_tps = round((N * args.max_new_tokens) / ser_decode_s, 3) if ser_decode_s else 0.0
135135
serial_recall = sum(recall(g_s[i], answers[i]) for i in range(N)) / N
136136

137+
# Diagnostic: per-row batched-vs-serialized first token + recall, to
138+
# localize whether batched PREFILL diverges from serialized (batch-1).
139+
print("[mlx-mt][diag] row | serial_tok0 | batched_tok0 | match | "
140+
"serial_recall | batched_recall", flush=True)
141+
for i in range(N):
142+
s0 = g_s[i][0] if g_s[i] else None
143+
b0 = g_b[i][0] if g_b[i] else None
144+
print(f"[mlx-mt][diag] {i:2d} | {s0} | {b0} | {s0 == b0} | "
145+
f"{recall(g_s[i], answers[i])} | {recall(g_b[i], answers[i])}",
146+
flush=True)
147+
137148
speedup = round(batched_tps / serial_tps, 2) if serial_tps else None
138149
report = {
139150
"kind": "mlx_batched_multitenant",

tests/inference_engine/bridge/test_manifest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def test_allowlist_contains_exactly_the_documented_presets():
7272
"k3-step2-fused",
7373
"k3-step2-fused-allmlx",
7474
"mlx-backend-tests",
75+
"mlx-batched-diag-short",
7576
"mlx-batched-multitenant",
7677
"mlx-env-probe",
7778
"mlx-multitenant-pressure",

0 commit comments

Comments
 (0)