Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
b513303
inkling2 metal: run greedy DSpark holds step-major across streams
plotarmordev Nov 23, 2026
0911e37
inkling2 metal: cover cohort depths and solo token equality
plotarmordev Nov 23, 2026
54e03b4
Merge remote-tracking branch 'origin/feat/210-inkling-2-mini-on-mac-f…
plotarmordev Nov 23, 2026
ea994bd
inkling2 metal: reduce only active DSpark unembed rows
plotarmordev Nov 23, 2026
7c51069
inkling2 metal: keep a lone greedy DSpark hold on its solo chain
plotarmordev Nov 23, 2026
46219d6
docs: card 235's step-major DSpark receipt and engine comparison on M…
plotarmordev Nov 23, 2026
1de6b1c
lanes: report head chain rows drafted and kept at each depth, summed …
plotarmordev Nov 23, 2026
0a05a58
inkling2 metal: register and probe the five DSpark cohort launches ag…
plotarmordev Nov 23, 2026
5faf939
docs: card 235's benches admit every measured stream
plotarmordev Nov 23, 2026
fc2e267
docs: card 235's receipt at 16 admitted lanes, acceptance by depth, t…
plotarmordev Nov 23, 2026
185461e
inkling2 metal: zig fmt dspark_state
plotarmordev Nov 23, 2026
55875eb
server: report per-depth draft tallies only when a head chain drafted…
plotarmordev Nov 23, 2026
cc3fede
Merge remote-tracking branch 'origin/feat/210-inkling-2-mini-on-mac-f…
plotarmordev Nov 23, 2026
895bdaf
inkling2 metal: say which DSpark holds take one command buffer; recei…
plotarmordev Nov 23, 2026
c478e1e
docs: card 235's receipt compares only against #4618's published figu…
plotarmordev Nov 23, 2026
baadcab
bench: redact credentials inside tuples; depth tallies keep only nonn…
plotarmordev Nov 24, 2026
4dba41c
Merge remote-tracking branch 'origin/feat/210-inkling-2-mini-on-mac-f…
plotarmordev Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog.d/235-inkling-2-mini-on-mac-all-streams-dspark.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Inkling 2 Mini on Metal: shared DSpark holds across streams

- Schedule greedy DSpark holds by block and recurrent step across active streams, batching the unembedding weight read for each cohort rather than completing one stream's draft chain before starting the next; a lone stream keeps its solo chain.
- Check greedy draft-token equality against solo holds with unequal depths, streams joining or leaving, and 16-stream cohorts.
- On the M5 Ultra, greedy DSpark reaches 317 / 260 tok/s at four streams (code / chat, up 14% on the better control) and 372 / 349 at sixteen (up 31%), with acceptance unchanged; `docs/receipts/inkling-2-mini-metal-235` holds the control/candidate/control medians and acceptance by depth.
78 changes: 78 additions & 0 deletions docs/receipts/inkling-2-mini-metal-235/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Inkling 2 Mini on Metal, M5 Ultra: card 235's receipt

Apple M5 Ultra, 256 GB, macOS 27.0; the official checkpoint (`Inkling-2-Mini`, its own `mtp.safetensors` as the
DSpark drafter); `tensorfold-native` from `zig build native -Doptimize=ReleaseFast`. Control is card 210's head
(781eeab52), candidate this branch; both carry this branch's per-depth draft counters (1de6b1c30), which only report.
Every run held `/tmp/tensorfold-model.lock` inside the Desk's Mac GPU window, one server at a time. Other agents'
builds kept the load average between 50 and 90; the two controls differ by up to 40% (16 chat streams), so the
candidate ran between them.

## Step-major holds

`bench.sh` (`--context 65536 --parallel 16`; `tools/bench_concurrent.py --levels 1,2,4,16 --reps 3 --tokens 256
--temperatures 0 --alone`), medians of three reps, aggregate tok/s. Control, candidate, control:

| code / chat | control | **candidate** | control again |
|---|---|---|---|
| 1 stream | 119.7 / 93.9 | **121.9 / 93.4** | 125.7 / 94.0 |
| 2 streams | 192.9 / 159.2 | **209.8 / 172.8** | 196.0 / 157.6 |
| 4 streams | 278.3 / 228.3 | **317.2 / 259.5** | 277.6 / 225.2 |
| 16 streams | 284.1 / 266.8 | **372.2 / 348.9** | 267.4 / 190.9 |

