Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
be4cb02
perf: enable advisory scalar deduplication for AVM wires
IlyasRidhuan Nov 5, 2026
e0b646c
uint256: accelerate single-limb division and remainder
Oct 11, 2026
97231dd
keccak: normalize sparse chunks using single-limb division
Oct 11, 2026
4e03a2a
perf(msm): fused scalar batch-affine drain for native Stage 6a
Oct 11, 2026
3a431c7
perf(translator): fetch only grand-product columns per row
Oct 11, 2026
d6eb175
perf(sumcheck): skip fold multiply for bit-identical neighbour pairs
Oct 11, 2026
b45aede
perf(ecc): batched variable-time divsteps in Bernstein-Yang inverse
Oct 11, 2026
2990668
perf(sumcheck): fold subrelation separators into Poseidon2 quad relat…
Oct 11, 2026
5391b36
perf(sumcheck): skip databus lookup rows of other bus columns
Oct 11, 2026
2319bf6
perf(dsl): move decoded ACIR enum variants instead of copying; string…
Oct 11, 2026
c414110
perf(dsl): stream msgpack-compact ACIR program and witness decoding
Oct 11, 2026
a3609ec
perf(uintx): skip multiplications by zero halves
Oct 11, 2026
aefda27
perf(field): compile-time one() and neg_one()
Oct 11, 2026
b39c365
perf(threading): lock-free parallel_for pool with bounded spin before…
Oct 11, 2026
ee798b3
perf(poseidon2): shorter critical path in native permutation rounds
Oct 11, 2026
6f093c7
perf(sha256): x86 SHA extensions and streaming input for native sha256
Oct 11, 2026
9740ed9
perf(polynomials): tile add_scaled_batch and skip zero source coeffic…
Oct 11, 2026
f0bd7f1
perf(oink): parallel, range-limited log-derivative inverse computation
Oct 11, 2026
8a1812c
perf(honk): fill only the permutation columns of the grand-product row
Oct 11, 2026
df978ed
perf(polynomials): Horner per thread chunk in polynomial evaluate
Oct 11, 2026
eb67754
perf(sumcheck): drop memory relation terms of gate types absent from …
Oct 11, 2026
5accd5f
perf(keccak): divide by multi-limb powers of 11 via chained single-li…
Oct 11, 2026
025801c
bigfield: cache fixed CRT bounds and unreduced zero
Oct 11, 2026
cfa6368
bigfield: use the proven 512-bit subtraction borrow bound
Oct 11, 2026
fa5bf7b
perf(keccak): runtime slice loop in normalize_and_rotate
Oct 11, 2026
3777c68
perf(field_t): compile-time Montgomery 1 and -1
Oct 11, 2026
0e7693b
perf(joint): fold both circuits' sumcheck tables in one largest-first…
Oct 11, 2026
b72bc5c
perf(pcs): parallel batched linear quotients for Shplonk and KZG
Oct 11, 2026
fc230c7
perf(gemini): single pass for the partially evaluated batch polynomials
Oct 11, 2026
8f9720e
perf(multilinear_batching): batched merge in compute_new_claim
Oct 11, 2026
d56a5da
perf(msm): AVX-512 IFMA batch-affine drain for native Stage 6a
Oct 11, 2026
278b8b4
perf(poseidon2): interleaved S-box layer and shorter internal-matrix …
Oct 11, 2026
713c4bd
perf(eccvm): narrow rows and zero-tail extension for grand product an…
Oct 11, 2026
4ea1f85
eccvm: parallelize independent transcript scalar multiplications
Oct 11, 2026
bdf9f07
eccvm: parallelize MSM trace construction
Oct 11, 2026
17c527e
perf(field): lower-latency ADX Montgomery mul and split-reduction squ…
Oct 11, 2026
6c3e544
perf(msm): run native Stage 6b batched adds on the IFMA drain
Oct 11, 2026
2287e8a
test(msm): IFMA drain edge cases
Oct 11, 2026
36e60c3
perf(pcs): overlap independent recurrences in batched linear quotients
Oct 11, 2026
3a97344
perf(gemini): build A0 = F + G/X in one pass
Oct 11, 2026
2fc4711
perf(gemini): skip zero-initialising the fold polynomials
Oct 11, 2026
3c70651
perf(polynomials): work-balanced thread split in add_scaled_batch
Oct 11, 2026
7fdc248
perf(polynomials): no multiplication for unit scalars in add_scaled_b…
Oct 11, 2026
be24261
perf(polynomials): two interleaved Horner chains in polynomial_arithm…
Oct 11, 2026
5befe02
perf(bigfield): avoid wide divisions on bounds and reduced values
Oct 11, 2026
a0fecb9
perf(bigfield): combine and split limbs with 256-bit shifts
Oct 11, 2026
43536b1
perf(sumcheck): prover fast path for arithmetic gates with q_arith == 1
Oct 11, 2026
436affb
perf(sumcheck): drop absent read/table terms in the log-derivative lo…
Oct 11, 2026
0b39edc
perf(sumcheck): batch the delta-range subrelations on the prover
Oct 11, 2026
14e9d09
test(sumcheck): prover relation paths on edges with gate-like selecto…
Oct 11, 2026
0515749
perf(trace): chunked gate tile storage
Oct 11, 2026
4086204
perf(wasm): build release wasm with -O3 -fno-vectorize instead of -Oz
Oct 11, 2026
378b133
perf(wasm): skip packed fold for blocks of identical neighbour pairs
Oct 11, 2026
edd0bff
perf(wasm): packed batch_two_round_fold (IPA SRS fold)
Oct 11, 2026
d1debbe
perf(bbapi): reference request blobs in place when unpacking msgpack …
Oct 11, 2026
5b7fa14
perf(ipc): free large socket receive buffers once their message is ha…
Oct 11, 2026
c559b17
perf(honk): parallel lookup read counts with integer accumulation
Oct 11, 2026
508f087
perf(trace): parallel copy-cycle counting and fill
Oct 11, 2026
ec81023
perf(databus): compute log-derivative inverse terms from the four col…
Oct 11, 2026
cd0f830
perf(honk): grand product as a running product of per-row ratios
Oct 11, 2026
12bdfe4
perf(sumcheck): AVX-512 IFMA kernel for the stride-2 fold
Oct 11, 2026
75d68ab
perf(polynomials): AVX-512 IFMA tiles in add_scaled_batch
Oct 11, 2026
1c73c4b
perf(polynomials): AVX-512 IFMA Horner chains in polynomial_arithmeti…
Oct 11, 2026
bb2f6cd
perf(ipa): AVX-512 IFMA replay of the two-round SRS fold
Oct 11, 2026
b13186e
perf(sumcheck): AVX-512 IFMA element-wise products of short univariates
Oct 11, 2026
f0833c4
perf(dsl): decode common ACIR opcodes straight from msgpack-compact b…
Oct 11, 2026
b0a688d
perf(transcript): allocate origin tag debug IDs in per-thread blocks
Oct 11, 2026
2890347
perf(dsl): skip zero-scaled terms in the AssertZero gate satisfiabili…
Oct 11, 2026
bbbad2a
perf(sumcheck): back partially evaluated tables on the folded support…
Oct 11, 2026
7f2fdd1
perf(sumcheck): materialize the partially evaluated tables after two …
Oct 11, 2026
c651acb
perf(ultra_honk): let Chonk's prover instances free the circuit data …
Oct 11, 2026
44dae3b
Use bounded reciprocal division for BN254 uint1024 operands
Nov 5, 2026
2c5d693
Batch AVM polynomial coefficients without per-thread full-size scratch
Nov 6, 2026
5381120
Reuse an equal-extent unshifted polynomial for AVM PCS batching
Nov 6, 2026
8a0a76a
Split AVM lookup inverse work into bounded independent row chunks
Nov 6, 2026
3300f45
Reuse AVM lazy edge storage between row pairs
Nov 6, 2026
f60d241
Check AVM inverse edge zero before extension
Nov 6, 2026
660807d
Avoid zeroing fully overwritten AVM fold tables
Nov 6, 2026
bb73b82
Compress AVM lookup endpoint pairs on the selected cumulative source
Nov 6, 2026
4e33303
Parallelize AVM execution trace rows after a deterministic state prepass
Nov 6, 2026
26a2e55
Reuse original AVM inverse terms after tuple columns become virtual zero
Nov 6, 2026
07f9665
Skip native AVM lookup accumulation when both contributions are zero
Nov 6, 2026
47f7e8c
Fill constant AVM linear edges without repeated field additions
Nov 6, 2026
70efcef
Allow a bounded larger native small-MSM aggregate workspace
Nov 7, 2026
8043de0
Cache exact memory-event sort keys beside event pointers
Nov 6, 2026
34988bc
Share the native CPU budget across independent large commitment MSMs
Nov 7, 2026
6da7382
perf(avm): load the CRS while simulating and generating the trace
alejoamiras Nov 10, 2026
d1c1c53
perf(avm): absorb the first challenge's known input during the wire c…
alejoamiras Nov 11, 2026
128a5f8
perf(sumcheck): build large slot accumulators on their threads and su…
alejoamiras Nov 11, 2026
6ae9ba9
perf(avm): batch the sumcheck relations in parallel
alejoamiras Nov 11, 2026
f09c564
perf(avm): keep execution events in a deque
alejoamiras Nov 11, 2026
c8e88cd
perf(avm): write the memory trace rows on all threads
alejoamiras Nov 11, 2026
321ddd1
perf(avm): split large multi-permutation tracegen jobs into parts
alejoamiras Nov 11, 2026
e4f8126
perf(avm): release the proving polynomials' pages in parallel after t…
alejoamiras Nov 11, 2026
95916e8
perf(msm): run wide members of concurrent batches as chunks
alejoamiras Nov 11, 2026
368d0a2
perf(srs): read the cached BN254 CRS with parallel pread
alejoamiras Nov 10, 2026
5e742b4
perf(srs): load the native CRS into uninitialised storage
alejoamiras Nov 10, 2026
6ad387c
perf(common): add a helper that releases a large block's pages from s…
alejoamiras Nov 11, 2026
dd4b49d
perf(srs): release the native CRS's pages in parallel when it is dest…
alejoamiras Nov 11, 2026
9918b7e
perf(srs): read and parse the cached Grumpkin CRS in parallel
alejoamiras Nov 11, 2026
6a092e4
perf(avm): invert lookup rows in chunks of 2^12 rows
alejoamiras Nov 12, 2026
4ecd448
perf(flavor): look up an entity's label by its offset when the entiti…
alejoamiras Nov 12, 2026
f3743e5
perf(avm): free the execution events as a job of the tracegen group
alejoamiras Nov 12, 2026
b4d08c7
perf(avm): fill a long bytecode decomposition in parts of the tracege…
alejoamiras Nov 12, 2026
455e6a6
perf(avm): free the interaction jobs and their shared indices on the …
alejoamiras Nov 12, 2026
d701cfc
perf(bb): release process memory on several threads before a successf…
alejoamiras Nov 12, 2026
6f1de67
perf(bb): keep freed heap memory in AVM and UltraHonk proving
alejoamiras Nov 13, 2026
bf164e2
perf(msm): release the small-member pool's arena slices from their wo…
alejoamiras Nov 13, 2026
0a1cd35
perf(avm): load only the CRS points the proof needs, while building t…
alejoamiras Nov 13, 2026
83ce8b8
perf(avm): size the sumcheck gate separator table to the rows the rou…
alejoamiras Nov 13, 2026
d74379f
perf(sumcheck): scale and zero each relation's accumulators in its ba…
alejoamiras Nov 13, 2026
574b1aa
perf(polynomials): skip the zero-fill dispatch for an empty polynomial
alejoamiras Nov 13, 2026
ad5d421
fix(polynomials): build the page release's fields without the release
alejoamiras Nov 13, 2026
ea02770
perf(sumcheck): schedule the first 256 edges of each AVM round one ed…
alejoamiras Nov 15, 2026
e035911
perf(msm): split costly small batch members across workers for AVM co…
alejoamiras Nov 15, 2026
6d86f5a
fix(msm): mark the native-only scalar drain helpers [[maybe_unused]] …
asterite Nov 26, 2026
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
10 changes: 7 additions & 3 deletions barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
endif()

