Repository navigation
bench: include draft acceptance in the JSON record - #89
Conversation
| let mut record = bench_record(&meta, &results, r.expert_summary().as_ref(), unix_time); | ||
| // The arch-specific benchners print this; putting it in the JSON too gives tools one reliable source. | ||
| let drafts = if let Runner::Gpu(g) = &r { g.drafts } else { (0, 0) }; | ||
| record["drafts"] = json!({"made": drafts.0, "accepted": drafts.1}); |
There was a problem hiding this comment.
🟠 High · Correctness · 1 of 4
Non-GPU runners are reported as zero drafts, indistinguishable from a GPU run with no drafts. For a CPU or other non-Gpu runner the else branch sets drafts to (0, 0), and the JSON gets "drafts": {"made": 0, "accepted": 0}. A downstream tool computing acceptance rate sees 0/0 and either treats it as a real 0% rate or divides by zero. The record cannot tell 'not applicable' from 'speculation ran and nothing was drafted'. Emitting null (or omitting the key) for non-GPU runs would keep the two apart.
Prompt for your AI agent
File: src/main.rs
Line: 1343
Symbol: run
Issue: Non-GPU runners are reported as zero drafts, indistinguishable from a GPU run with no drafts. For a CPU or other non-Gpu runner the else branch sets drafts to (0, 0), and the JSON gets "drafts": {"made": 0, "accepted": 0}. A downstream tool computing acceptance rate sees 0/0 and either treats it as a real 0% rate or divides by zero. The record cannot tell 'not applicable' from 'speculation ran and nothing was drafted'. Emitting null (or omitting the key) for non-GPU runs would keep the two apart.
Make the smallest change that fixes this, add a test, and change nothing unrelated.
Reply /dismiss (optionally with a reason) if this isn't helpful - Aletheore won't raise it again on this repo.
| let record = bench_record(&meta, &results, r.expert_summary().as_ref(), unix_time); | ||
| let mut record = bench_record(&meta, &results, r.expert_summary().as_ref(), unix_time); | ||
| // The arch-specific benchners print this; putting it in the JSON too gives tools one reliable source. | ||
| let drafts = if let Runner::Gpu(g) = &r { g.drafts } else { (0, 0) }; |
There was a problem hiding this comment.
🟠 High · Correctness · 2 of 4
Tuple field order (made, accepted) is assumed, not checked against g.drafts. The code maps drafts.0 to "made" and drafts.1 to "accepted" without any visible definition of g.drafts. If the GPU runner stores (accepted, made), every bench JSON silently swaps the two values, and the acceptance ratio reported downstream is inverted or exceeds 1. Naming the fields on the GPU side, or destructuring with named bindings, would make the mapping explicit.
Prompt for your AI agent
File: src/main.rs
Line: 1342
Symbol: run
Issue: Tuple field order (made, accepted) is assumed, not checked against g.drafts. The code maps drafts.0 to "made" and drafts.1 to "accepted" without any visible definition of g.drafts. If the GPU runner stores (accepted, made), every bench JSON silently swaps the two values, and the acceptance ratio reported downstream is inverted or exceeds 1. Naming the fields on the GPU side, or destructuring with named bindings, would make the mapping explicit.
Make the smallest change that fixes this, add a test, and change nothing unrelated.
Reply /dismiss (optionally with a reason) if this isn't helpful - Aletheore won't raise it again on this repo.
| let unix_time = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).map_or(0, |d| d.as_secs()); | ||
| let record = bench_record(&meta, &results, r.expert_summary().as_ref(), unix_time); | ||
| let mut record = bench_record(&meta, &results, r.expert_summary().as_ref(), unix_time); | ||
| // The arch-specific benchners print this; putting it in the JSON too gives tools one reliable source. |
There was a problem hiding this comment.
🟠 High · Correctness · 3 of 4
Comment overstates the source as 'reliable' while non-GPU runs fill in zeros. The comment says this gives tools 'one reliable source', yet for every non-GPU runner the value is a fabricated (0, 0) rather than a measurement. Someone reading the comment would trust the field for CPU benches and draw wrong conclusions about speculative decoding. The comment should say the field is only populated for GPU runs.
Prompt for your AI agent
File: src/main.rs
Line: 1341
Symbol: run
Issue: Comment overstates the source as 'reliable' while non-GPU runs fill in zeros. The comment says this gives tools 'one reliable source', yet for every non-GPU runner the value is a fabricated (0, 0) rather than a measurement. Someone reading the comment would trust the field for CPU benches and draw wrong conclusions about speculative decoding. The comment should say the field is only populated for GPU runs.
Make the smallest change that fixes this, add a test, and change nothing unrelated.
Reply /dismiss (optionally with a reason) if this isn't helpful - Aletheore won't raise it again on this repo.
| let mut record = bench_record(&meta, &results, r.expert_summary().as_ref(), unix_time); | ||
| // The arch-specific benchners print this; putting it in the JSON too gives tools one reliable source. | ||
| let drafts = if let Runner::Gpu(g) = &r { g.drafts } else { (0, 0) }; | ||
| record["drafts"] = json!({"made": drafts.0, "accepted": drafts.1}); |
There was a problem hiding this comment.
🔵 Low · Maintainability · 4 of 4
Drafts are patched into the record after construction instead of passed to bench_record. bench_record builds the JSON, then the caller reaches in with record["drafts"] = ... to add a field. Any other caller of bench_record will silently lack the field, and the schema is now split across two places. Passing drafts as a parameter (or an Option) into bench_record keeps the schema in one function.
Prompt for your AI agent
File: src/main.rs
Line: 1343
Symbol: run
Issue: Drafts are patched into the record after construction instead of passed to bench_record. bench_record builds the JSON, then the caller reaches in with record["drafts"] = ... to add a field. Any other caller of bench_record will silently lack the field, and the schema is now split across two places. Passing drafts as a parameter (or an Option) into bench_record keeps the schema in one function.
Make the smallest change that fixes this, add a test, and change nothing unrelated.
Reply /dismiss (optionally with a reason) if this isn't helpful - Aletheore won't raise it again on this repo.
Aletheore Flash Lite reviewWhat this PR does. This pull request adds a "drafts" object with "made" and "accepted" counts to the JSON benchmark record emitted by the bench command in src/main.rs. The counts come from the GPU runner's draft statistics and default to zero for other runner types, so downstream tools that parse bench output get draft acceptance data without scraping the printed text.
4 finding(s) posted as inline review comment(s).
Review detailsReviewed 1 file(s); skipped 0. Dismissed 0; outside PR diff 0. Grounding: 4 of 4 proposed finding(s). Fix all with your agent |
🔍 Aletheore evidence diffWhat changed
Aggregate deltas
|
The text output of
strata benchalready reports MTP drafts made and accepted (fromRunner::finish), but tools reading--json-outcannot see it. Add adraftsobject withmadeandacceptedto the main engine'sstrata.bench.v1record. Greedy output and timings are unchanged.This is a self-contained, two-line change: the calibration work in the other PR parses the same numbers from stdout when the JSON field is absent, so the two can be merged in either order.
Verified with
cargo check --releaseand the existing bench-record tests.