Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Supernova benchmarks and config for CI #253

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

samuelburnham
Copy link
Member

This PR refactors the Supernova benchmarks to reduce duplicated code and enables configuration of the constraint numbers used in the benchmarks via the ARECIBO_NUM_CONS env var.

  • Factors out common functionality into benches/common/supernova. The bench_snark_internal_with_arity function is a bit hacky, as the S1, S2 trait bounds are required but unused by the recursive SNARK. There is surely a better trait solution but this seemed simplest for now.
  • Creates a new supernova-ci benchmark to run the RecursiveSNARKSuperNova-2circuit and CompressedSNARKSuperNova-Commitments-2circuit with 16384/1038732 constraints to get a good idea of perf changes on each PR, and updates CI accordingly.
    • I tried to configure the benchmark targets directly by quote!-ing a vector of strings into a list of tokens and passing that to the criterion_group! targets, but it expected a path specifier instead of an expr so this was unsuccessful. Other than this I couldn't think of a way to configure which targets to run besides feature configuration or the implemented solution of creating a new benchmark.
  • Sets the noise threshold to 0.30 to reduce noise (e.g. 🚨 Performance regression in #238 #248, 🚨 Performance regression in #242 #251)

Copy link
Member

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

Very encouraging, and I'm ok with the type hackery for now.

benches/justfile Outdated
gpu-bench-ci +benches:
#!/bin/sh
for bench in {{benches}}; do
cargo criterion --bench $bench --features "cuda" --message-format=json > "$bench-{{commit}}".json
cargo criterion --bench $bench --features "cuda,asm" --message-format=json > "$bench-{{commit}}".json
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure all uses of this justfile are on x86_64? If not, the ASM feature will cause a panic here.

We may want to add at least a code comment, if not running arch beforehand and doing the feature selection in function.

// we vary the number of constraints in the step circuit
for &num_cons_in_augmented_circuit in num_cons().iter() {
// number of constraints in the step circuit
let num_cons = num_cons_in_augmented_circuit - NUM_CONS_VERIFIER_CIRCUIT_PRIMARY;
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, so this is the problem: in bench mode, that substraction has wrapping semantics, and if a missed update of the cons numbers makes it wrap around, the benches will silently start eating up the bench machine's memory. We should do checked_sub(..).expect("constraint numbers out of date!!") here

Comment on lines 28 to 31
// This should match the value in test_supernova_recursive_circuit_pasta
// TODO: This should also be a table matching the num_augmented_circuits in the below
pub const NUM_CONS_VERIFIER_CIRCUIT_PRIMARY: usize = 9844;
pub const NUM_SAMPLES: usize = 10;
Copy link
Member

Choose a reason for hiding this comment

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

Not-so-fun part: this number is meant to be meaningfully different for the nova and supernova use cases. We may want to document that.
This number is also a footgun waiting to happen, see my note on let num_cons = ...

Copy link
Member

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

This is excellent, and much more secure, thanks a ton!

@samuelburnham samuelburnham added this pull request to the merge queue Jan 12, 2024
Merged via the queue into lurk-lab:dev with commit 2066ae4 Jan 12, 2024
10 checks passed
@samuelburnham samuelburnham deleted the bench-refactor branch January 12, 2024 14:55
huitseeker pushed a commit to huitseeker/arecibo that referenced this pull request Jan 14, 2024
gabriel-barrett pushed a commit to gabriel-barrett/arecibo that referenced this pull request Feb 9, 2024
* optimize ppsnark (lurk-lab#252)

* optimize; check claims about Az,Bz,Cz

* add rayon

* Use rayon for computing evaluations in prove_helper in parallel (lurk-lab#253)

* add rayon for prove_inner

* version

---------

Co-authored-by: Srinath Setty <srinath@microsoft.com>
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.

🚨 Performance regression in #242 🚨 Performance regression in #238
2 participants