# We enable -O1 level optimsations, even when compiling debug wasm, otherwise we get "local count too large" at runtime.
# We prioritize reducing size of final artifacts in release with -Oz.
# Release wasm is built with -O3 and the loop vectorizer off: the vectorizer turns field-arithmetic loops into i64x2
# multiplies that V8 lowers to slow sequences (scalar Fr mul 50 ns -> 72 ns), while the rest of -O3 (inlining,
# unrolling) proves ~8% faster than -Oz end to end. The cost is a larger artifact (gzipped ~3.9 MB -> ~5.6 MB);
# configure with -DWASM_RELEASE_OPT=-Oz to prioritise size instead.
if(WASM)
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -g")
set(CMAKE_C_FLAGS_DEBUG "-O1 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-Oz -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-Oz -DNDEBUG")
set(WASM_RELEASE_OPT "-O3 -fno-vectorize" CACHE STRING "Optimisation flags for release WASM builds")
set(CMAKE_CXX_FLAGS_RELEASE "${WASM_RELEASE_OPT} -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${WASM_RELEASE_OPT} -DNDEBUG")
add_link_options(-Wl,--export-memory,--import-memory,--stack-first,-z,stack-size=1048576,--max-memory=4294967296)
endif()

Expand Down
9 changes: 7 additions & 2 deletions barretenberg/cpp/src/barretenberg/api/api_msgpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "barretenberg/bbapi/c_bind.hpp"
#include "barretenberg/common/log.hpp"
#include "barretenberg/serialize/msgpack.hpp"
#include "barretenberg/serialize/msgpack_impl.hpp"
#include <cstdint>
#include <fstream>
#include <iostream>
Expand Down Expand Up @@ -60,7 +61,9 @@ int process_msgpack_commands(std::istream& input_stream)
// Deserialize the msgpack buffer
// The buffer should contain a tuple of arguments (array) matching the bbapi function signature.
// Since bbapi(Command) takes one argument, we expect a 1-element array containing the Command.
auto unpacked = msgpack::unpack(reinterpret_cast<const char*>(buffer.data()), buffer.size());
// The buffer outlives the command's execution, so blobs (bytecode, witnesses, VKs) are referenced in place.
auto unpacked =
msgpack::unpack(reinterpret_cast<const char*>(buffer.data()), buffer.size(), msgpack_reference_input);
auto obj = unpacked.get();

