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

feat: widget benchmarking #2897

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ add_subdirectory(decrypt_bench)
add_subdirectory(pippenger_bench)
add_subdirectory(plonk_bench)
add_subdirectory(honk_bench)
add_subdirectory(relations_bench)
add_subdirectory(relations_bench)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Each source represents a separate benchmark suite
set(BENCHMARK_SOURCES
standard_plonk.bench.cpp
ultra_honk.bench.cpp
ultra_plonk.bench.cpp
standard_plonk.bench.cpp
ultra_honk.bench.cpp
ultra_plonk.bench.cpp
)

# Required libraries for benchmark suites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ template <typename Builder> void generate_basic_arithmetic_circuit(Builder& buil
proof_system::plonk::stdlib::field_t b(
proof_system::plonk::stdlib::witness_t(&builder, barretenberg::fr::random_element()));
proof_system::plonk::stdlib::field_t c(&builder);
if (num_gates < 4) {
throw std::runtime_error("too few gates");
}
for (size_t i = 0; i < (num_gates / 4) - 4; ++i) {
c = a + b;
c = a * c;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Each source represents a separate benchmark suite
set(BENCHMARK_SOURCES
barycentric.bench.cpp
relations.bench.cpp
barycentric.bench.cpp
relations.bench.cpp
widget.bench.cpp
)

# Required libraries for benchmark suites
set(LINKED_LIBRARIES
polynomials
proof_system
benchmark::benchmark
transcript
stdlib_primitives
)

# Add executable and custom target for each suite, e.g. ultra_honk_bench
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp"
#include "barretenberg/honk/flavor/goblin_ultra.hpp"
#include "barretenberg/honk/flavor/ultra.hpp"
#include "barretenberg/plonk/composer/standard_composer.hpp"
#include "barretenberg/plonk/composer/ultra_composer.hpp"
#include "barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_auxiliary_widget.hpp"
#include <benchmark/benchmark.h>

namespace {
auto& engine = numeric::random::get_debug_engine();
}

namespace proof_system::plonk {

template <typename Flavor, typename Widget> void execute_widget(::benchmark::State& state)
{
barretenberg::srs::init_crs_factory("../srs_db/ignition");
auto inner_composer = plonk::UltraComposer();
auto builder = typename plonk::UltraComposer::CircuitBuilder();
bench_utils::generate_basic_arithmetic_circuit(builder, 80);
auto inner_prover = inner_composer.create_prover(builder);
auto inner_proof = inner_prover.construct_proof();
for (auto _ : state) {
Widget widget(inner_composer.circuit_proving_key.get());
widget.compute_quotient_contribution(barretenberg::fr::random_element(), inner_prover.transcript);
}
}

void plookup_auxiliary_widget(::benchmark::State& state) noexcept
{
execute_widget<honk::flavor::Ultra, ProverPlookupAuxiliaryWidget<ultra_settings>>(state);
}
BENCHMARK(plookup_auxiliary_widget);

} // namespace proof_system::plonk
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,12 @@ UltraProver UltraComposer::create_prover(CircuitBuilder& circuit_constructor)

UltraProver output_state(circuit_proving_key, create_manifest(circuit_constructor.public_inputs.size()));

std::unique_ptr<ProverPermutationWidget<4, true>> permutation_widget =
std::make_unique<ProverPermutationWidget<4, true>>(circuit_proving_key.get());

std::unique_ptr<ProverPlookupWidget<>> plookup_widget =
std::make_unique<ProverPlookupWidget<>>(circuit_proving_key.get());

std::unique_ptr<ProverPlookupArithmeticWidget<ultra_settings>> arithmetic_widget =
std::make_unique<ProverPlookupArithmeticWidget<ultra_settings>>(circuit_proving_key.get());

std::unique_ptr<ProverGenPermSortWidget<ultra_settings>> sort_widget =
std::make_unique<ProverGenPermSortWidget<ultra_settings>>(circuit_proving_key.get());

std::unique_ptr<ProverEllipticWidget<ultra_settings>> elliptic_widget =
std::make_unique<ProverEllipticWidget<ultra_settings>>(circuit_proving_key.get());

std::unique_ptr<ProverPlookupAuxiliaryWidget<ultra_settings>> auxiliary_widget =
std::make_unique<ProverPlookupAuxiliaryWidget<ultra_settings>>(circuit_proving_key.get());
auto permutation_widget = std::make_unique<ProverPermutationWidget<4, true>>(circuit_proving_key.get());
auto plookup_widget = std::make_unique<ProverPlookupWidget<>>(circuit_proving_key.get());
auto arithmetic_widget = std::make_unique<ProverPlookupArithmeticWidget<ultra_settings>>(circuit_proving_key.get());
auto sort_widget = std::make_unique<ProverGenPermSortWidget<ultra_settings>>(circuit_proving_key.get());
auto elliptic_widget = std::make_unique<ProverEllipticWidget<ultra_settings>>(circuit_proving_key.get());
auto auxiliary_widget = std::make_unique<ProverPlookupAuxiliaryWidget<ultra_settings>>(circuit_proving_key.get());

output_state.random_widgets.emplace_back(std::move(permutation_widget));
output_state.random_widgets.emplace_back(std::move(plookup_widget));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ class FFTGetter : public BaseGetter<Field, Transcript, Settings, num_widget_rela
return polynomials
.coefficients[id][(ptrdiff_t)((index + polynomials.index_shift) & polynomials.block_mask)];
}
// This ID should exist
ASSERT(polynomials.coefficients.count(id) > 0);
return polynomials.coefficients[id][(ptrdiff_t)index];
}
};
Expand Down Expand Up @@ -316,6 +318,7 @@ class TransitionWidget : public TransitionWidgetBase<Field> {
const transcript::StandardTranscript& transcript) override
{
auto* key = TransitionWidgetBase<Field>::key;
ASSERT(key != nullptr);

// Get the set IDs for the polynomials required by the widget
auto& required_polynomial_ids = FFTKernel::get_required_polynomial_ids();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void Transcript::apply_fiat_shamir(const std::string& challenge_name /*, const b
if (current_round > 0) {
buffer.insert(buffer.end(), current_challenge.data.begin(), current_challenge.data.end());
}
for (auto manifest_element : manifest.get_round_manifest(current_round).elements) {
for (const auto& manifest_element : manifest.get_round_manifest(current_round).elements) {
info_togglable("apply_fiat_shamir(): manifest element name match:");
info_togglable("\t element name: ", manifest_element.name);
info_togglable(
Expand Down