- Against the better control: +7.0% / +8.5% at two streams, +14.0% / +13.7% at four, +31.0% / +30.8% at sixteen.
One stream keeps the solo chain (−3.0% / −0.6%, inside the controls' spread).
- 0 failed requests; every concurrent reply equal to its run alone (3, 6, 12 and 48 of each in every session).

Acceptance by depth, head chain rows kept over drafted, summed over each cell's three reps (`drafts.depth_accepted`
and `drafts.depth_drafted` in `cells.jsonl`). From two streams on the three sessions agree row for row; the later
depths' few rows are the first round's:

| code | control | candidate | control again |
|---|---|---|---|
| 1 | 172/232 132/226 103/224 57/171 39/156 25/153 7/78 | 169/229 125/223 94/216 70/216 48/181 29/150 4/45 | 173/228 134/222 105/222 71/201 48/163 7/50 0/4 |
| 2 | 420/534 318/534 252/528 0/6 0/6 | 420/534 318/534 252/528 0/6 0/6 0/6 0/6 | 420/534 318/534 252/528 0/6 0/6 |
| 4 | 840/1068 636/1068 504/1056 0/12 0/12 | 840/1068 636/1068 504/1056 0/12 0/12 0/12 0/12 | 840/1068 636/1068 504/1056 0/12 0/12 |
| 16 | 5424/6720 | 5424/6720 | 5424/6720 |

| chat | control | candidate | control again |
|---|---|---|---|
| 1 | 223/321 113/297 68/261 21/177 10/157 6/58 0/5 | 225/322 112/292 71/267 20/213 9/133 2/15 | 212/307 107/295 77/280 28/219 20/186 13/109 0/10 |
| 2 | 438/648 246/642 180/642 0/6 | 438/648 246/642 180/642 0/6 0/6 | 438/648 246/642 180/642 0/6 0/6 |
| 4 | 876/1296 492/1284 360/1284 0/12 | 876/1296 492/1284 360/1284 0/12 0/12 | 876/1296 492/1284 360/1284 0/12 0/12 |
| 16 | 5088/7008 | 5088/7008 | 5088/7008 |

One stream's depths follow each round's timing, so drafted rows per depth move between sessions in both arms and the
per-depth ratios do not compare; its total kept rows (535, 539, 538 code; 441, 440, 457 chat) do not regress. At
sixteen admitted streams the depth rule drafts one row.

## Against #4618's published figures

#4618 published TensorFold's Inkling 2 Mini at 123.4 code / 91.5 chat tok/s on one stream and 281.1 / 223.0 on four,
on this Mac with its own clients; those are its published figures, not measured here. This branch's candidate gives
121.9 / 93.4 on one stream and 317.2 / 259.5 on four. Other engines at 1, 4 and 64 streams are card "ink mac
engines"'s receipt.

## Exactness

`TF_INKLING2_METAL_DIR` and `TF_INKLING2_DSPARK_DIR` set to the checkpoint, the `test-inkling2-metal-host` test
binary runs on the device:

- `Mini Metal DSpark sixteen-stream chain preserves solo holds at unequal depths`: depths 1-7, four streams then all
sixteen in one hold, each equal to its own solo hold;
- `Mini Metal DSpark four prompts equal solos through a leave and join`: four greedy replies equal four solo replies
token for token while a stream leaves and another joins;
- `Mini Metal opt-in DSpark drafting preserves target tokens and rolls back exactly`.

## Kernel contract

`tf-kernel-contract --only 'dspark cohort'` on this Mac: `SUMMARY 5 kernels: 5 pass gates 1-4, 0 fail, 0 known
findings; 5 controls: 5 red as planted, 0 missed; 0 limit problems`. Each cohort launch
(`zig/tests/contract/metal_inkling2_dspark_cohort.zig`, records in `inkling2_dspark_cohort_metal_records.zig`) is
checked byte for byte against the solo launches it replaces run a stream at a time on the same inputs: `block_qkv`
at each anchor, `recurrent` at each kappa row and held token, `chain_pick`, `logits` per base row, and the host's
row copies for `pack`. Each control plants one stream's or row's wrong index and turns red at `shapes`.

## Files

