feat(circuit_params): tool to report verifier circuit component sizes#398
Conversation
PR SummaryLow Risk Overview
Reviewed by Cursor Bugbot for commit 8e54217. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #398 +/- ##
==========================================
+ Coverage 67.14% 67.58% +0.44%
==========================================
Files 41 42 +1
Lines 5332 5411 +79
==========================================
+ Hits 3580 3657 +77
- Misses 1752 1754 +2
🚀 New features to boost your workflow:
|
3c6bbf9 to
825649b
Compare
6c7c96b to
ce5906e
Compare
| component("triple_xor", raw.triple_xor, padded.triple_xor), | ||
| component("blake_g_gate", raw.blake_g_gate, padded.blake_g_gate), | ||
| ) | ||
| } |
There was a problem hiding this comment.
Output omits raw row counts
Medium Severity
The binary computes RawSizes for each AIR component but format_sizes only prints padded log and usage. The PR and crate docs describe emitting non-padded row counts per component, so stdout/file output is missing a primary reported field.
Reviewed by Cursor Bugbot for commit ce5906e. Configure here.
There was a problem hiding this comment.
Do we care about this?
There was a problem hiding this comment.
I fixed the doc, I think the usage percentage is more useful than the actual number.
ce5906e to
4d4201e
Compare
YairVaknin-starkware
left a comment
There was a problem hiding this comment.
@YairVaknin-starkware reviewed 5 files and all commit messages, and made 7 comments.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on ilyalesokhin-starkware).
crates/circuit_params/src/main.rs line 43 at r3 (raw file):
fn log_size(size: usize) -> u32 { size.next_power_of_two().ilog2()
doesn't the padding do this already?
Code quote:
next_power_of_two()crates/circuit_params/src/main.rs line 48 at r3 (raw file):
/// The fraction (as a percentage) of the padded (power-of-two) component that is actually used. fn usage_percent(size: usize) -> f64 { 100.0 * size as f64 / size.next_power_of_two() as f64
isn't this basically the padded size (or do u not want to assume N_LANES isn't the max)?
Code quote:
size.next_power_of_two()crates/circuit_params/src/main.rs line 100 at r3 (raw file):
enabled_bits.push(true); } }
This logic too repeats a few times in our various crates. So centralize or add a TODO too.
Code quote:
let mut cairo_components: IndexMap<&'static str, Box<dyn CircuitEval<QM31>>> =
IndexMap::default();
let mut enabled_bits = vec![];
for (name, component) in all_components::<QM31>() {
if DISABLED_COMPONENTS_CANONICAL_PREPROCESSED.contains(&name) {
enabled_bits.push(false);
} else {
cairo_components.insert(name, component);
enabled_bits.push(true);
}
}crates/circuit_params/src/main.rs line 132 at r3 (raw file):
+ circuit.mul.len() + circuit.pointwise_mul.len() + circuit.permutation.iter().map(|p| p.inputs.len() + p.outputs.len()).sum::<usize>();
Can you make the func calcing that from stwo-circuits pub or add a TODO for doing it in the mono repo?
Code quote:
let qm31_ops = circuit.add.len()
+ circuit.sub.len()
+ circuit.mul.len()
+ circuit.pointwise_mul.len()
+ circuit.permutation.iter().map(|p| p.inputs.len() + p.outputs.len()).sum::<usize>();crates/circuit_params/src/main.rs line 154 at r3 (raw file):
.map(|trace_log_size| { let (raw, padded) = leaf_verifier_component_sizes(trace_log_size, args.log_blowup_factor);
let's also allow a range for blowup factors (min_bu..=max_bu)
Code quote:
args.log_blowup_factorcrates/circuit_params/tests/cli_test.rs line 5 at r3 (raw file):
/// Runs the `circuit-params` binary for a single trace log size and checks it prints one info line. #[test] fn run_circuit_params_binary() {
Can this test write to a flie with a FIX logic?
Code quote:
fn run_circuit_params_binary() {| component("triple_xor", raw.triple_xor, padded.triple_xor), | ||
| component("blake_g_gate", raw.blake_g_gate, padded.blake_g_gate), | ||
| ) | ||
| } |
There was a problem hiding this comment.
Do we care about this?
| component("triple_xor", raw.triple_xor, padded.triple_xor), | ||
| component("blake_g_gate", raw.blake_g_gate, padded.blake_g_gate), | ||
| ) | ||
| } |
There was a problem hiding this comment.
I fixed the doc, I think the usage percentage is more useful than the actual number.
|
Previously, YairVaknin-starkware wrote…
I don't want yet another file that changes on every PR. |
|
Previously, YairVaknin-starkware wrote…
What is the use case? |
|
Previously, YairVaknin-starkware wrote…
removed. |
4d4201e to
2cb3b4d
Compare
|
Previously, YairVaknin-starkware wrote…
It is currently not public. |
2cb3b4d to
42bc0b9
Compare
|
Previously, YairVaknin-starkware wrote…
done. |
42bc0b9 to
f546396
Compare
ilyalesokhin-starkware
left a comment
There was a problem hiding this comment.
@ilyalesokhin-starkware made 1 comment.
Reviewable status: 4 of 6 files reviewed, 6 unresolved discussions (waiting on YairVaknin-starkware).
crates/circuit_params/src/main.rs line 100 at r3 (raw file):
Previously, YairVaknin-starkware wrote…
This logic too repeats a few times in our various crates. So centralize or add a TODO too.
Done.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f546396. Configure here.
| + circuit.sub.len() | ||
| + circuit.mul.len() | ||
| + circuit.pointwise_mul.len() | ||
| + circuit.permutation.iter().map(|p| p.inputs.len() + p.outputs.len()).sum::<usize>(); |
There was a problem hiding this comment.
Wrong qm31_ops usage metric
Medium Severity
The qm31_ops usage percentage pairs a hand-rolled raw count (sums of add/sub/mul/pointwise_mul lengths plus permutation input/output counts) with padded.qm31_ops from compute_padded_sizes, which uses the library’s row model (see the nearby TODO for qm31_ops_n_rows). That mismatch makes reported qm31_ops usage and log lines unreliable for sizing decisions.
Reviewed by Cursor Bugbot for commit f546396. Configure here.
There was a problem hiding this comment.
both compute qm31_ops_n_rows in the same way
YairVaknin-starkware
left a comment
There was a problem hiding this comment.
@YairVaknin-starkware reviewed 2 files and all commit messages, made 2 comments, and resolved 6 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ilyalesokhin-starkware).
crates/circuit_params/src/main.rs line 154 at r3 (raw file):
Previously, ilyalesokhin-starkware wrote…
What is the use case?
To print them all at once, but up to you if unnecessary.
| + circuit.sub.len() | ||
| + circuit.mul.len() | ||
| + circuit.pointwise_mul.len() | ||
| + circuit.permutation.iter().map(|p| p.inputs.len() + p.outputs.len()).sum::<usize>(); |
There was a problem hiding this comment.
both compute qm31_ops_n_rows in the same way
…izes Add a `circuit-params` crate with a binary that builds the leaf-prover verifier circuit (CANONICAL preprocessed trace + its component set) for a range of verified trace sizes and prints each AIR component's non-padded row count, padded log size, and usage percentage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
f546396 to
8e54217
Compare
ilyalesokhin-starkware
left a comment
There was a problem hiding this comment.
@ilyalesokhin-starkware resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on ilyalesokhin-starkware).
Merge activity
|



What
Adds a new
circuit-paramscrate with acircuit-paramsbinary that computes the leaf-prover verifier circuit's per-component sizes for the CANONICAL preprocessed trace config, across a range of verified Cairo trace sizes.For each trace log size it prints, per AIR component (
eq,qm31_ops,m31_to_u32,triple_xor,blake_g_gate):log), andusage= non-padded rows /next_power_of_two, rounded to a whole percent).It builds the verifier circuit topology only (
NoValue, viabuild_cairo_verifier_circuit) — no proving — reusingget_pcs_configand the leaf prover'sDISABLED_COMPONENTS_CANONICAL_PREPROCESSEDcomponent set.Usage
Omit
--output-pathto print to stdout.--log_blowup_factormust be 1, 2, or 3 (passed toget_pcs_config).Example output:
Each line is prefixed with the verified trace log size.
Notes
circuit-paramsdepends onleaf-proveronly to reuse the canonical disabled-components list; happy to move that constant instead if the dependency direction is undesirable.🤖 Generated with Claude Code
This change is