Skip to content

Commit

Permalink
feat(prover): add CLI option to run prover with max allocation (#2794)
Browse files Browse the repository at this point in the history
## What ❔

Add CLI option for prover to limit max allocation of GPU

## Why ❔

To be able to run compressor and prover on one machine.

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
  • Loading branch information
Artemka374 authored Sep 4, 2024
1 parent 6f38a43 commit 35e4cae
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
30 changes: 16 additions & 14 deletions prover/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ circuit_sequencer_api = "=0.150.4"
zkevm_test_harness = "=0.150.4"

# GPU proving dependencies
wrapper_prover = { package = "zksync-wrapper-prover", version = "=0.150.4" }
shivini = "=0.150.4"
wrapper_prover = { package = "zksync-wrapper-prover", version = "=0.150.6" }
shivini = "=0.150.6"

# Core workspace dependencies
zksync_multivm = { path = "../core/lib/multivm", version = "0.1.0" }
Expand Down
12 changes: 10 additions & 2 deletions prover/crates/bin/prover_fri/src/gpu_prover_job_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod gpu_prover {
use anyhow::Context as _;
use shivini::{
gpu_proof_config::GpuProofConfig, gpu_prove_from_external_witness_data, ProverContext,
ProverContextConfig,
};
use tokio::task::JoinHandle;
use zksync_config::configs::{fri_prover_group::FriProverGroupConfig, FriProverConfig};
Expand Down Expand Up @@ -82,7 +83,15 @@ pub mod gpu_prover {
address: SocketAddress,
zone: Zone,
protocol_version: ProtocolSemanticVersion,
max_allocation: Option<usize>,
) -> Self {
let prover_context = match max_allocation {
Some(max_allocation) => ProverContext::create_with_config(
ProverContextConfig::default().with_maximum_device_allocation(max_allocation),
)
.expect("failed initializing gpu prover context"),
None => ProverContext::create().expect("failed initializing gpu prover context"),
};
Prover {
blob_store,
public_blob_store,
Expand All @@ -91,8 +100,7 @@ pub mod gpu_prover {
setup_load_mode,
circuit_ids_for_round_to_be_proven,
witness_vector_queue,
prover_context: ProverContext::create()
.expect("failed initializing gpu prover context"),
prover_context,
address,
zone,
protocol_version,
Expand Down
6 changes: 6 additions & 0 deletions prover/crates/bin/prover_fri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ async fn main() -> anyhow::Result<()> {
public_blob_store,
pool,
circuit_ids_for_round_to_be_proven,
opt.max_allocation,
notify,
)
.await
Expand Down Expand Up @@ -178,6 +179,7 @@ async fn get_prover_tasks(
public_blob_store: Option<Arc<dyn ObjectStore>>,
pool: ConnectionPool<Prover>,
circuit_ids_for_round_to_be_proven: Vec<CircuitIdRoundTuple>,
_max_allocation: Option<usize>,
_init_notifier: Arc<Notify>,
) -> anyhow::Result<Vec<JoinHandle<anyhow::Result<()>>>> {
use crate::prover_job_processor::{load_setup_data_cache, Prover};
Expand Down Expand Up @@ -213,6 +215,7 @@ async fn get_prover_tasks(
public_blob_store: Option<Arc<dyn ObjectStore>>,
pool: ConnectionPool<Prover>,
circuit_ids_for_round_to_be_proven: Vec<CircuitIdRoundTuple>,
max_allocation: Option<usize>,
init_notifier: Arc<Notify>,
) -> anyhow::Result<Vec<JoinHandle<anyhow::Result<()>>>> {
use gpu_prover_job_processor::gpu_prover;
Expand Down Expand Up @@ -245,6 +248,7 @@ async fn get_prover_tasks(
address.clone(),
zone.clone(),
protocol_version,
max_allocation,
);
let producer = shared_witness_vector_queue.clone();

Expand Down Expand Up @@ -295,4 +299,6 @@ pub(crate) struct Cli {
pub(crate) config_path: Option<std::path::PathBuf>,
#[arg(long)]
pub(crate) secrets_path: Option<std::path::PathBuf>,
#[arg(long)]
pub(crate) max_allocation: Option<usize>,
}

0 comments on commit 35e4cae

Please sign in to comment.