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: reduce max memory in translator by freeing accumulator and eccvm #8253

Merged
merged 5 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 4 additions & 1 deletion barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ ClientIVC::Proof ClientIVC::prove()
ASSERT(merge_verification_queue.size() == 1); // ensure only a single merge proof remains in the queue
FoldProof& fold_proof = verification_queue[0].proof;
MergeProof& merge_proof = merge_verification_queue[0];
return { fold_proof, decider_prove(), goblin.prove(merge_proof) };
HonkProof decider_proof = decider_prove();
// Free the accumulator to save memory
fold_output.accumulator = nullptr;
return { fold_proof, std::move(decider_proof), goblin.prove(merge_proof) };
};

bool ClientIVC::verify(const Proof& proof,
Expand Down
49 changes: 36 additions & 13 deletions barretenberg/cpp/src/barretenberg/goblin/goblin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ class GoblinProver {
// on the first call to accumulate there is no merge proof to verify
bool merge_proof_exists{ false };

std::shared_ptr<ECCVMProvingKey> get_eccvm_proving_key() const { return eccvm_prover->key; }
std::shared_ptr<ECCVMProvingKey> get_eccvm_proving_key() const { return eccvm_key; }
std::shared_ptr<TranslatorProvingKey> get_translator_proving_key() const { return translator_prover->key; }

private:
// TODO(https://github.com/AztecProtocol/barretenberg/issues/798) unique_ptr use is a hack
std::unique_ptr<ECCVMBuilder> eccvm_builder;
std::unique_ptr<TranslatorBuilder> translator_builder;
std::unique_ptr<TranslatorProver> translator_prover;
std::unique_ptr<ECCVMProver> eccvm_prover;
std::shared_ptr<ECCVMProvingKey> eccvm_key;

GoblinAccumulationOutput accumulator; // Used only for ACIR methods for now

Expand Down Expand Up @@ -171,23 +170,47 @@ class GoblinProver {
*/
void prove_eccvm()
{
eccvm_builder = std::make_unique<ECCVMBuilder>(op_queue);
eccvm_prover = std::make_unique<ECCVMProver>(*eccvm_builder);
goblin_proof.eccvm_proof = eccvm_prover->construct_proof();
goblin_proof.translation_evaluations = eccvm_prover->translation_evaluations;
};
{
ZoneScopedN("Create ECCVMBuilder");
auto eccvm_builder = std::make_unique<ECCVMBuilder>(op_queue);
ZoneScopedN("Create ECCVMProver");
eccvm_prover = std::make_unique<ECCVMProver>(*eccvm_builder);
}
{
ZoneScopedN("Construct ECCVM Proof");
goblin_proof.eccvm_proof = eccvm_prover->construct_proof();
}

{
ZoneScopedN("Assign Translation Evaluations");
goblin_proof.translation_evaluations = eccvm_prover->translation_evaluations;
}
}

/**
* @brief Construct a translator proof
*
*/
void prove_translator()
{
translator_builder = std::make_unique<TranslatorBuilder>(
eccvm_prover->translation_batching_challenge_v, eccvm_prover->evaluation_challenge_x, op_queue);
translator_prover = std::make_unique<TranslatorProver>(*translator_builder, eccvm_prover->transcript);
goblin_proof.translator_proof = translator_prover->construct_proof();
};
fq translation_batching_challenge_v = eccvm_prover->translation_batching_challenge_v;
fq evaluation_challenge_x = eccvm_prover->evaluation_challenge_x;
std::shared_ptr<Transcript> transcript = eccvm_prover->transcript;
eccvm_key = eccvm_prover->key;
eccvm_prover = nullptr;
{
ZoneScopedN("Create TranslatorBuilder");
auto translator_builder =
std::make_unique<TranslatorBuilder>(translation_batching_challenge_v, evaluation_challenge_x, op_queue);
ZoneScopedN("Create TranslatorProver");
translator_prover = std::make_unique<TranslatorProver>(*translator_builder, transcript);
}

{
ZoneScopedN("Construct Translator Proof");
goblin_proof.translator_proof = translator_prover->construct_proof();
}
}

/**
* @brief Constuct a full Goblin proof (ECCVM, Translator, merge)
Expand Down
Loading