-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Faster CIV benching with mocked VKs (#8843)
Rather than going through a whole separate (and more expensive) CIVC prover flow to get vks, we just use random group elements. In order to get assurance that the benchmark is still a good reflection of performance, we refactor the functions used in the benchmark to create an equivalent test.
- Loading branch information
1 parent
a02370c
commit fad3d6e
Showing
6 changed files
with
145 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
barretenberg/cpp/src/barretenberg/client_ivc/test_bench_shared.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
#include "barretenberg/client_ivc/client_ivc.hpp" | ||
#include "barretenberg/client_ivc/mock_circuit_producer.hpp" | ||
#include "barretenberg/common/op_count.hpp" | ||
#include "barretenberg/goblin/mock_circuits.hpp" | ||
#include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" | ||
#include "barretenberg/ultra_honk/ultra_verifier.hpp" | ||
|
||
namespace bb { | ||
|
||
/** | ||
* @brief Verify an IVC proof | ||
* | ||
*/ | ||
bool verify_ivc(ClientIVC::Proof& proof, ClientIVC& ivc) | ||
{ | ||
auto verifier_inst = | ||
std::make_shared<DeciderVerificationKey_<MegaFlavor>>(ivc.verification_queue[0].honk_verification_key); | ||
bool verified = ivc.verify(proof, { ivc.verifier_accumulator, verifier_inst }); | ||
|
||
// This is a benchmark, not a test, so just print success or failure to the log | ||
if (verified) { | ||
info("IVC successfully verified!"); | ||
} else { | ||
info("IVC failed to verify."); | ||
} | ||
return verified; | ||
} | ||
|
||
/** | ||
* @brief Perform a specified number of circuit accumulation rounds | ||
* | ||
* @param NUM_CIRCUITS Number of circuits to accumulate (apps + kernels) | ||
*/ | ||
void perform_ivc_accumulation_rounds(size_t NUM_CIRCUITS, | ||
ClientIVC& ivc, | ||
auto& precomputed_vks, | ||
const bool& mock_vk = false) | ||
{ | ||
ASSERT(precomputed_vks.size() == NUM_CIRCUITS); // ensure presence of a precomputed VK for each circuit | ||
|
||
PrivateFunctionExecutionMockCircuitProducer circuit_producer; | ||
|
||
for (size_t circuit_idx = 0; circuit_idx < NUM_CIRCUITS; ++circuit_idx) { | ||
MegaCircuitBuilder circuit; | ||
{ | ||
BB_OP_COUNT_TIME_NAME("construct_circuits"); | ||
circuit = circuit_producer.create_next_circuit(ivc); | ||
} | ||
|
||
ivc.accumulate(circuit, precomputed_vks[circuit_idx], mock_vk); | ||
} | ||
} | ||
|
||
std::vector<std::shared_ptr<typename MegaFlavor::VerificationKey>> mock_verification_keys(const size_t num_circuits) | ||
{ | ||
|
||
std::vector<std::shared_ptr<typename MegaFlavor::VerificationKey>> vkeys; | ||
|
||
for (size_t idx = 0; idx < num_circuits; ++idx) { | ||
auto key = std::make_shared<typename MegaFlavor::VerificationKey>(); | ||
for (auto& commitment : key->get_all()) { | ||
commitment = MegaFlavor::Commitment::random_element(); | ||
} | ||
vkeys.push_back(key); | ||
} | ||
|
||
return vkeys; | ||
} | ||
|
||
} // namespace bb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fad3d6e
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.
Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.05
.wasmClientIVCBench/Full/6
96144.082579
ms/iter91525.805055
ms/iter1.05
This comment was automatically generated by workflow using github-action-benchmark.
CC: @ludamad @codygunton