Skip to content

Commit 7c0b92b

Browse files
Add code-completion workload (--code-prompts) + k3-fused-allmlx-code preset
Honest spec-decode throughput probe: all-MLX fused on naturally-long, predictable code-completion prompts (the spec-decode sweet spot), natural stop. Reports decode-only tok/s (fused vs oracle AR) + acceptance. --code-prompts skips the NIAH recall gate (recall N/A by design). Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>
1 parent 2c93e48 commit 7c0b92b

2 files changed

Lines changed: 78 additions & 8 deletions

File tree

inference_engine/bridge/manifest.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,37 @@ def _harness_preset(
235235
timeout_minutes=45,
236236
params={"path": ("path:tests", None)},
237237
),
238+
Preset(
239+
name="k3-fused-allmlx-code",
240+
description="HONEST spec-decode throughput probe: all-MLX fused on a "
241+
"code-completion workload (naturally-long, predictable gen "
242+
"= the spec-decode sweet spot), natural stop. Reports "
243+
"decode-only tok/s (fused vs oracle AR) + acceptance.",
244+
command_templates=(
245+
(
246+
"python3", "scripts/research/k3_integrated_niah_eval_mac.py",
247+
"--verifier-path", "${ENV:KAKEYA_MAC_VERIFIER_PATH}",
248+
"--drafter-id", "${ENV:KAKEYA_MAC_DRAFTER_ID}",
249+
"--f-theta-dir", "${ENV:KAKEYA_MAC_FTHETA_DIR}",
250+
"--s5-exact-full-attn", "--fused-specdecode",
251+
"--all-mlx-drafter", "--code-prompts",
252+
# natural stop (no --ignore-turn-stop); code finishes itself
253+
"--n-samples", "{n_samples}",
254+
"--max-new-tokens", "{max_new_tokens}",
255+
"--block-size", "{block_size}",
256+
"--prefill-chunk-size", "512",
257+
"--output",
258+
"results/research/k3_mac_bridge_k3_fused_allmlx_code.json",
259+
),
260+
),
261+
timeout_minutes=120,
262+
params={
263+
"n_samples": ("int:n_samples", "8"),
264+
"max_new_tokens": ("int:max_new_tokens", "128"),
265+
"block_size": ("int:block_size", "4"),
266+
},
267+
validate_reports=False,
268+
),
238269
Preset(
239270
name="k3-fused-allmlx-natural",
240271
description="Acceptance probe: all-MLX fused, NATURAL stop (no "

scripts/research/k3_integrated_niah_eval_mac.py

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ def parse_args() -> argparse.Namespace:
112112
"crossings per block. Requires --s5-exact-full-attn "
113113
"(the all-MLX path uses native-S5 injection; the "
114114
"f_theta sliding restoration path stays torch).")
115+
ap.add_argument("--code-prompts", action="store_true",
116+
help="Replace the NIAH dataset with code-completion prompts "
117+
"(naturally-long, predictable generation = the spec-decode "
118+
"sweet spot). Recall metric is N/A; measures honest "
119+
"decode-only throughput + acceptance on a real workload.")
115120
ap.add_argument("--ignore-turn-stop", action="store_true",
116121
help="Do not include Gemma4 <turn|> as a stop token. "
117122
"Useful for throughput evidence runs that require "
@@ -391,12 +396,41 @@ def restored_forward(ids: List[int], rk, rv, t_src, *, return_all: bool):
391396
)
392397

393398
# ---------- Dataset ----------
394-
samples: List[NIAHSample] = make_niah_dataset(
395-
n_samples=args.n_samples,
396-
haystack_min_lines=args.haystack_min_lines,
397-
haystack_max_lines=args.haystack_max_lines,
398-
seed=args.seed,
399-
)
399+
if args.code_prompts:
400+
_CODE = [
401+
"Write a complete Python implementation of a binary search tree class "
402+
"with insert, search, and in-order traversal methods. Include type "
403+
"hints and docstrings.",
404+
"Implement a Python LRU cache class with get and put methods using an "
405+
"OrderedDict. Include type hints and docstrings.",
406+
"Write a Python function that parses a CSV string into a list of dicts, "
407+
"correctly handling quoted fields and embedded commas. Add error handling.",
408+
"Implement quicksort in Python with an in-place partition helper. "
409+
"Include docstrings and a small example in a __main__ block.",
410+
"Write a Python class for a fixed-capacity ring buffer with push, pop, "
411+
"and is_full methods, raising on overflow. Include type hints.",
412+
"Implement a recursive descent parser in Python for arithmetic "
413+
"expressions with + - * / and parentheses. Return the evaluated value.",
414+
"Write a Python decorator `retry` that retries a function up to n times "
415+
"with exponential backoff on exception. Include type hints and docstring.",
416+
"Implement a thread-safe counter class in Python using threading.Lock, "
417+
"with increment, decrement, and value methods.",
418+
]
419+
n = min(args.n_samples, len(_CODE))
420+
samples: List[NIAHSample] = [
421+
NIAHSample(prompt_text=p, answer_text="", needle_line_index=0,
422+
needle_text="")
423+
for p in _CODE[:n]
424+
]
425+
print(f"[mac] CODE-PROMPTS workload: {n} prompts (recall N/A; "
426+
f"measuring decode throughput + acceptance)", file=sys.stderr)
427+
else:
428+
samples = make_niah_dataset(
429+
n_samples=args.n_samples,
430+
haystack_min_lines=args.haystack_min_lines,
431+
haystack_max_lines=args.haystack_max_lines,
432+
seed=args.seed,
433+
)
400434

401435
def encode(prompt_text: str) -> List[int]:
402436
if args.direct_answer_prompt:
@@ -1036,12 +1070,17 @@ def _mx_peak_mb() -> Optional[float]:
10361070
print(f"\n[mac] DONE. {sut_label}={cross_res.recall:.3f} "
10371071
f"oracle={oracle_res.recall if oracle_res else 'skipped'} "
10381072
f"-> {out_path}", file=sys.stderr)
1039-
if violations:
1073+
if violations and args.code_prompts:
1074+
print("[mac] code-prompts throughput probe: recall is N/A by design; "
1075+
"evidence gate informational only (not aborting):\n"
1076+
+ summarize_violations(violations), file=sys.stderr)
1077+
elif violations:
10401078
print("[mac] EVIDENCE GATE FAILED — this report is NOT admissible "
10411079
"as evidence:\n" + summarize_violations(violations),
10421080
file=sys.stderr)
10431081
return 2
1044-
print("[mac] evidence gate: PASS", file=sys.stderr)
1082+
else:
1083+
print("[mac] evidence gate: PASS", file=sys.stderr)
10451084
return 0
10461085

10471086

0 commit comments

Comments
 (0)