// First, expect an array (the tuple of arguments)
Expand Down Expand Up @@ -213,7 +216,9 @@ int execute_msgpack_ipc_server(std::unique_ptr<ipc::IpcServer> server)
// Deserialize msgpack command
// The buffer should contain a tuple of arguments (array) matching the bbapi function signature.
// Since bbapi(Command) takes one argument, we expect a 1-element array containing the Command.
auto unpacked = msgpack::unpack(reinterpret_cast<const char*>(request.data()), request.size());
// The buffer outlives the command's execution, so blobs (bytecode, witnesses, VKs) are referenced in place.
auto unpacked =
msgpack::unpack(reinterpret_cast<const char*>(request.data()), request.size(), msgpack_reference_input);
auto obj = unpacked.get();

// First, expect an array (the tuple of arguments)
Expand Down
11 changes: 11 additions & 0 deletions barretenberg/cpp/src/barretenberg/bb/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "barretenberg/bbapi/c_bind.hpp"
#include "barretenberg/common/bb_bench.hpp"
#include "barretenberg/common/get_bytecode.hpp"
#include "barretenberg/common/malloc_policy.hpp"
#include "barretenberg/common/memory_profile.hpp"
#include "barretenberg/common/thread.hpp"
#include "barretenberg/common/version.hpp"
Expand Down Expand Up @@ -860,6 +861,16 @@ int parse_and_run_cli_command(int argc, char* argv[])
bb_log_level = LogLevel::VERBOSE;
}
slow_low_memory = flags.slow_low_memory;
// AVM and UltraHonk proving keep freed heap memory for reuse instead of trimming it on one thread mid-proof (see
// command_keeps_heap()); every other command, Chonk included, and --slow_low_memory leave the settings in force
// untouched. This runs before any worker the command creates (mallopt is not thread-safe).
std::string_view command;
for (const CLI::App* subcommand : app.get_subcommands()) {
if (subcommand->parsed()) {
command = subcommand->get_name();
}
}
configure_process_malloc_and_log(command_keeps_heap(command, flags.scheme, flags.slow_low_memory));
#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
if (!flags.storage_budget.empty()) {
storage_budget = parse_size_string(flags.storage_budget);
Expand Down
12 changes: 11 additions & 1 deletion barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "barretenberg/bb/cli.hpp"
#include "barretenberg/common/exit_release.hpp"

#ifdef _WIN32
#include <fcntl.h>
Expand All @@ -14,5 +15,14 @@ int main(int argc, char* argv[])
_setmode(_fileno(stdin), _O_BINARY);
_setmode(_fileno(stdout), _O_BINARY);
#endif
return bb::parse_and_run_cli_command(argc, argv);
const int rc = bb::parse_and_run_cli_command(argc, argv);
if (rc == 0) {
// On success, skip the single-core teardown of the process's memory. Every output file (proof, VK, public
// inputs through write_file's open/write/close; --bench_out*, traces, --memory_profile_out through scoped
// std::ofstream) is closed by now. What a normal exit still writes is written first: the BB_BENCH report of
// ~GlobalBenchStatsContainer, the one writing destructor (bb has no atexit hook), and the buffered streams.
// Whenever that cannot be done safely it returns, and the normal exit runs.
bb::release_memory_and_exit(rc);
}
return rc;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
#include "barretenberg/commitment_schemes/shplonk/shplemini.hpp"
#include "barretenberg/commitment_schemes/small_subgroup_ipa/small_subgroup_ipa.hpp"
#include "barretenberg/common/bb_bench.hpp"
#include "barretenberg/polynomials/fold_stride2.hpp"
#include "barretenberg/polynomials/gate_separator.hpp"
#include "barretenberg/polynomials/row_disabling_polynomial.hpp"
#include "barretenberg/translator_vm/translator_prover.hpp"

#include <algorithm>
#include <optional>
#include <vector>

// Short-monomial translator relation definitions: the joint sumcheck round (TransProverRound) is templated on
// TranslatorShortMonomialFlavor, so this TU instantiates the short relations' prover-side accumulate. The short
// relations are otherwise header-only (no explicit instantiation into librelations), so include the _impl here.
Expand All @@ -20,6 +25,67 @@

namespace bb {

namespace {

/**
* @brief Partially evaluate the MegaZK and translator tables in one parallel region: at one round challenge, or (with
* `second_challenge`) at the first two round challenges straight from the full polynomials.
* @details Equivalent to SumcheckProver::partially_evaluate (respectively partially_evaluate_first_two_rounds) on each
* circuit's tables, but the polynomials of both circuits form a single work list scheduled largest-first, so the
* smaller circuit's folds fill the tail of the larger one's instead of each circuit paying its own load-imbalance tail
* and parallel_for dispatch. Source and destination may alias for a single fold (in-place rounds).
*/
template <typename FF, typename MegaZKSource, typename MegaZKDest, typename TranslatorSource, typename TranslatorDest>
void joint_partially_evaluate(MegaZKSource& mega_zk_source,
MegaZKDest& mega_zk_dest,
TranslatorSource& translator_source,
TranslatorDest& translator_dest,
const FF& round_challenge,
const std::optional<FF>& second_challenge = std::nullopt)
{
struct FoldJob {
const Polynomial<FF>* source;
Polynomial<FF>* dest;
size_t num_outputs;
};
std::vector<FoldJob> jobs;
auto add_jobs = [&](auto& source, auto& dest) {
for (auto [source_poly, dest_poly] : zip_view(source.get_all(), dest.get_all())) {
const auto [begin, end] = second_challenge.has_value() ? twice_folded_backed_range(source_poly)
: folded_backed_range(source_poly);
jobs.push_back({ &source_poly, &dest_poly, end - begin });
}
};
add_jobs(mega_zk_source, mega_zk_dest);
add_jobs(translator_source, translator_dest);
std::stable_sort(
jobs.begin(), jobs.end(), [](const FoldJob& a, const FoldJob& b) { return a.num_outputs > b.num_outputs; });

parallel_for(jobs.size(), [&](size_t j) {
const FoldJob& job = jobs[j];
if (second_challenge.has_value()) {
fold_stride4_backed(*job.source, *job.dest, round_challenge, *second_challenge);
} else {
fold_stride2_backed(*job.source, *job.dest, round_challenge);
}
});

// Halve the active-row prefix to track the folded trace (only tables that carry it).
auto halve_active_prefix = [](auto& source, auto& dest) {
if constexpr (requires {
source.row_skip_active_prefix_end;
dest.row_skip_active_prefix_end;
}) {
dest.row_skip_active_prefix_end =
(source.row_skip_active_prefix_end / 2) + (source.row_skip_active_prefix_end % 2);
}
};
halve_active_prefix(mega_zk_source, mega_zk_dest);
halve_active_prefix(translator_source, translator_dest);
}

} // namespace

BatchedHonkTranslatorProver::BatchedHonkTranslatorProver(std::shared_ptr<MegaZKProverInstance> mega_zk_instance,
std::shared_ptr<MegaZKVK> mega_zk_vk,
std::shared_ptr<Transcript> transcript)
Expand Down Expand Up @@ -122,9 +188,11 @@ void BatchedHonkTranslatorProver::execute_joint_sumcheck_rounds()
auto& mega_zk_params = mega_zk_inst->relation_parameters;
auto& translator_polys = translator_key->proving_key->polynomials;

// Allocate partially evaluated polynomial tables (populated by the first partially_evaluate call).
MegaZKPartialEvals mega_zk_partial(mega_zk_polys, static_cast<size_t>(1) << mega_zk_log_n);
TransPartialEvals translator_partial(translator_polys, static_cast<size_t>(1) << JOINT_LOG_N);
// Allocate partially evaluated polynomial tables, sized for the state after two rounds: round 1 reads the full
// polynomials folded on access, and the tables are populated after it.
BB_ASSERT(mega_zk_log_n >= 2);
MegaZKPartialEvals mega_zk_partial(mega_zk_polys, static_cast<size_t>(1) << mega_zk_log_n, /*num_folds=*/2);
TransPartialEvals translator_partial(translator_polys, static_cast<size_t>(1) << JOINT_LOG_N, /*num_folds=*/2);

// Type aliases for static partial-evaluation helpers from SumcheckProver.
using MegaZKSumcheck = SumcheckProver<MegaZKFlavor>;
Expand Down Expand Up @@ -196,46 +264,41 @@ void BatchedHonkTranslatorProver::execute_joint_sumcheck_rounds()
return send_round(round_idx);
};

// ==================== Round 0: bootstraps mega_zk_partial and translator_partial ====================
// PartiallyEvaluatedMultivariates only allocates output buffers; values are populated here.
// ============ Rounds 0 and 1: bootstrap mega_zk_partial and translator_partial ============
// Round 0 reads the full polynomials and round 1 reads them folded at u_0 on access; the tables are populated
// after round 1 from the full polynomials (PartiallyEvaluatedMultivariates only allocates output buffers).
{
const FF u = do_round(mega_zk_polys, translator_polys, 0);
{
BB_BENCH_NAME("joint_sumcheck/hiding_kernel");
{
BB_BENCH_NAME("joint_sumcheck/hiding_kernel/partially_evaluate");
MegaZKSumcheck::partially_evaluate(mega_zk_polys, mega_zk_partial, u);
}
}
const FF u_0 = do_round(mega_zk_polys, translator_polys, 0);
rdp.update_evaluations(u_0, 0);
mega_zk_round.advance_round();
mega_zk_round.excluded_head_size = 2; // After round 0, disabled zone collapses to 1 edge pair
update_round_state(0, u_0);

using MegaZKFolded = FoldedMultivariatesBase<MegaZKFlavor::AllEntities<FoldedPolynomialView<FF>>,
MegaZKFlavor::ProverPolynomials,
FF>;
using TransFolded = FoldedMultivariatesBase<TranslatorFlavor::AllEntities<FoldedPolynomialView<FF>>,
TranslatorFlavor::ProverPolynomials,
FF>;
const MegaZKFolded mega_zk_folded(mega_zk_polys, u_0);
const TransFolded translator_folded(translator_polys, u_0);
const FF u_1 = do_round(mega_zk_folded, translator_folded, 1);
{
BB_BENCH_NAME("joint_sumcheck/translator");
{
BB_BENCH_NAME("joint_sumcheck/translator/partially_evaluate");
TransSumcheck::partially_evaluate(translator_polys, translator_partial, u);
}
BB_BENCH_NAME("joint_sumcheck/partially_evaluate");
joint_partially_evaluate(
mega_zk_polys, mega_zk_partial, translator_polys, translator_partial, u_0, std::optional<FF>(u_1));
}
rdp.update_evaluations(u, 0);
rdp.update_evaluations(u_1, 1);
mega_zk_round.advance_round();
mega_zk_round.excluded_head_size = 2; // After round 0, disabled zone collapses to 1 edge pair
update_round_state(0, u);
update_round_state(1, u_1);
}

// ==================== Real rounds 1..mega_zk_log_n-1 ====================
for (size_t round_idx = 1; round_idx < mega_zk_log_n; round_idx++) {
// ==================== Real rounds 2..mega_zk_log_n-1 ====================
for (size_t round_idx = 2; round_idx < mega_zk_log_n; round_idx++) {
const FF u = do_round(mega_zk_partial, translator_partial, round_idx);
{
BB_BENCH_NAME("joint_sumcheck/hiding_kernel");
{
BB_BENCH_NAME("joint_sumcheck/hiding_kernel/partially_evaluate_in_place");
MegaZKSumcheck::partially_evaluate_in_place(mega_zk_partial, u);
}
}
{
BB_BENCH_NAME("joint_sumcheck/translator");
{
BB_BENCH_NAME("joint_sumcheck/translator/partially_evaluate_in_place");
TransSumcheck::partially_evaluate_in_place(translator_partial, u);
}
BB_BENCH_NAME("joint_sumcheck/partially_evaluate_in_place");
joint_partially_evaluate(mega_zk_partial, mega_zk_partial, translator_partial, translator_partial, u);
}
rdp.update_evaluations(u, round_idx);
mega_zk_round.advance_round();
Expand Down
7 changes: 5 additions & 2 deletions barretenberg/cpp/src/barretenberg/chonk/chonk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void Chonk::accumulate_hiding_kernel(HidingKernelCircuit& circuit,
}

vinfo("Constructing hiding kernel instance (proving deferred to prove())");
hiding_prover_inst = std::make_shared<HidingKernelProverInstance>(circuit);
hiding_prover_inst = std::make_shared<HidingKernelProverInstance>(circuit, CopiedCircuitData::RELEASE);

// The circuit has been copied into the prover polynomials; free its construction data.
circuit.free_construction_data();
Expand Down Expand Up @@ -195,9 +195,12 @@ HonkProof Chonk::instance_to_accumulator(typename InstanceFlavor::CircuitBuilder
using PI = ProverInstance_<InstanceFlavor>;
BB_ASSERT(vk != nullptr, "Chonk::accumulate_and_fold - VK expected for the provided circuit");

auto prover_instance = std::make_shared<PI>(circuit);
#ifndef NDEBUG
// The debug checks below read the circuit after the instance is built.
auto prover_instance = std::make_shared<PI>(circuit, CopiedCircuitData::KEEP);
debug_incoming_circuit<InstanceFlavor>(circuit, prover_instance, vk);
#else
auto prover_instance = std::make_shared<PI>(circuit, CopiedCircuitData::RELEASE);
#endif
// The circuit has been copied into the prover polynomials; free its construction data.
circuit.free_construction_data();
Expand Down
Loading
Loading