Skip to content

[DON'T MERGE]: share gpu benchmark results #29

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

Closed
wants to merge 7 commits into from
Closed
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
1,596 changes: 1,242 additions & 354 deletions Cargo.lock

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -20,26 +20,26 @@ repository = "https://github.com/scroll-tech/zkvm-prover"
version = "0.1.0-rc.2"

[workspace.dependencies]
openvm = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-algebra-complex-macros = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-algebra-guest = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-bigint-guest = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-build ={ git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-circuit ={ git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-native-circuit = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-native-transpiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-native-compiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-native-recursion = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-ecc-guest = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-instructions ={ git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-keccak256-guest = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-pairing-guest = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-rv32im-guest = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-rv32im-transpiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-transpiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1" }
openvm-sdk = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.0.0-rc.1", default-features = false}
openvm = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-algebra-complex-macros = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-algebra-guest = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-bigint-guest = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-build ={ git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-circuit ={ git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218", features = ["bench-metrics"] }
openvm-native-circuit = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-native-transpiler = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-native-compiler = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218", features = ["bench-metrics"] }
openvm-native-recursion = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218", features = ["bench-metrics"] }
openvm-ecc-guest = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-instructions ={ git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-keccak256-guest = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-pairing-guest = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-rv32im-guest = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-rv32im-transpiler = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-transpiler = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218" }
openvm-sdk = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "bench-0218", features = ["bench-metrics"] }

openvm-stark-sdk = { git = "https://github.com/openvm-org/stark-backend.git", tag = "v1.0.0-rc.0" }
openvm-stark-sdk = { git = "ssh://git@github.com/scroll-tech/openvm-stark-gpu.git", branch = "process-single-rap", features = ["gpu"] }

bitcode = { version = "0.6.3", default-features = false, features = ["serde", "derive"] }
derivative = "2.2.0"
@@ -77,3 +77,4 @@ revm-precompile = { git = "https://github.com/scroll-tech/revm", branch = "scrol
revm-primitives = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/chore/v55-upgrade" }
ruint = { git = "https://github.com/scroll-tech/uint.git", branch = "v1.12.3" }
tiny-keccak = { git = "https://github.com/scroll-tech/tiny-keccak", branch = "scroll-patch-v2.0.2-openvm-v1.0.0-rc.1" }

8 changes: 8 additions & 0 deletions bench-cpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export RUST_MIN_STACK=16777216
export RUST_LOG=info
export RUSTFLAGS="-Ctarget-feature=+avx2"
export OUTPUT_PATH="metrics.json"

cargo test --release -p scroll-zkvm-integration --features scroll --test chunk_circuit setup_prove_verify_single -- --exact --nocapture 2>&1 | tee chunk-cpu.log
#cargo test --release -p scroll-zkvm-integration --features scroll --test batch_circuit setup_prove_verify_single -- --exact --nocapture 2>&1 | tee batch-cpu.log
#cargo test --release -p scroll-zkvm-integration --features scroll --test bundle_circuit setup_prove_verify -- --exact --nocapture 2>&1 | tee bundle-cpu.log
5 changes: 4 additions & 1 deletion crates/build-guest/src/verifier/mod.rs
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ use openvm_instructions::{
};
use openvm_sdk::{config::AggStarkConfig, keygen::AggStarkProvingKey};
use openvm_stark_sdk::p3_baby_bear::BabyBear as F;
use openvm_stark_sdk::config::FriParameters;

#[allow(dead_code)]
mod asm_utils;
@@ -69,7 +70,9 @@ fn dump_root_program(stark_pk: &AggStarkProvingKey, output_file: &str) {

pub fn dump_verifier(path: &str) {
println!("generating AggStarkProvingKey");
let (agg_stark_pk, _) = AggStarkProvingKey::dummy_proof_and_keygen(AggStarkConfig::default());
let mut agg_stark_config = AggStarkConfig::default();
agg_stark_config.leaf_fri_params = FriParameters::standard_with_100_bits_conjectured_security(1);
let (agg_stark_pk, _) = AggStarkProvingKey::dummy_proof_and_keygen(agg_stark_config);

println!("generating root_verifier.asm");
dump_root_program(&agg_stark_pk, path);
1 change: 1 addition & 0 deletions crates/integration/Cargo.toml
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ openvm-native-compiler = { workspace = true, default-features = false }
openvm-native-recursion = { workspace = true, default-features = false }
openvm-native-transpiler = { workspace = true, default-features = false }
openvm-transpiler = { workspace = true, default-features = false }
openvm-stark-sdk.workspace = true

alloy-primitives.workspace = true
tiny-keccak.workspace = true
7 changes: 4 additions & 3 deletions crates/integration/src/lib.rs
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ pub trait ProverTester {
/// Setup directory structure for the test suite.
fn setup() -> eyre::Result<()> {
// Setup tracing subscriber.
setup_logger()?;
// setup_logger()?;

// If user has set an output directory, use it.
let dir_testrun = if let Ok(env_dir) = std::env::var(ENV_OUTPUT_DIR) {
@@ -216,8 +216,9 @@ impl<T: Clone, P: Clone> ProveVerifyOutcome<T, P> {
/// Setup test environment
fn setup_logger() -> eyre::Result<()> {
let fmt_layer = tracing_subscriber::fmt::layer()
.pretty()
.with_span_events(FmtSpan::CLOSE);
.compact()
.with_ansi(false)
.with_span_events(FmtSpan::NONE);

#[cfg(feature = "limit-logs")]
{
41 changes: 23 additions & 18 deletions crates/integration/tests/batch_circuit.rs
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ use scroll_zkvm_integration::{
utils::build_batch_task,
};
use scroll_zkvm_prover::{ChunkProof, task::batch::BatchProvingTask, utils::read_json_deep};
use openvm_stark_sdk::bench::run_with_metric_collection;

fn load_recent_chunk_proofs() -> eyre::Result<BatchProvingTask> {
let proof_path = glob::glob("../../.output/chunk-tests-*/chunk/proofs/chunk-*.json")?
@@ -47,34 +48,38 @@ fn test_execute() -> eyre::Result<()> {
fn setup_prove_verify_single() -> eyre::Result<()> {
BatchProverTester::setup()?;

let task = load_recent_chunk_proofs()?;
prove_verify_single::<BatchProverTester>(Some(task))?;

Ok(())
run_with_metric_collection("OUTPUT_PATH", || -> eyre::Result<()> {
let task = load_recent_chunk_proofs()?;
prove_verify_single::<BatchProverTester>(Some(task))?;
Ok(())
})
}

#[test]
fn setup_prove_verify_multi() -> eyre::Result<()> {
MultiBatchProverTester::setup()?;

prove_verify_single::<MultiBatchProverTester>(None)?;

Ok(())
run_with_metric_collection("OUTPUT_PATH", || -> eyre::Result<()> {
prove_verify_single::<MultiBatchProverTester>(None)?;
Ok(())
})
}

#[test]
fn e2e() -> eyre::Result<()> {
BatchProverTester::setup()?;

let outcome = prove_verify_multi::<MultiChunkProverTester>(None)?;

let batch_task = build_batch_task(
&outcome.tasks,
&outcome.proofs,
scroll_zkvm_circuit_input_types::batch::MAX_AGG_CHUNKS,
Default::default(),
);
prove_verify_single::<BatchProverTester>(Some(batch_task))?;

Ok(())
run_with_metric_collection("OUTPUT_PATH", || -> eyre::Result<()> {
let outcome = prove_verify_multi::<MultiChunkProverTester>(None)?;

let batch_task = build_batch_task(
&outcome.tasks,
&outcome.proofs,
scroll_zkvm_circuit_input_types::batch::MAX_AGG_CHUNKS,
Default::default(),
);
prove_verify_single::<BatchProverTester>(Some(batch_task))?;

Ok(())
})
}
103 changes: 54 additions & 49 deletions crates/integration/tests/bundle_circuit.rs
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ use scroll_zkvm_integration::{
utils::{LastHeader, build_batch_task},
};
use scroll_zkvm_prover::{BatchProof, task::bundle::BundleProvingTask, utils::read_json_deep};
use openvm_stark_sdk::bench::run_with_metric_collection;

fn load_recent_batch_proofs() -> eyre::Result<BundleProvingTask> {
let proof_path = glob::glob("../../.output/batch-tests-*/batch/proofs/batch-*.json")?
@@ -24,60 +25,64 @@ fn load_recent_batch_proofs() -> eyre::Result<BundleProvingTask> {
fn setup_prove_verify() -> eyre::Result<()> {
BundleProverTester::setup()?;

let task = load_recent_batch_proofs()?;
prove_verify_single_evm::<BundleProverTester>(Some(task))?;

Ok(())
run_with_metric_collection("OUTPUT_PATH", || -> eyre::Result<()> {
let task = load_recent_batch_proofs()?;
prove_verify_single_evm::<BundleProverTester>(Some(task))?;

Ok(())
})
}

#[test]
fn e2e() -> eyre::Result<()> {
BundleProverTester::setup()?;

let outcome = prove_verify_multi::<MultiChunkProverTester>(None)?;
let (chunk_tasks, chunk_proofs) = (outcome.tasks, outcome.proofs);
assert_eq!(chunk_tasks.len(), chunk_proofs.len());
assert_eq!(chunk_tasks.len(), 3);

// Construct batch tasks using chunk tasks and chunk proofs.
let batch_task_1 = build_batch_task(
&chunk_tasks[0..1],
&chunk_proofs[0..1],
scroll_zkvm_circuit_input_types::batch::MAX_AGG_CHUNKS,
Default::default(),
);
let batch_task_2 = build_batch_task(
&chunk_tasks[1..],
&chunk_proofs[1..],
scroll_zkvm_circuit_input_types::batch::MAX_AGG_CHUNKS,
LastHeader::from(&batch_task_1.batch_header),
);

let outcome =
prove_verify_multi::<MultiBatchProverTester>(Some(&[batch_task_1, batch_task_2]))?;

// Construct bundle task using batch tasks and batch proofs.
let bundle_task = BundleProvingTask {
batch_proofs: outcome.proofs,
};
let outcome = prove_verify_single_evm::<BundleProverTester>(Some(bundle_task))?;

assert_eq!(outcome.proofs.len(), 1, "single bundle proof");

let expected_pi_hash = &outcome.proofs[0].metadata.bundle_pi_hash;
let observed_instances = &outcome.proofs[0].proof.instances[0];

for (i, (&expected, &observed)) in expected_pi_hash
.iter()
.zip(observed_instances.iter().skip(14).take(32))
.enumerate()
{
assert_eq!(
halo2curves_axiom::bn256::Fr::from(u64::from(expected)),
observed,
"pi inconsistent at index {i}: expected={expected}, observed={observed:?}"
run_with_metric_collection("OUTPUT_PATH", || -> eyre::Result<()> {
let outcome = prove_verify_multi::<MultiChunkProverTester>(None)?;
let (chunk_tasks, chunk_proofs) = (outcome.tasks, outcome.proofs);
assert_eq!(chunk_tasks.len(), chunk_proofs.len());
assert_eq!(chunk_tasks.len(), 3);

// Construct batch tasks using chunk tasks and chunk proofs.
let batch_task_1 = build_batch_task(
&chunk_tasks[0..1],
&chunk_proofs[0..1],
scroll_zkvm_circuit_input_types::batch::MAX_AGG_CHUNKS,
Default::default(),
);
}

Ok(())
let batch_task_2 = build_batch_task(
&chunk_tasks[1..],
&chunk_proofs[1..],
scroll_zkvm_circuit_input_types::batch::MAX_AGG_CHUNKS,
LastHeader::from(&batch_task_1.batch_header),
);

let outcome =
prove_verify_multi::<MultiBatchProverTester>(Some(&[batch_task_1, batch_task_2]))?;

// Construct bundle task using batch tasks and batch proofs.
let bundle_task = BundleProvingTask {
batch_proofs: outcome.proofs,
};
let outcome = prove_verify_single_evm::<BundleProverTester>(Some(bundle_task))?;

assert_eq!(outcome.proofs.len(), 1, "single bundle proof");

let expected_pi_hash = &outcome.proofs[0].metadata.bundle_pi_hash;
let observed_instances = &outcome.proofs[0].proof.instances[0];

for (i, (&expected, &observed)) in expected_pi_hash
.iter()
.zip(observed_instances.iter().skip(14).take(32))
.enumerate()
{
assert_eq!(
halo2curves_axiom::bn256::Fr::from(u64::from(expected)),
observed,
"pi inconsistent at index {i}: expected={expected}, observed={observed:?}"
);
}

Ok(())
})
}
15 changes: 9 additions & 6 deletions crates/integration/tests/chunk_circuit.rs
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ use scroll_zkvm_integration::{
ProverTester, prove_verify_multi, prove_verify_single,
testers::chunk::{ChunkProverTester, MultiChunkProverTester},
};
use openvm_stark_sdk::bench::run_with_metric_collection;

#[test]
fn test_execute() -> eyre::Result<()> {
@@ -22,16 +23,18 @@ fn test_execute() -> eyre::Result<()> {
fn setup_prove_verify_single() -> eyre::Result<()> {
ChunkProverTester::setup()?;

prove_verify_single::<ChunkProverTester>(None)?;

Ok(())
run_with_metric_collection("OUTPUT_PATH", || -> eyre::Result<()> {
prove_verify_single::<ChunkProverTester>(None)?;
Ok(())
})
}

#[test]
fn setup_prove_verify_multi() -> eyre::Result<()> {
MultiChunkProverTester::setup()?;

prove_verify_multi::<MultiChunkProverTester>(None)?;

Ok(())
run_with_metric_collection("OUTPUT_PATH", || -> eyre::Result<()> {
prove_verify_multi::<MultiChunkProverTester>(None)?;
Ok(())
})
}
15 changes: 15 additions & 0 deletions crates/prover/src/prover/batch.rs
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ use crate::{
task::batch::BatchProvingTask,
};

use openvm_stark_sdk::config::FriParameters;

/// Prover for [`BatchCircuit`].
pub type BatchProver = Prover<BatchProverType>;

@@ -28,6 +30,19 @@ impl ProverType for BatchProverType {
) -> Result<openvm_sdk::config::AppConfig<openvm_sdk::config::SdkVmConfig>, Error> {
let mut app_config = read_app_config(path_app_config)?;
app_config.app_vm_config.castf = Some(openvm_native_circuit::CastFExtension);

println!("app_fri_params: {:?}", app_config.app_fri_params.fri_params);
println!("leaf_fri_params: {:?}", app_config.leaf_fri_params.fri_params);

app_config.app_fri_params.fri_params = FriParameters::standard_with_100_bits_conjectured_security(1/*app_log_blowup*/);
app_config.leaf_fri_params.fri_params = FriParameters::standard_with_100_bits_conjectured_security(1/*agg_log_blowup*/);
app_config.app_vm_config.system.config = app_config.app_vm_config.system.config.with_max_segment_len((1 << 22) - 100);

println!("set max_seg < d22, log_blowup: 1...");

println!("app_fri_params: {:?}", app_config.app_fri_params.fri_params);
println!("leaf_fri_params: {:?}", app_config.leaf_fri_params.fri_params);

Ok(app_config)
}

15 changes: 15 additions & 0 deletions crates/prover/src/prover/bundle.rs
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ use crate::{
task::{ProvingTask, bundle::BundleProvingTask},
};

use openvm_stark_sdk::config::FriParameters;

/// Prover for [`BundleCircuit`].
pub type BundleProver = Prover<BundleProverType>;

@@ -29,6 +31,19 @@ impl ProverType for BundleProverType {
) -> Result<openvm_sdk::config::AppConfig<openvm_sdk::config::SdkVmConfig>, Error> {
let mut app_config = read_app_config(path_app_config)?;
app_config.app_vm_config.castf = Some(openvm_native_circuit::CastFExtension);

println!("app_fri_params: {:?}", app_config.app_fri_params.fri_params);
println!("leaf_fri_params: {:?}", app_config.leaf_fri_params.fri_params);

app_config.app_fri_params.fri_params = FriParameters::standard_with_100_bits_conjectured_security(1/*app_log_blowup*/);
app_config.leaf_fri_params.fri_params = FriParameters::standard_with_100_bits_conjectured_security(1/*agg_log_blowup*/);
app_config.app_vm_config.system.config = app_config.app_vm_config.system.config.with_max_segment_len((1 << 22) - 100);

println!("set max_seg < d22, log_blowup: 1...");

println!("app_fri_params: {:?}", app_config.app_fri_params.fri_params);
println!("leaf_fri_params: {:?}", app_config.leaf_fri_params.fri_params);

Ok(app_config)
}

17 changes: 16 additions & 1 deletion crates/prover/src/prover/chunk.rs
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ use sbv::{
},
};
use scroll_zkvm_circuit_input_types::chunk::{ChunkInfo, make_providers};
use openvm_stark_sdk::config::FriParameters;

#[cfg(feature = "scroll")]
use sbv::{
@@ -41,7 +42,21 @@ impl ProverType for ChunkProverType {
fn read_app_config<P: AsRef<std::path::Path>>(
path_app_config: P,
) -> Result<openvm_sdk::config::AppConfig<openvm_sdk::config::SdkVmConfig>, Error> {
read_app_config(path_app_config)
let mut app_config = read_app_config(path_app_config)?;

println!("app_fri_params: {:?}", app_config.app_fri_params.fri_params);
println!("leaf_fri_params: {:?}", app_config.leaf_fri_params.fri_params);

app_config.app_fri_params.fri_params = FriParameters::standard_with_100_bits_conjectured_security(1/*app_log_blowup*/);
app_config.leaf_fri_params.fri_params = FriParameters::standard_with_100_bits_conjectured_security(1/*agg_log_blowup*/);
app_config.app_vm_config.system.config = app_config.app_vm_config.system.config.with_max_segment_len((1 << 22) - 100);

println!("set max_seg < d22, log_blowup: 1...");

println!("app_fri_params: {:?}", app_config.app_fri_params.fri_params);
println!("leaf_fri_params: {:?}", app_config.leaf_fri_params.fri_params);

Ok(app_config)
}

fn metadata_with_prechecks(task: &Self::ProvingTask) -> Result<Self::ProofMetadata, Error> {
5 changes: 4 additions & 1 deletion crates/prover/src/prover/mod.rs
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ use openvm_sdk::{
keygen::{AggStarkProvingKey, AppProvingKey, RootVerifierProvingKey},
prover::ContinuationProver,
};
use openvm_stark_sdk::config::FriParameters;
use openvm_stark_sdk::config::baby_bear_poseidon2::BabyBearPoseidon2Config;
use serde::{Serialize, de::DeserializeOwned};
use tracing::{debug, instrument};
@@ -183,8 +184,10 @@ impl<Type: ProverType> Prover<Type> {
println!("raw leaf commit: {:?}", leaf_commit);
println!("leaf commit: {:?}", commits.app_config_commit_to_bn254());

let mut agg_stark_config = AggStarkConfig::default();
agg_stark_config.leaf_fri_params = FriParameters::standard_with_100_bits_conjectured_security(1);
let _agg_stark_pk = AGG_STARK_PROVING_KEY
.get_or_init(|| AggStarkProvingKey::keygen(AggStarkConfig::default()));
.get_or_init(|| AggStarkProvingKey::keygen(agg_stark_config));

Ok((app_committed_exe, Arc::new(app_pk), [
exe_commit,