-
Notifications
You must be signed in to change notification settings - Fork 598
feat: no longer recompute vk's in CIVC proofs #13590
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
Changes from all commits
7a833ab
33f2bd2
1633a79
7c864a8
dc29c03
177bd39
ccbd8b1
1382798
c91da61
f6b2f9e
9aadff0
93d95ba
64cc855
17b160f
fee32e2
d197965
081d5b4
ce52bba
7591bf8
cd266c1
11b6f24
36c830c
80c077e
50d5b1a
98daf58
b81fb76
1151d1b
12ebf59
54f82bb
18cd4f4
30fa963
5c5f8d6
9e55a51
08b2a61
971b911
d25c3cc
f0f5618
d77d224
1ece81a
292315e
80fc995
406bead
b5d5fcf
1dfbecd
aa2fa12
d4ba5ad
d3d890a
56d2dca
a3923a0
09c68c1
1e30786
9803f72
0c87d96
c72bf4d
79dba97
105d8a3
328bd07
217f9df
f6a5dcf
92591bd
6d09306
9562630
d18dc1f
47005a7
7dfbf42
bb5c13e
b39e65c
410142f
7fa1d0d
f37bfd7
f395a6b
c1b41d1
d54dd07
a7ad083
57f4c60
a718546
cbe5e28
c0146b2
1d19a68
8156584
f5c1de3
8cbc9e6
30f3909
e599155
a2fb716
faf137f
472c744
79d9c2c
e7e8204
e0b0def
3d6f674
2b8fed1
4d5e916
9facb01
b5ef9c5
e8088cd
646c526
7b6f4b2
cabb411
b4852a2
eb41175
55c0e44
53c1ccc
722006a
33901e4
4cf99ed
fb5662f
059fa3f
c2d78cf
564e0a6
3d45f5f
589346c
cefc90d
0aa3206
9ef5b77
e0209c1
a19569d
f2c6a1f
d9044fd
5df58f0
8f7d710
c2dc61a
b8561d0
5713053
e1a7314
c4cae77
4722524
12dc1ce
98e8874
39c4ae5
e5f77a3
09f6c6c
a2a0bbb
259b129
ab8b3a5
fe6a1d7
fa60b49
565a8d5
1db4059
94dd7cd
d41542c
873d61b
d5613bb
57b32e3
9477c85
4891bef
be4d7d4
66f9b2b
a573cb7
1d05a92
8e6ad0d
ad25787
55b82ab
9c2c9b3
457ce81
72acfb6
fc8988a
383f09e
e7c3d63
aa48687
57a240b
55bed56
81cf33e
a8a0ecc
29cf814
d91561d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,23 +6,6 @@ BFLAG="-b ./target/program.json" | |
| FLAGS="-c $CRS_PATH ${VERBOSE:+-v}" | ||
| [ "${RECURSIVE}" = "true" ] && FLAGS+=" --recursive" | ||
|
|
||
| # TODO: Use this when client ivc support write_vk. Currently it keeps its own flow. | ||
| # case ${SYS:-} in | ||
| # "") | ||
| # prove_cmd=prove | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will have to anyway rethink this |
||
| # verify_cmd=verify | ||
| # ;; | ||
| # "client_ivc") | ||
| # prove_cmd=prove | ||
| # verify_cmd=verify | ||
| # flags+=" --scheme client_ivc --input_type ${INPUT_TYPE:-single_circuit}" | ||
| # ;; | ||
| # *) | ||
| # prove_cmd=prove_$SYS | ||
| # verify_cmd=verify_$SYS | ||
| # ;; | ||
| # esac | ||
|
|
||
| # Test we can perform the proof/verify flow. | ||
| # This ensures we test independent pk construction through real/garbage witness data paths. | ||
| # We use process substitution pipes to avoid temporary files, which need cleanup, and can collide with parallelism. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -220,10 +220,9 @@ function bench { | |
| --benchmark_filter="construct_proof_ultrahonk_power_of_2/20$" | ||
| } | ||
| function ultra_honk_wasm { | ||
| wasmtime run --env HARDWARE_CONCURRENCY --env IGNITION_CRS_PATH --env GRUMPKIN_CRS_PATH -Wthreads=y -Sthreads=y --dir=. \ | ||
| ./build-wasm-threads/bin/ultra_honk_bench \ | ||
| --benchmark_out=./bench-out/ultra_honk_wasm.json \ | ||
| --benchmark_filter="construct_proof_ultrahonk_power_of_2/20$" | ||
| scripts/wasmtime.sh ./build-wasm-threads/bin/ultra_honk_bench \ | ||
| --benchmark_out=./bench-out/ultra_honk_wasm.json \ | ||
| --benchmark_filter="construct_proof_ultrahonk_power_of_2/20$" | ||
| } | ||
|
|
||
| # Client IVC | ||
|
|
@@ -243,10 +242,9 @@ function bench { | |
| --benchmark_filter="ClientIVCBench/Full/6$" | ||
| } | ||
| function client_ivc_wasm { | ||
| wasmtime run --env HARDWARE_CONCURRENCY --env IGNITION_CRS_PATH --env GRUMPKIN_CRS_PATH -Wthreads=y -Sthreads=y --dir=. \ | ||
| ./build-wasm-threads/bin/client_ivc_bench \ | ||
| --benchmark_out=./bench-out/client_ivc_wasm.json \ | ||
| --benchmark_filter="ClientIVCBench/Full/6$" | ||
| scripts/wasmtime.sh ./build-wasm-threads/bin/client_ivc_bench \ | ||
| --benchmark_out=./bench-out/client_ivc_wasm.json \ | ||
| --benchmark_filter="ClientIVCBench/Full/6$" | ||
| } | ||
|
|
||
| function run_benchmark { | ||
|
|
@@ -300,7 +298,7 @@ case "$cmd" in | |
| # Takes an optional master commit to download them from. Otherwise, downloads from latest master commit. | ||
| git fetch origin master | ||
|
|
||
| build the benchmarked benches | ||
| # build the benchmarked benches | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh.. how was this working
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it calls 'build' simply :) its valid BASH |
||
| parallel --line-buffered --tag -v denoise ::: \ | ||
| "build_preset $native_preset --target bb_cli_bench" \ | ||
| "build_preset wasm-threads --target bb_cli_bench" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,21 +4,23 @@ | |
| source $(git rev-parse --show-toplevel)/ci3/source | ||
|
|
||
| if [[ $# -ne 2 ]]; then | ||
| echo "Usage: $0 <bench_input_folder> <output_folder>" | ||
| echo "Usage: $0 <bench_input_folder> <benchmark_output>" | ||
| exit 1 | ||
| fi | ||
| export input_folder="$1" | ||
| output_folder="$2" | ||
|
|
||
| cd .. | ||
| export input_folder="$1" | ||
| benchmark_output="$2" | ||
|
|
||
| echo_header "bb ivc flow bench" | ||
|
|
||
| export HARDWARE_CONCURRENCY=16 | ||
| export IGNITION_CRS_PATH=./srs_db/ignition | ||
| export GRUMPKIN_CRS_PATH=./srs_db/grumpkin | ||
| export native_preset=${NATIVE_PRESET:-clang16-assert} | ||
| export native_build_dir=$(scripts/cmake/preset-build-dir $native_preset) | ||
|
|
||
| rm -rf bench-out/ivc && mkdir -p bench-out/ivc | ||
| mkdir -p bench-out | ||
| rm -rf bench-out/ivc-* | ||
|
|
||
| function verify_ivc_flow { | ||
| local flow="$1" | ||
|
|
@@ -28,10 +30,10 @@ function verify_ivc_flow { | |
| # TODO(AD): Checking which one would be good, but there isn't too much that can go wrong here. | ||
| set +e | ||
| echo_stderr "Private verify." | ||
| ./build/bin/bb verify --scheme client_ivc -p "$proof" -k ../../yarn-project/bb-prover/artifacts/private-civc-vk 1>&2 | ||
| "./$native_build_dir/bin/bb" verify --scheme client_ivc -p "$proof" -k ../../yarn-project/bb-prover/artifacts/private-civc-vk 1>&2 | ||
| local private_result=$? | ||
| echo_stderr "Private verify: $private_result." | ||
| ./build/bin/bb verify --scheme client_ivc -p "$proof" -k ../../yarn-project/bb-prover/artifacts/public-civc-vk 1>&2 | ||
| "./$native_build_dir/bin/bb" verify --scheme client_ivc -p "$proof" -k ../../yarn-project/bb-prover/artifacts/public-civc-vk 1>&2 | ||
| local public_result=$? | ||
| echo_stderr "Public verify: $public_result." | ||
| if [[ $private_result -eq $public_result ]]; then | ||
|
|
@@ -44,86 +46,71 @@ function verify_ivc_flow { | |
| fi | ||
| } | ||
|
|
||
| function client_ivc_flow_native { | ||
| set -eu | ||
| local flow=$1 | ||
| local flow_folder="$input_folder/$flow" | ||
| local start=$(date +%s%N) | ||
| mkdir -p "bench-out/$flow-proof-files" | ||
| export MEMUSAGE_OUT="bench-out/$flow-proof-files/peak-memory-native-mb.txt" | ||
|
|
||
| function bb_cli_bench_native { | ||
| export MAIN_ARGS="$*" | ||
| memusage ./build/bin/bb_cli_bench \ | ||
| --benchmark_out=bench-out/$flow-proof-files/op-counts.json \ | ||
| --benchmark_out_format=json || { | ||
| echo "bb_cli_bench failed with args: $*" | ||
| function run_bb_cli_bench { | ||
| local runtime="$1" | ||
| local output="$2" | ||
| local args="$3" | ||
| export MAIN_ARGS="$args" | ||
|
|
||
| if [[ "$runtime" == "native" ]]; then | ||
| memusage "./$native_build_dir/bin/bb_cli_bench" \ | ||
| --benchmark_out=$output/op-counts.json \ | ||
| --benchmark_out_format=json || { | ||
| echo "bb_cli_bench native failed with args: $args" | ||
| exit 1 | ||
| } | ||
| } | ||
|
|
||
| bb_cli_bench_native prove -o "bench-out/$flow-proof-files" -b "$flow_folder/acir.msgpack" -w "$flow_folder/witnesses.msgpack" --scheme client_ivc --input_type runtime_stack | ||
| local end=$(date +%s%N) | ||
| local elapsed_ns=$(( end - start )) | ||
| local elapsed_ms=$(( elapsed_ns / 1000000 )) | ||
| local memory_taken_mb=$(cat "$MEMUSAGE_OUT") | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As noted mostly a refactor, but allows honouring NATIVE_PRESET=op-count-time now with op count times printing. (in the future we may just make op counts part of core bb as they are quite light-weight) |
||
| echo "$flow (native) has proven in $((elapsed_ms / 1000))s and peak memory of ${memory_taken_mb}MB." | ||
| dump_fail "verify_ivc_flow $flow bench-out/$flow-proof-files/proof" | ||
| echo "$flow (native) has verified." | ||
| cat > "./bench-out/ivc/$flow-ivc-native.json" <<EOF | ||
| { | ||
| "benchmarks": [ | ||
| { | ||
| "name": "$flow-ivc-proof", | ||
| "time_unit": "ms", | ||
| "real_time": ${elapsed_ms} | ||
| }, | ||
| { | ||
| "name": "$flow-ivc-proof-memory", | ||
| "time_unit": "MB", | ||
| "real_time": ${elapsed_ms} | ||
| else # wasm | ||
| export WASMTIME_ALLOWED_DIRS="--dir=$flow_folder --dir=$output" | ||
| # TODO support wasm op count time preset | ||
| memusage scripts/wasmtime.sh $WASMTIME_ALLOWED_DIRS ./build-wasm-threads/bin/bb_cli_bench \ | ||
| --benchmark_out=$output/op-counts.json \ | ||
| --benchmark_out_format=json || { | ||
| echo "bb_cli_bench wasm failed with args: $args" | ||
| exit 1 | ||
| } | ||
| ] | ||
| } | ||
| EOF | ||
| fi | ||
| } | ||
|
|
||
| function client_ivc_flow_wasm { | ||
| function client_ivc_flow { | ||
| set -eu | ||
| local flow=$1 | ||
| local runtime="$1" | ||
| local flow="$2" | ||
| local flow_folder="$input_folder/$flow" | ||
| local start=$(date +%s%N) | ||
| mkdir -p "bench-out/$flow-proof-files" | ||
| export MEMUSAGE_OUT="bench-out/$flow-proof-files/peak-memory-wasm-mb.txt" | ||
|
|
||
| function bb_cli_bench_wasm { | ||
| export MAIN_ARGS="$*" | ||
| export WASMTIME_ALLOWED_DIRS="--dir=$HOME/.bb-crs --dir="$flow_folder" --dir=bench-out/$flow-proof-files" | ||
| memusage scripts/wasmtime.sh $WASMTIME_ALLOWED_DIRS ./build-wasm-threads/bin/bb_cli_bench \ | ||
| --benchmark_out=bench-out/$flow-proof-files/op-counts.json \ | ||
| --benchmark_out_format=json || { | ||
| echo "bb_cli_bench failed with args: $*" | ||
| exit 1 | ||
| } | ||
| } | ||
| bb_cli_bench_wasm prove -o "bench-out/$flow-proof-files" -b "$flow_folder/acir.msgpack" -w "$flow_folder/witnesses.msgpack" --scheme client_ivc --input_type runtime_stack | ||
| local output="bench-out/ivc-$flow-$runtime" | ||
| rm -rf "$output" | ||
| mkdir -p "$output" | ||
| export MEMUSAGE_OUT="$output/peak-memory-$runtime-mb.txt" | ||
|
|
||
| run_bb_cli_bench "$runtime" "$output" "prove -o $output --ivc_inputs_path $flow_folder/ivc-inputs.msgpack --scheme client_ivc" | ||
|
|
||
| if [ -f "$output/op-counts.json" ]; then | ||
| scripts/google-bench/summarize-op-counts "$output/op-counts.json" | ||
| fi | ||
|
|
||
| local end=$(date +%s%N) | ||
| local elapsed_ns=$(( end - start )) | ||
| local elapsed_ms=$(( elapsed_ns / 1000000 )) | ||
| local memory_taken_mb=$(cat "$MEMUSAGE_OUT") | ||
| echo "$flow (WASM) has proven in ${elapsed_ms}ms and peak memory of ${memory_taken_mb}MB." | ||
| dump_fail "verify_ivc_flow $flow bench-out/$flow-proof-files/proof" | ||
| echo "$flow (WASM) has verified." | ||
| cat > "./bench-out/ivc/$flow-ivc-wasm.json" <<EOF | ||
|
|
||
| echo "$flow ($runtime) has proven in $((elapsed_ms / 1000))s and peak memory of ${memory_taken_mb}MB." | ||
| dump_fail "verify_ivc_flow $flow $output/proof" | ||
| echo "$flow ($runtime) has verified." | ||
|
|
||
| local runtime_suffix="" | ||
| [[ "$runtime" == "wasm" ]] && runtime_suffix="-wasm" | ||
|
|
||
| cat > "$output/benchmarks.json" <<EOF | ||
| { | ||
| "benchmarks": [ | ||
| { | ||
| "name": "$flow-ivc-proof-wasm", | ||
| "name": "$flow-ivc-proof$runtime_suffix", | ||
| "time_unit": "ms", | ||
| "real_time": ${elapsed_ms} | ||
| }, | ||
| { | ||
| "name": "$flow-ivc-proof-wasm-memory", | ||
| "name": "$flow-ivc-proof$runtime_suffix-memory", | ||
| "time_unit": "MB", | ||
| "real_time": ${memory_taken_mb} | ||
| } | ||
|
|
@@ -140,7 +127,7 @@ function run_benchmark { | |
| taskset -c $start_core-$end_core bash -c "$2" | ||
| } | ||
|
|
||
| export -f verify_ivc_flow client_ivc_flow_native client_ivc_flow_wasm run_benchmark | ||
| export -f verify_ivc_flow client_ivc_flow run_bb_cli_bench run_benchmark | ||
|
|
||
| # TODO this does not work with smaller core counts - we will soon have a benchmark-wide mechanism for this. | ||
| num_cpus=$(get_num_cpus) | ||
|
|
@@ -149,15 +136,16 @@ jobs=$((num_cpus / HARDWARE_CONCURRENCY)) | |
| # Split up the flows into chunks to run in parallel - otherwise we run out of CPUs to pin. | ||
| if [ -n "${IVC_BENCH:-}" ]; then | ||
| # If IVC_BENCH is set, run only that benchmark. | ||
| run_benchmark 1 "client_ivc_flow_native $IVC_BENCH" | ||
| run_benchmark 1 "client_ivc_flow_wasm $IVC_BENCH" | ||
| run_benchmark 1 "client_ivc_flow native $IVC_BENCH" | ||
| run_benchmark 1 "client_ivc_flow wasm $IVC_BENCH" | ||
| else | ||
| parallel -v --line-buffer --tag --jobs "$jobs" run_benchmark {#} '"client_ivc_flow_native {}"' ::: $(ls "$input_folder") | ||
| parallel -v --line-buffer --tag --jobs "$jobs" run_benchmark {#} '"client_ivc_flow_wasm {}"' ::: $(ls "$input_folder") | ||
| for runtime in native wasm; do | ||
| parallel -v --line-buffer --tag --jobs "$jobs" run_benchmark {#} '"client_ivc_flow '$runtime' {}"' ::: $(ls "$input_folder") | ||
| done | ||
| fi | ||
|
|
||
| mkdir -p "$output_folder" | ||
| mkdir -p "$benchmark_output" | ||
|
|
||
| ../scripts/combine_benchmarks.py \ | ||
| ./bench-out/ivc/*.json \ | ||
| > $output_folder/ivc-bench.json | ||
| ./bench-out/*/benchmarks.json \ | ||
| > $benchmark_output/ivc-bench.json | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this issue be closed? I see it doesn't have a description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. it was the old acir benchmarks. they're probably not coming back at this point