`cells.jsonl`: each cell of the three sessions; `bench.sh` reproduces them (`MODEL` names the checkpoint, `OUT` the
scratch folder).
18 changes: 18 additions & 0 deletions docs/receipts/inkling-2-mini-metal-235/bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# bench.sh LABEL BINARY: one DSpark server session from BINARY admitting 16 lanes, bench_concurrent at 1, 2, 4 and 16
# streams, greedy, 3 reps. Run it under `lockf -k /tmp/tensorfold-model.lock`, one at a time; LEVELS overrides the
# stream counts.
set -euo pipefail
label=$1 bin=$2
wt=$(git -C "$(dirname "$0")" rev-parse --show-toplevel)
model=${MODEL:-$HOME/models/Inkling-2-Mini}
out=${OUT:-/tmp/ink2-bench}
mkdir -p "$out"
[ -e /Users/Shared/agent-work/mac-gpu-window ] || { echo "no Mac GPU window" >&2; exit 3; }
"$bin" serve "$model" --port 18235 --context 65536 --parallel 16 --drafter "$model" >"$out/$label.server.log" 2>&1 &
pid=$!
trap 'kill -INT $pid 2>/dev/null; wait $pid 2>/dev/null' EXIT
for _ in $(seq 240); do curl -sf http://127.0.0.1:18235/v1/models >/dev/null && break; sleep 1; done
/opt/homebrew/bin/python3.13 "$wt/tools/bench_concurrent.py" http://127.0.0.1:18235 Inkling-2-Mini \
--levels "${LEVELS:-1,2,4,16}" --reps 3 --tokens 256 --temperatures 0 --label "$label" --alone \
--output "$out/$label.json" 2>&1 | tail -n 6
24 changes: 24 additions & 0 deletions docs/receipts/inkling-2-mini-metal-235/cells.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{"label": "c16-ctl-a", "prompt": "code", "streams": 1, "aggregate_tps": 119.7, "end_to_end_tps": 116.88543685775235, "failed": 0, "drafts": {"rounds": 233, "drafted": 1255, "accepted": 535, "depth_drafted": [232, 226, 224, 171, 156, 153, 78], "depth_accepted": [172, 132, 103, 57, 39, 25, 7]}, "alone": {"equal": 3, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-a", "prompt": "code", "streams": 2, "aggregate_tps": 192.9, "end_to_end_tps": 189.231965025503, "failed": 0, "drafts": {"rounds": 540, "drafted": 1608, "accepted": 990, "depth_drafted": [534, 534, 528, 6, 6], "depth_accepted": [420, 318, 252]}, "alone": {"equal": 6, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-a", "prompt": "code", "streams": 4, "aggregate_tps": 278.3, "end_to_end_tps": 275.10994491939044, "failed": 0, "drafts": {"rounds": 1080, "drafted": 3216, "accepted": 1980, "depth_drafted": [1068, 1068, 1056, 12, 12], "depth_accepted": [840, 636, 504]}, "alone": {"equal": 12, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-a", "prompt": "code", "streams": 16, "aggregate_tps": 284.1, "end_to_end_tps": 283.96345011473045, "failed": 0, "drafts": {"rounds": 6816, "drafted": 6768, "accepted": 5424, "depth_drafted": [6720], "depth_accepted": [5424]}, "alone": {"equal": 48, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-a", "prompt": "chat", "streams": 1, "aggregate_tps": 93.9, "end_to_end_tps": 91.38977157597242, "failed": 0, "drafts": {"rounds": 324, "drafted": 1321, "accepted": 441, "depth_drafted": [321, 297, 261, 177, 157, 58, 5], "depth_accepted": [223, 113, 68, 21, 10, 6]}, "alone": {"equal": 3, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-a", "prompt": "chat", "streams": 2, "aggregate_tps": 159.2, "end_to_end_tps": 155.6431134964016, "failed": 0, "drafts": {"rounds": 654, "drafted": 2028, "accepted": 876, "depth_drafted": [648, 642, 642, 6], "depth_accepted": [438, 246, 180]}, "alone": {"equal": 6, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-a", "prompt": "chat", "streams": 4, "aggregate_tps": 228.3, "end_to_end_tps": 224.64889015945306, "failed": 0, "drafts": {"rounds": 1308, "drafted": 3960, "accepted": 1752, "depth_drafted": [1296, 1284, 1284, 12], "depth_accepted": [876, 492, 360]}, "alone": {"equal": 12, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-a", "prompt": "chat", "streams": 16, "aggregate_tps": 266.8, "end_to_end_tps": 266.3535516813391, "failed": 0, "drafts": {"rounds": 7104, "drafted": 7104, "accepted": 5136, "depth_drafted": [7008], "depth_accepted": [5088]}, "alone": {"equal": 48, "unequal": 0, "failed": 0}}
{"label": "c16-cand", "prompt": "code", "streams": 1, "aggregate_tps": 121.9, "end_to_end_tps": 119.32538271894245, "failed": 0, "drafts": {"rounds": 229, "drafted": 1260, "accepted": 539, "depth_drafted": [229, 223, 216, 216, 181, 150, 45], "depth_accepted": [169, 125, 94, 70, 48, 29, 4]}, "alone": {"equal": 3, "unequal": 0, "failed": 0}}
{"label": "c16-cand", "prompt": "code", "streams": 2, "aggregate_tps": 209.8, "end_to_end_tps": 205.71504794300844, "failed": 0, "drafts": {"rounds": 540, "drafted": 1620, "accepted": 990, "depth_drafted": [534, 534, 528, 6, 6, 6, 6], "depth_accepted": [420, 318, 252]}, "alone": {"equal": 6, "unequal": 0, "failed": 0}}
{"label": "c16-cand", "prompt": "code", "streams": 4, "aggregate_tps": 317.2, "end_to_end_tps": 313.0650068588643, "failed": 0, "drafts": {"rounds": 1080, "drafted": 3240, "accepted": 1980, "depth_drafted": [1068, 1068, 1056, 12, 12, 12, 12], "depth_accepted": [840, 636, 504]}, "alone": {"equal": 12, "unequal": 0, "failed": 0}}
{"label": "c16-cand", "prompt": "code", "streams": 16, "aggregate_tps": 372.2, "end_to_end_tps": 371.7421721646994, "failed": 0, "drafts": {"rounds": 6816, "drafted": 6768, "accepted": 5424, "depth_drafted": [6720], "depth_accepted": [5424]}, "alone": {"equal": 48, "unequal": 0, "failed": 0}}
{"label": "c16-cand", "prompt": "chat", "streams": 1, "aggregate_tps": 93.4, "end_to_end_tps": 91.0309139987294, "failed": 0, "drafts": {"rounds": 325, "drafted": 1287, "accepted": 440, "depth_drafted": [322, 292, 267, 213, 133, 15], "depth_accepted": [225, 112, 71, 20, 9, 2]}, "alone": {"equal": 3, "unequal": 0, "failed": 0}}
{"label": "c16-cand", "prompt": "chat", "streams": 2, "aggregate_tps": 172.8, "end_to_end_tps": 168.53290897738248, "failed": 0, "drafts": {"rounds": 654, "drafted": 2034, "accepted": 876, "depth_drafted": [648, 642, 642, 6, 6], "depth_accepted": [438, 246, 180]}, "alone": {"equal": 6, "unequal": 0, "failed": 0}}
{"label": "c16-cand", "prompt": "chat", "streams": 4, "aggregate_tps": 259.5, "end_to_end_tps": 255.12893928587093, "failed": 0, "drafts": {"rounds": 1308, "drafted": 3972, "accepted": 1752, "depth_drafted": [1296, 1284, 1284, 12, 12], "depth_accepted": [876, 492, 360]}, "alone": {"equal": 12, "unequal": 0, "failed": 0}}
{"label": "c16-cand", "prompt": "chat", "streams": 16, "aggregate_tps": 348.9, "end_to_end_tps": 347.74160865912006, "failed": 0, "drafts": {"rounds": 7104, "drafted": 7104, "accepted": 5136, "depth_drafted": [7008], "depth_accepted": [5088]}, "alone": {"equal": 48, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-b", "prompt": "code", "streams": 1, "aggregate_tps": 125.7, "end_to_end_tps": 122.5636142797601, "failed": 0, "drafts": {"rounds": 230, "drafted": 1120, "accepted": 538, "depth_drafted": [228, 222, 222, 201, 163, 50, 4], "depth_accepted": [173, 134, 105, 71, 48, 7]}, "alone": {"equal": 3, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-b", "prompt": "code", "streams": 2, "aggregate_tps": 196.0, "end_to_end_tps": 192.53329013059238, "failed": 0, "drafts": {"rounds": 540, "drafted": 1608, "accepted": 990, "depth_drafted": [534, 534, 528, 6, 6], "depth_accepted": [420, 318, 252]}, "alone": {"equal": 6, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-b", "prompt": "code", "streams": 4, "aggregate_tps": 277.6, "end_to_end_tps": 274.6690769031714, "failed": 0, "drafts": {"rounds": 1080, "drafted": 3216, "accepted": 1980, "depth_drafted": [1068, 1068, 1056, 12, 12], "depth_accepted": [840, 636, 504]}, "alone": {"equal": 12, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-b", "prompt": "code", "streams": 16, "aggregate_tps": 267.4, "end_to_end_tps": 266.9129804820544, "failed": 0, "drafts": {"rounds": 6816, "drafted": 6768, "accepted": 5424, "depth_drafted": [6720], "depth_accepted": [5424]}, "alone": {"equal": 48, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-b", "prompt": "chat", "streams": 1, "aggregate_tps": 94.0, "end_to_end_tps": 91.0247506851077, "failed": 0, "drafts": {"rounds": 308, "drafted": 1421, "accepted": 457, "depth_drafted": [307, 295, 280, 219, 186, 109, 10], "depth_accepted": [212, 107, 77, 28, 20, 13]}, "alone": {"equal": 3, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-b", "prompt": "chat", "streams": 2, "aggregate_tps": 157.6, "end_to_end_tps": 153.4496116937129, "failed": 0, "drafts": {"rounds": 654, "drafted": 2034, "accepted": 876, "depth_drafted": [648, 642, 642, 6, 6], "depth_accepted": [438, 246, 180]}, "alone": {"equal": 6, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-b", "prompt": "chat", "streams": 4, "aggregate_tps": 225.2, "end_to_end_tps": 221.44720707479132, "failed": 0, "drafts": {"rounds": 1308, "drafted": 3972, "accepted": 1752, "depth_drafted": [1296, 1284, 1284, 12, 12], "depth_accepted": [876, 492, 360]}, "alone": {"equal": 12, "unequal": 0, "failed": 0}}
{"label": "c16-ctl-b", "prompt": "chat", "streams": 16, "aggregate_tps": 190.9, "end_to_end_tps": 190.63346263988035, "failed": 0, "drafts": {"rounds": 7104, "drafted": 7104, "accepted": 5136, "depth_drafted": [7008], "depth_accepted": [5088]}, "alone": {"equal": 48, "unequal": 0, "failed": 0}}
2 changes: 1 addition & 1 deletion tools/bench_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def redact(value, key: str | None):
return value
if isinstance(value, str):
return value.replace(key, "[REDACTED]")
if isinstance(value, list):
if isinstance(value, (list, tuple)):
return [redact(item, key) for item in value]
if isinstance(value, dict):
return {redact(name, key): redact(item, key) for name, item in value.items()}
Expand Down
34 changes: 33 additions & 1 deletion tools/bench_concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
server with a small listen backlog resets simultaneous connections; those resets are reported, not hidden).
Each request also carries bench_metrics' figures (prompt/TTFT tok/s, token ITL/TPOT, chunk estimates, round gaps) and
bench_stream's boundaries and completion class (docs/cache-benchmarks.md defines them); each rep pools them over its
streams, and each cell gives medians ("request" and "pooled") and its completion classes.
streams, and each cell gives medians ("request" and "pooled") and its completion classes. ``drafts``: the cell's
speculative rounds, drafted and accepted tokens summed over its reps' requests, when the server reports them for all,
and ``depth_drafted``/``depth_accepted``, the head chain's drafted and kept rows at each depth, when it reports those.
Every stream of a default cell sends the same prompt (greedy: and gets the same reply), so a mixture-of-experts
model routes all of them to the same experts, which can flatter multi-stream rates. ``--prompts FILE`` (for example
tools/bench_prompts.json) runs one "distinct" cell instead, where request i sends the file's item i (modulo its length).
Expand Down Expand Up @@ -191,12 +193,34 @@ def overlapped(runs: list[dict]) -> bool | None:
return any(b[0] < a[1] for a, b in zip(spans, spans[1:])) if len(spans) > 1 else None


DRAFT_KEYS = ("rounds", "drafted", "accepted")
DEPTH_KEYS = ("depth_drafted", "depth_accepted")


def draft_count(run: dict, key: str) -> int | None:
"""A run's speculative count, None when the server reported none."""
value = (run.get("speculative") or {}).get(key)
return value if type(value) is int and value >= 0 else None


def depth_counts(run: dict) -> list[list[int]] | None:
"""A run's per-depth drafted and kept rows, None unless the server reported both as nonnegative integers."""
spec = run.get("speculative") or {}
pair = [spec.get(k) for k in DEPTH_KEYS]
ok = all(type(v) is list and all(type(n) is int and n >= 0 for n in v) for v in pair)
return pair if ok else None


def sum_depths(rows) -> list[int]:
"""Element-wise sums of per-depth tallies of any lengths."""
out: list[int] = []
for row in rows:
out.extend([0] * (len(row) - len(out)))
for i, v in enumerate(row):
out[i] += v
return out


def serial_evidence(alone: dict) -> dict:
"""Drafts the alone runs accepted and the ``"draft": false`` runs drafted; ``vacuous`` says why that proves none."""
accepted = [draft_count(r, "accepted") for r in alone.values()]
Expand Down Expand Up @@ -324,6 +348,8 @@ def main() -> None:
rep["ttft_s"] = [round(r["ttft_s"], 2) if r["ttft_s"] is not None else None for r in runs]
rep["errors"] = [r["error"] for r in runs if r.get("error")]
rep["thinking_modes"] = sorted({r["thinking"] for r in runs if "thinking" in r})
rep["drafts"] = [[draft_count(r, k) for k in DRAFT_KEYS] for r in runs]
rep["depths"] = [depth_counts(r) for r in runs]
rep["requests"] = [{k: r.get(k) for k in ("prompt_tokens", "ttft_s", "decode_tps", "thinking", "thinking_off_requested",
"completion", "token_timing", *METRICS)}
for r in runs]
Expand Down Expand Up @@ -366,6 +392,12 @@ def main() -> None:
cell[key] = statistics.median(r[key] for r in reps) if valid else None
if all("steady_tps" in r for r in reps):
cell["steady_tps"] = round(statistics.median(r["steady_tps"] for r in reps), 1)
counts = [c for r in reps for c in r["drafts"]]
if counts and all(None not in c for c in counts):
cell["drafts"] = dict(zip(DRAFT_KEYS, map(sum, zip(*counts))))
depths = [d for r in reps for d in r["depths"]]
if all(d is not None for d in depths):
cell["drafts"].update(zip(DEPTH_KEYS, (sum_depths(d[i] for d in depths) for i in range(2))))
if alone:
checks = [v for r in reps for v in r["equal_alone"]]
cell["alone"] = {"equal": checks.count(True), "unequal": checks.count(False),
Expand Down
11 changes: 11 additions & 0 deletions tools/tests/test_bench_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from unittest.mock import patch

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
import bench_auth
import bench_concurrent
import bench_openai

Expand Down Expand Up @@ -153,6 +154,16 @@ def test_stream_error_payload_does_not_expose_credentials(self):
self.assertNotIn(KEY, stdout.getvalue() + stderr.getvalue())
self.assertIn("RuntimeError", stdout.getvalue() + stderr.getvalue())

def test_credentials_nested_in_tuples_and_depth_tallies_are_redacted(self):
nested = {"depths": [([1, KEY], (KEY, {"note": KEY}))], KEY: (KEY,)}
self.assertNotIn(KEY, json.dumps(bench_auth.redact(nested, KEY)))
for drafted in ([2, KEY], [2, -1], [2, 1.5], [2, True]):
with self.subTest(drafted=drafted):
run = {"speculative": {"depth_drafted": drafted, "depth_accepted": [1, 0]}}
self.assertIsNone(bench_concurrent.depth_counts(run))
run = {"speculative": {"depth_drafted": [4, 2], "depth_accepted": [3, 1]}}
self.assertEqual(bench_concurrent.depth_counts(run), [[4, 2], [3, 1]])


@contextlib.contextmanager
def serve(handler):
Expand Down
Loading