Skip to content

bench: include draft acceptance in the JSON record - #89

Merged
Vasyl-Trefilov merged 1 commit into
RustingStudio:mainfrom
sayampy:pr/bench-drafts
Nov 24, 2026
Merged

Vasyl-Trefilov merged 1 commit into
RustingStudio:mainfrom
sayampy:pr/bench-drafts

Conversation

@sayampy

@sayampy sayampy commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

The text output of strata bench already reports MTP drafts made and accepted (from Runner::finish), but tools reading --json-out cannot see it. Add a drafts object with made and accepted to the main engine's strata.bench.v1 record. 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 --release and the existing bench-record tests.

Comment thread src/main.rs
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});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 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.

Comment thread src/main.rs
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) };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 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.

Comment thread src/main.rs
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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 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.

Comment thread src/main.rs
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});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

aletheore Bot commented Nov 23, 2026

Copy link
Copy Markdown

Aletheore Flash Lite review

What 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.

Merge confidence Review effort Merge risk
2 / 5 1 / 5 Medium
Area Files Lines
src 1 +4 −1

4 finding(s) posted as inline review comment(s).

# Severity Category Where
1 🟠 High Correctness main.rs:1343 Non-GPU runners are reported as zero drafts, indistinguishable from a GPU run with no drafts. For a CPU or…
2 🟠 High Correctness main.rs:1342 Tuple field order (made, accepted) is assumed, not checked against g.drafts. The code maps drafts.0 to "made"…
3 🟠 High Correctness main.rs:1341 Comment overstates the source as 'reliable' while non-GPU runs fill in zeros. The comment says this gives…
4 🔵 Low Maintainability main.rs:1343 Drafts are patched into the record after construction instead of passed to bench_record. bench_record builds…
Review details

Reviewed 1 file(s); skipped 0. Dismissed 0; outside PR diff 0. Grounding: 4 of 4 proposed finding(s).

Fix all with your 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.

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.

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.

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.

@aletheore

aletheore Bot commented Nov 23, 2026

Copy link
Copy Markdown

🔍 Aletheore evidence diff

What changed
Deterministic, computed from this commit's real scan and import graph - posted on every run, whether or not Flash Review found anything.

  • src/main.rs · modified · +4/-1

Aggregate deltas

  • Modules: +0
  • Dependency graph edges: +0
  • Commits: 1

@Vasyl-Trefilov
Vasyl-Trefilov merged commit 7f91a3e into RustingStudio:main Nov 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants