-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(circuit_prover): Add circuit prover (#2908)
### Summary This PR introduces a new component `circuit_prover`, which is multiple WVGs & GPU prover running together, groupless. The changes are non-destructive, old setup and new setup must work together in-tandem. ### What? Circuit prover is a component that runs X WVGs alongside a GPU prover. Making full use of CPUs on the GPU machine, WVGs as a component can be removed altogether. Prover groups are not needed anymore. Based on empiric testing we can (almost -- there will be follow-up fixes to make it efficient) fully run everything on a single machine. The current implementation can sunset the old setup. Current metrics show that circuit prover is > 60% efficient than old one (but quirks are needed for node proofs to unlock it -- will be treated as a follow-up). The purpose is to have the `circuit_prover` deprecate old `prover_fri` & `witness_vector_generator`. ### Why? The changes will allow us to reduce our infrastructure footprint by ~2x and fix plenty of issues we had in the past. Namely: - fully decoupled of GCP - better resource utilization & reduce costs - reduce overall infrastructure needs (which solves the GPU unavailability we've been facing) - reduce complexity & other inefficiencies (no more prover groups!) - and more ### Ask We want to unblock folks running on AWS. This PR is done as is to speed up release process on DevOps side, as it's the longest pole. NOTE: This is the first PR out of a longer set of PRs. Comments are more than welcome, but the following concerns will be addressed in follow-up PRs and are out of scope for this PR: - tracing implementation is subpar; in fact, I'm confident that most metrics could be done via traces - there's a lot of code duplication (both old/new prover, but runner interface between new WVG & CP) - tests - concern separation between job scheduling & job execution - job priority based on resource consumption - other nits (such as no README, constants being hard-coded instead of configuration, etc.) ### Reviewer suggestion This is basically a merge between `prover_fri`, `witness_vector_generation` and `JobProcessor`. Checking code alongside should give you a better view of what's going on. Sorry for making this hard. :/
- Loading branch information
Showing
26 changed files
with
1,484 additions
and
20 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[package] | ||
name = "zksync_circuit_prover" | ||
version.workspace = true | ||
edition.workspace = true | ||
authors.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
license.workspace = true | ||
keywords.workspace = true | ||
categories.workspace = true | ||
|
||
[dependencies] | ||
tokio = { workspace = true, features = ["macros", "time"] } | ||
tokio-util.workspace = true | ||
anyhow.workspace = true | ||
async-trait.workspace = true | ||
tracing.workspace = true | ||
bincode.workspace = true | ||
clap = { workspace = true, features = ["derive"] } | ||
|
||
zksync_config.workspace = true | ||
zksync_object_store.workspace = true | ||
zksync_prover_dal.workspace = true | ||
zksync_prover_fri_types.workspace = true | ||
zksync_prover_fri_utils.workspace = true | ||
zksync_queued_job_processor.workspace = true | ||
zksync_types.workspace = true | ||
zksync_prover_keystore = { workspace = true, features = ["gpu"] } | ||
zksync_env_config.workspace = true | ||
zksync_core_leftovers.workspace = true | ||
zksync_utils.workspace = true | ||
|
||
vise.workspace = true | ||
shivini = { workspace = true, features = [ | ||
"circuit_definitions", | ||
"zksync", | ||
] } | ||
zkevm_test_harness.workspace = true |
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,39 @@ | ||
use std::{ops::Mul, time::Duration}; | ||
|
||
/// Backoff - convenience structure that takes care of backoff timings. | ||
#[derive(Debug, Clone)] | ||
pub struct Backoff { | ||
base_delay: Duration, | ||
current_delay: Duration, | ||
max_delay: Duration, | ||
} | ||
|
||
impl Backoff { | ||
/// The delay multiplication coefficient. | ||
// Currently it's hardcoded, but could be provided in the constructor. | ||
const DELAY_MULTIPLIER: u32 = 2; | ||
|
||
/// Create a backoff with base_delay (first delay) and max_delay (maximum delay possible). | ||
pub fn new(base_delay: Duration, max_delay: Duration) -> Self { | ||
Backoff { | ||
base_delay, | ||
current_delay: base_delay, | ||
max_delay, | ||
} | ||
} | ||
|
||
/// Get current delay, handling future delays if needed | ||
pub fn delay(&mut self) -> Duration { | ||
let delay = self.current_delay; | ||
self.current_delay = self | ||
.current_delay | ||
.mul(Self::DELAY_MULTIPLIER) | ||
.min(self.max_delay); | ||
delay | ||
} | ||
|
||
/// Reset the backoff time for to base delay | ||
pub fn reset(&mut self) { | ||
self.current_delay = self.base_delay; | ||
} | ||
} |
Oops, something went wrong.