diff --git a/bin/reth-benchmark/src/lib.rs b/bin/reth-benchmark/src/lib.rs index ea68b5181..11f23b265 100644 --- a/bin/reth-benchmark/src/lib.rs +++ b/bin/reth-benchmark/src/lib.rs @@ -55,6 +55,14 @@ use tracing::{info, info_span}; mod cli; use cli::ProviderArgs; +use std::os::raw::c_int; + +#[link(name = "cudart")] +unsafe extern "C" { + pub fn cudaProfilerStart() -> c_int; + pub fn cudaProfilerStop() -> c_int; +} + /// Enum representing the execution mode of the host executable. #[derive(Debug, Clone, clap::ValueEnum)] pub enum BenchMode { @@ -164,6 +172,13 @@ pub struct HostArgs { #[arg(long)] pub agg_pk_path: Option, + + #[arg(long, default_value = "1")] + pub runs: u32, + + #[arg(long, default_value = "0")] + pub warmups: u32, + /// The number of nibbles to precompute for the preimage lookup table. /// Higher values increase startup time but reduce RPC calls for missing storage keys. /// @@ -173,6 +188,19 @@ pub struct HostArgs { pub preimage_cache_nibbles: u8, } +fn get_params_from_env(env_var: &str, default: impl FnOnce() -> SystemParams) -> SystemParams { + match std::env::var(env_var) { + Ok(s) => { + eprintln!("getting params from env {env_var}"); + let p = serde_json::from_str(&s).unwrap(); + println!("params: {:?}", p); + p + }, + Err(_) => default(), + } +} + + #[derive(Parser, Debug)] #[command(allow_external_subcommands = true)] pub struct BenchmarkCli { @@ -281,9 +309,14 @@ pub async fn run_reth_benchmark(args: HostArgs, openvm_client_eth_elf: &[u8]) -> args.benchmark.internal_log_blowup, )?, }; - #[cfg(feature = "evm-verify")] - let root_params = - override_log_blowup(root_params_with_100_bits_security(), args.benchmark.root_log_blowup)?; + // #[cfg(feature = "evm-verify")] + // let root_params = get_params_from_env("OVERRIDE_ROOT_PARAMS", || { + // override_log_blowup(root_params_with_100_bits_security(), args.benchmark.root_log_blowup).unwrap() + // }); + + let root_bytes = include_bytes!("root_param_final.json"); + let root_params = serde_json::from_slice(root_bytes).unwrap(); + // Resolve key paths: explicit flag wins; otherwise fall back to /.pk // if the file exists. The chain agg->app and root->agg->app is enforced by the builder, @@ -323,6 +356,7 @@ pub async fn run_reth_benchmark(args: HostArgs, openvm_client_eth_elf: &[u8]) -> let root_pk = read_object_from_file(&root_pk_path)?; sdk_builder = sdk_builder.root_pk(root_pk); } else { + println!("using root params from default or env var"); sdk_builder = sdk_builder.root_params(root_params); } } @@ -524,12 +558,25 @@ pub async fn run_reth_benchmark(args: HostArgs, openvm_client_eth_elf: &[u8]) -> .stark_prover .prove(stdin, &[]) .expect("failed to prove stark"); - let root_proof = evm_prover + let mut root_proof = None; + for _ in 0..args.warmups { + root_proof = Some(evm_prover .prove_root_from_vm_stark_proof( stark_proof.clone(), &mut metadata.clone(), ) - .expect("failed to prove root"); + .expect("failed to prove root")); + } + unsafe { assert!( cudaProfilerStart() == 0 ); } + for _ in 0..args.runs { + root_proof = Some( evm_prover + .prove_root_from_vm_stark_proof( + stark_proof.clone(), + &mut metadata.clone(), + ) + .expect("failed to prove root") ); + } + unsafe { assert!( cudaProfilerStop() == 0 ); } if let Some(proof_file) = &proof_file { if let Some(parent) = proof_file.parent() { fs::create_dir_all(parent)?; @@ -542,14 +589,26 @@ pub async fn run_reth_benchmark(args: HostArgs, openvm_client_eth_elf: &[u8]) -> .encode(&mut stark_proof_writer) .expect("failed to write stark proof"); } - root_proof + root_proof.unwrap() }; } #[cfg(feature = "evm-verify")] BenchMode::ProveEvm => { let mut evm_prover = sdk.evm_prover(exe)?; evm_prover.stark_prover.app_prover.set_program_name(&program_name); - let proof = evm_prover.prove_evm(stdin, &[])?; + let mut proof = None; + for i in 0..args.warmups { + eprintln!("warmup {i}"); + proof = Some(evm_prover.prove_evm(stdin.clone(), &[])?); + } + unsafe { assert!( cudaProfilerStart() == 0 ); } + for i in 0..args.runs { + eprintln!("run {i}"); + proof = Some(info_span!("prove_evm.run", run = format!("run_{i}")).in_scope(|| + evm_prover.prove_evm(stdin.clone(), &[]))?); + } + unsafe { assert!( cudaProfilerStop() == 0 ); } + let proof = proof.unwrap(); let block_hash = &proof.user_public_values; println!("block_hash (prove_evm): {}", hex::encode(block_hash)); let openvm_verifier = sdk.generate_halo2_verifier_solidity()?; diff --git a/bin/reth-benchmark/src/root_param_final.json b/bin/reth-benchmark/src/root_param_final.json new file mode 100644 index 000000000..06f7cbc10 --- /dev/null +++ b/bin/reth-benchmark/src/root_param_final.json @@ -0,0 +1,34 @@ +{ + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 4, + "rounds": [ + { + "num_queries": 61 + }, + { + "num_queries": 30 + }, + { + "num_queries": 20 + } + ], + "mu_pow_bits": 15, + "query_phase_pow_bits": 15, + "folding_pow_bits": 15, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 +} diff --git a/root_params.json b/root_params.json new file mode 100644 index 000000000..ccb8c57e7 --- /dev/null +++ b/root_params.json @@ -0,0 +1,2312 @@ +[ + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + }, + { + "num_queries": 193 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + }, + { + "num_queries": 88 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 1, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + }, + { + "num_queries": 57 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 57 + }, + { + "num_queries": 34 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 57 + }, + { + "num_queries": 34 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 57 + }, + { + "num_queries": 34 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 57 + }, + { + "num_queries": 34 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 57 + }, + { + "num_queries": 34 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 42 + }, + { + "num_queries": 28 + }, + { + "num_queries": 21 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 42 + }, + { + "num_queries": 28 + }, + { + "num_queries": 21 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 42 + }, + { + "num_queries": 28 + }, + { + "num_queries": 21 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 42 + }, + { + "num_queries": 28 + }, + { + "num_queries": 21 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 42 + }, + { + "num_queries": 28 + }, + { + "num_queries": 21 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 34 + }, + { + "num_queries": 24 + }, + { + "num_queries": 19 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 34 + }, + { + "num_queries": 24 + }, + { + "num_queries": 19 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 34 + }, + { + "num_queries": 24 + }, + { + "num_queries": 19 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 34 + }, + { + "num_queries": 24 + }, + { + "num_queries": 19 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 3, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 34 + }, + { + "num_queries": 24 + }, + { + "num_queries": 19 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 34 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 34 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 34 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 34 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 34 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 28 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 28 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 28 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 28 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 28 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 5, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 2, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 193 + }, + { + "num_queries": 24 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 21 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 21 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 21 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 21 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 3, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 88 + }, + { + "num_queries": 21 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 2, + "n_stack": 18, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 19 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 4, + "n_stack": 16, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 19 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 8, + "n_stack": 12, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 19 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 14, + "n_stack": 6, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 19 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + }, + { + "l_skip": 18, + "n_stack": 2, + "w_stack": 18, + "log_blowup": 4, + "whir": { + "k": 7, + "rounds": [ + { + "num_queries": 57 + }, + { + "num_queries": 19 + } + ], + "mu_pow_bits": 20, + "query_phase_pow_bits": 20, + "folding_pow_bits": 20, + "proximity": { + "ListDecoding": { + "m": 1 + } + } + }, + "logup": { + "max_interaction_count": 2013265921, + "log_max_message_length": 7, + "pow_bits": 18 + }, + "max_constraint_degree": 4 + } +] \ No newline at end of file diff --git a/run.sh b/run.sh index 2490cd7e8..3eca52fdd 100755 --- a/run.sh +++ b/run.sh @@ -16,6 +16,7 @@ # --root-log-blowup # --num-children-leaf # --num-children-internal +# --max-segment-length # --segment-max-memory # --cuda Force CUDA acceleration (auto-detected if nvidia-smi available) # --tco Use TCO instead of AOT (default is AOT on x86_64) @@ -48,14 +49,13 @@ RUST_TOOLCHAIN=$(sed -n 's/^channel = "\(.*\)"/\1/p' "$REPO_ROOT/rust-toolchain. DEST="$REPO_ROOT/bin/reth-benchmark/elf/openvm-stateless-guest" -build_openvm_guest_elf() { - cd "$REPO_ROOT/bin/stateless-guest" - OPENVM_RUST_TOOLCHAIN=$RUST_TOOLCHAIN cargo openvm build - mkdir -p ../reth-benchmark/elf - SRC="target/riscv32im-risc0-zkvm-elf/release/openvm-stateless-guest" - cp "$SRC" "$DEST" - cd "$WORKDIR" -} +if [ ! -f "$DEST" ]; then + cd "$REPO_ROOT/bin/stateless-guest" + OPENVM_RUST_TOOLCHAIN=$RUST_TOOLCHAIN cargo openvm build + mkdir -p ../reth-benchmark/elf + SRC="target/riscv32im-risc0-zkvm-elf/release/openvm-stateless-guest" + cp "$SRC" "$DEST" +fi cd $WORKDIR @@ -66,7 +66,7 @@ trap finalize_gpu_monitor EXIT NVIDIA_SMI_READY=false if command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi >/dev/null 2>&1; then - NVIDIA_SMI_READY=true + NVIDIA_SMI_READY=true fi # Parse command-line arguments @@ -81,6 +81,7 @@ USE_NSYS=false USE_NSYS_GPU_METRICS=false USE_NCU=false COMPUTE_SANITIZER_ARGS="" +ROOT_PARAMS="" while [[ $# -gt 0 ]]; do case $1 in @@ -209,47 +210,47 @@ if [ "$USE_NSYS_GPU_METRICS" = "true" ] && [ "$USE_NSYS" = "false" ]; then fi if [ "$USE_CUDA" = "false" ] && [ "$NVIDIA_SMI_READY" = "true" ]; then - USE_CUDA=true - CUDA_REASON="nvidia-smi detected a CUDA-capable GPU" + USE_CUDA=true + CUDA_REASON="nvidia-smi detected a CUDA-capable GPU" fi if [ "$USE_CUDA" = "true" ]; then - echo "Using CUDA acceleration ($CUDA_REASON)." + echo "Using CUDA acceleration ($CUDA_REASON)." fi if [ "$NVIDIA_SMI_READY" = "true" ] && [ "$USE_NSYS" = "false" ]; then - start_gpu_monitor "$GPU_LOG_FILE" "$GPU_MONITOR_INTERVAL" + start_gpu_monitor "$GPU_LOG_FILE" "$GPU_MONITOR_INTERVAL" elif [ "$USE_NSYS" = "true" ]; then - echo "GPU memory monitoring disabled for nsys profiling." + echo "GPU memory monitoring disabled for nsys profiling." else - echo "nvidia-smi not detected; GPU memory monitoring disabled." + echo "nvidia-smi not detected; GPU memory monitoring disabled." fi mkdir -p rpc-cache if [[ -f .env ]]; then - # Optional convenience file for local runs. - source .env + # Optional convenience file for local runs. + source .env fi if [[ -z "${RPC_1:-}" ]]; then - echo "Missing RPC endpoint: set RPC_1 env var or create reth-bench/.env with RPC_1=..." >&2 - exit 1 + echo "Missing RPC endpoint: set RPC_1 env var or create reth-bench/.env with RPC_1=..." >&2 + exit 1 fi MODE="${MODE_OVERRIDE:-prove-app}" # can be prove-app, prove-stark, keygen, generate-vm-vkey # Map profile aliases and set target directory case "${PROFILE_OVERRIDE:-release}" in - dev|debug) - PROFILE="dev" - TARGET_DIR="debug" - ;; - release) - PROFILE="release" - TARGET_DIR="release" - ;; - *) - PROFILE="${PROFILE_OVERRIDE:-profiling}" - TARGET_DIR="$PROFILE" - ;; +dev | debug) + PROFILE="dev" + TARGET_DIR="debug" + ;; +release) + PROFILE="release" + TARGET_DIR="release" + ;; +*) + PROFILE="${PROFILE_OVERRIDE:-profiling}" + TARGET_DIR="$PROFILE" + ;; esac FEATURES="parallel,metrics,jemalloc,unprotected" BLOCK_NUMBER="${BLOCK_NUMBER_OVERRIDE:-23992138}" @@ -257,54 +258,54 @@ TOOLCHAIN="+$RUST_TOOLCHAIN" BIN_NAME="openvm-reth-benchmark" export VPMM_PAGE_SIZE=$((4 << 20)) if [[ -z "${VPMM_PAGES:-}" ]] && [[ "$MODE" == "prove-stark" || "$MODE" == "prove-app" || "$MODE" == "prove-evm" ]]; then - export VPMM_PAGES=$((16 << 8)) # start with 16GB + export VPMM_PAGES=$((16 << 8)) # start with 16GB fi # Settings to turn off VPMM: # VPMM_PAGE_SIZE=$((1<<35)) # VPMM_PAGES=0 if [ "$USE_CUDA" = "true" ]; then - FEATURES="$FEATURES,cuda" + FEATURES="$FEATURES,cuda" fi if [ "$USE_NSYS" = "true" ]; then - FEATURES="$FEATURES,nvtx" + FEATURES="$FEATURES,nvtx" fi if [ "$MODE" = "prove-evm" ] || [ "$MODE" = "prove-root" ] || [ "$MODE" = "keygen-root" ]; then - FEATURES="$FEATURES,evm-verify" + FEATURES="$FEATURES,evm-verify" fi # `keygen-root` is a shell-level alias: enable evm-verify (handled above) and pass --mode keygen # to the binary. The keygen branch then additionally writes /root.pk when evm-verify # is compiled in. if [ "$MODE" = "keygen-root" ]; then - MODE="keygen" + MODE="keygen" fi arch=$(uname -m) case $arch in -arm64|aarch64) - RUSTFLAGS="-Ctarget-cpu=native" - if [ "$USE_TCO" = "false" ]; then - USE_TCO=true +arm64 | aarch64) + RUSTFLAGS="-Ctarget-cpu=native" + if [ "$USE_TCO" = "false" ]; then + USE_TCO=true + fi + ;; +x86_64 | amd64) + RUSTFLAGS="-Ctarget-cpu=native" + if [ "$USE_TCO" = "false" ]; then + # aot enables halo2curves-axiom/asm which is x86_64-only + FEATURES="$FEATURES,aot" + if [ "$MODE" = "prove-evm" ]; then + FEATURES="$FEATURES,halo2-asm" fi - ;; -x86_64|amd64) - RUSTFLAGS="-Ctarget-cpu=native" - if [ "$USE_TCO" = "false" ]; then - # aot enables halo2curves-axiom/asm which is x86_64-only - FEATURES="$FEATURES,aot" - if [ "$MODE" = "prove-evm" ]; then - FEATURES="$FEATURES,halo2-asm" - fi - fi - ;; + fi + ;; *) -echo "Unsupported architecture: $arch" -exit 1 -;; + echo "Unsupported architecture: $arch" + exit 1 + ;; esac if [ "$USE_TCO" = "true" ]; then - FEATURES="$FEATURES,tco" + FEATURES="$FEATURES,tco" fi if [ "$USE_PERF" = "true" ] || [ "$USE_NSYS" = "true" ]; then RUSTFLAGS="$RUSTFLAGS -C force-frame-pointers=yes" @@ -315,58 +316,52 @@ if [ "$USE_PERF" = "true" ] || [ "$USE_NSYS" = "true" ]; then fi fi if [ "$USE_NSYS" = "false" ]; then - export JEMALLOC_SYS_WITH_MALLOC_CONF="retain:true,background_thread:true,metadata_thp:always,dirty_decay_ms:10000,muzzy_decay_ms:10000,abort_conf:true" + export JEMALLOC_SYS_WITH_MALLOC_CONF="retain:true,background_thread:true,metadata_thp:always,dirty_decay_ms:10000,muzzy_decay_ms:10000,abort_conf:true" fi if [[ "${OPENVM_BENCH_SKIP_BUILD:-0}" != "1" ]]; then - build_openvm_guest_elf - RUSTFLAGS=$RUSTFLAGS cargo $TOOLCHAIN build --bin $BIN_NAME --profile=$PROFILE --no-default-features --features=$FEATURES + RUSTFLAGS=$RUSTFLAGS cargo $TOOLCHAIN build --bin $BIN_NAME --profile=$PROFILE --no-default-features --features=$FEATURES fi BIN=$REPO_ROOT/target/$TARGET_DIR/$BIN_NAME CONFIG_ARGS="" -if [[ -n $APP_LOG_BLOWUP ]] -then - CONFIG_ARGS="$CONFIG_ARGS --app-log-blowup ${APP_LOG_BLOWUP}" +if [[ -n $APP_LOG_BLOWUP ]]; then + CONFIG_ARGS="$CONFIG_ARGS --app-log-blowup ${APP_LOG_BLOWUP}" +fi +if [[ -n $LEAF_LOG_BLOWUP ]]; then + CONFIG_ARGS="$CONFIG_ARGS --leaf-log-blowup ${LEAF_LOG_BLOWUP}" fi -if [[ -n $LEAF_LOG_BLOWUP ]] -then - CONFIG_ARGS="$CONFIG_ARGS --leaf-log-blowup ${LEAF_LOG_BLOWUP}" +if [[ -n $INTERNAL_LOG_BLOWUP ]]; then + CONFIG_ARGS="$CONFIG_ARGS --internal-log-blowup ${INTERNAL_LOG_BLOWUP}" fi -if [[ -n $INTERNAL_LOG_BLOWUP ]] -then - CONFIG_ARGS="$CONFIG_ARGS --internal-log-blowup ${INTERNAL_LOG_BLOWUP}" +if [[ -n $APP_L_SKIP ]]; then + CONFIG_ARGS="$CONFIG_ARGS --app-l-skip ${APP_L_SKIP}" fi -if [[ -n $APP_L_SKIP ]] -then - CONFIG_ARGS="$CONFIG_ARGS --app-l-skip ${APP_L_SKIP}" +if [[ -n $ROOT_LOG_BLOWUP ]]; then + CONFIG_ARGS="$CONFIG_ARGS --root-log-blowup ${ROOT_LOG_BLOWUP}" fi -if [[ -n $ROOT_LOG_BLOWUP ]] -then - CONFIG_ARGS="$CONFIG_ARGS --root-log-blowup ${ROOT_LOG_BLOWUP}" +if [[ -n $NUM_CHILDREN_LEAF ]]; then + CONFIG_ARGS="$CONFIG_ARGS --num-children-leaf ${NUM_CHILDREN_LEAF}" fi -if [[ -n $NUM_CHILDREN_LEAF ]] -then - CONFIG_ARGS="$CONFIG_ARGS --num-children-leaf ${NUM_CHILDREN_LEAF}" +if [[ -n $NUM_CHILDREN_INTERNAL ]]; then + CONFIG_ARGS="$CONFIG_ARGS --num-children-internal ${NUM_CHILDREN_INTERNAL}" fi -if [[ -n $NUM_CHILDREN_INTERNAL ]] -then - CONFIG_ARGS="$CONFIG_ARGS --num-children-internal ${NUM_CHILDREN_INTERNAL}" +if [[ -n $PROOF_CACHE ]]; then + CONFIG_ARGS="$CONFIG_ARGS --proof-cache ${PROOF_CACHE}" fi -if [[ -n $PROOF_CACHE ]] -then - CONFIG_ARGS="$CONFIG_ARGS --proof-cache ${PROOF_CACHE}" +if [[ -n $MAX_SEGMENT_LENGTH ]]; then + CONFIG_ARGS="$CONFIG_ARGS --max-segment-length ${MAX_SEGMENT_LENGTH}" fi -if [[ -n $SEGMENT_MAX_MEMORY ]] -then - CONFIG_ARGS="$CONFIG_ARGS --segment-max-memory ${SEGMENT_MAX_MEMORY}" +if [[ -n $SEGMENT_MAX_MEMORY ]]; then + CONFIG_ARGS="$CONFIG_ARGS --segment-max-memory ${SEGMENT_MAX_MEMORY}" fi BIN_ARGS="--mode $MODE \ $CONFIG_ARGS" if [ "$MODE" != "generate-vm-vkey" ]; then - BIN_ARGS="$BIN_ARGS \ + BIN_ARGS="$BIN_ARGS \ + --block-number $BLOCK_NUMBER \ --rpc-url $RPC_1 \ --cache-dir rpc-cache" @@ -376,29 +371,29 @@ export RUST_LOG="info,p3_=warn" echo "Run command:" echo "$BIN $BIN_ARGS" if [ "$USE_PERF" = "true" ]; then - # Set sampling frequency based on mode - if [[ "$MODE" == "execute-host" || "$MODE" == "execute" || "$MODE" == "execute-metered" ]]; then - PERF_FREQ=4000 - else - PERF_FREQ=100 - fi - - echo "Running with perf profiling (freq=${PERF_FREQ})..." - export OUTPUT_PATH="metrics.json" - perf record -F $PERF_FREQ --call-graph=dwarf -g -o perf.data -- $BIN $BIN_ARGS - - echo "Converting perf.data with samply..." - mkdir -p samply_profile - samply import perf.data --unstable-presymbolicate --save-only --output samply_profile/profile.json.gz - echo "Saved profile: samply_profile/profile.json.gz" - - FIREFOX_PROFILER_URL=$(python3 "$REPO_ROOT/scripts/upload_firefox_profile.py" samply_profile/profile.json.gz) || true - - if [ -n "$FIREFOX_PROFILER_URL" ]; then - echo "Firefox Profiler URL: $FIREFOX_PROFILER_URL" - else - echo "Warning: failed to upload profile to Firefox Profiler" - fi + # Set sampling frequency based on mode + if [[ "$MODE" == "execute-host" || "$MODE" == "execute" || "$MODE" == "execute-metered" ]]; then + PERF_FREQ=4000 + else + PERF_FREQ=100 + fi + $BIN $BIN_ARGS + # echo "Running with perf profiling (freq=${PERF_FREQ})..." + # export OUTPUT_PATH="metrics.json" + # perf record -F $PERF_FREQ --call-graph=dwarf -g -o perf.data -- $BIN $BIN_ARGS + # + # echo "Converting perf.data with samply..." + # mkdir -p samply_profile + # samply import perf.data --unstable-presymbolicate --save-only --output samply_profile/profile.json.gz + # echo "Saved profile: samply_profile/profile.json.gz" + # + # FIREFOX_PROFILER_URL=$(python3 "$REPO_ROOT/scripts/upload_firefox_profile.py" samply_profile/profile.json.gz) || true + # + # if [ -n "$FIREFOX_PROFILER_URL" ]; then + # echo "Firefox Profiler URL: $FIREFOX_PROFILER_URL" + # else + # echo "Warning: failed to upload profile to Firefox Profiler" + # fi elif [ "$USE_NSYS" = "true" ]; then NSYS_OUTPUT="reth.nsys-rep" NSYS_ARGS="--trace=cuda,nvtx,osrt --sample=cpu --cpuctxsw=true --cuda-memory-usage=true --force-overwrite=true -o $NSYS_OUTPUT" @@ -413,21 +408,21 @@ elif [ "$USE_NSYS" = "true" ]; then nsys profile $NSYS_ARGS \ $BIN $BIN_ARGS - echo "=== CUDA GPU Kernel Summary ===" - nsys stats --force-export=true --report cuda_gpu_kern_sum "$NSYS_OUTPUT" - echo "=== CUDA Memory Time Summary ===" - nsys stats --force-export=true --report cuda_gpu_mem_time_sum "$NSYS_OUTPUT" - echo "=== CUDA Memory Size Summary ===" - nsys stats --force-export=true --report cuda_gpu_mem_size_sum "$NSYS_OUTPUT" - echo "=== NCU Top Kernel Analysis ===" - TOP_KERNEL=$(nsys stats --report cuda_gpu_kern_sum "$NSYS_OUTPUT" 2>/dev/null | \ - awk '/--------/{getline; print; exit}' | \ - sed -E 's/.*::([a-zA-Z_][a-zA-Z0-9_]*)[<(].*/\1/; t; s/.*[[:space:]]([a-zA-Z_][a-zA-Z0-9_]*)[<(].*/\1/') - echo "Top kernel: $TOP_KERNEL" + echo "=== CUDA GPU Kernel Summary ===" + nsys stats --force-export=true --report cuda_gpu_kern_sum "$NSYS_OUTPUT" + echo "=== CUDA Memory Time Summary ===" + nsys stats --force-export=true --report cuda_gpu_mem_time_sum "$NSYS_OUTPUT" + echo "=== CUDA Memory Size Summary ===" + nsys stats --force-export=true --report cuda_gpu_mem_size_sum "$NSYS_OUTPUT" + echo "=== NCU Top Kernel Analysis ===" + TOP_KERNEL=$(nsys stats --report cuda_gpu_kern_sum "$NSYS_OUTPUT" 2>/dev/null | + awk '/--------/{getline; print; exit}' | + sed -E 's/.*::([a-zA-Z_][a-zA-Z0-9_]*)[<(].*/\1/; t; s/.*[[:space:]]([a-zA-Z_][a-zA-Z0-9_]*)[<(].*/\1/') + echo "Top kernel: $TOP_KERNEL" elif [[ "$USE_NCU" == true ]]; then - echo "[sudo] Running with Ncu..." - NCU_OUTPUT="reth-${ncu_kernel}.ncu-rep" - sudo env PATH=$PATH ncu \ + echo "[sudo] Running with Ncu..." + NCU_OUTPUT="reth-${ncu_kernel}.ncu-rep" + sudo env PATH=$PATH ncu \ --target-processes all \ --kernel-name "$ncu_kernel" \ -f -o "${NCU_OUTPUT}" \ @@ -436,8 +431,8 @@ elif [[ "$USE_NCU" == true ]]; then --set full \ $BIN $BIN_ARGS - ncu -i "$NCU_OUTPUT" > "reth-${ncu_kernel}.txt" + ncu -i "$NCU_OUTPUT" >"reth-${ncu_kernel}.txt" else - export OUTPUT_PATH="metrics.json" - $COMPUTE_SANITIZER_ARGS $BIN $BIN_ARGS + export OUTPUT_PATH="metrics.json" + $COMPUTE_SANITIZER_ARGS $BIN $BIN_ARGS fi diff --git a/sweep_root.py b/sweep_root.py new file mode 100644 index 000000000..16b2b629f --- /dev/null +++ b/sweep_root.py @@ -0,0 +1,79 @@ +import json +import subprocess +import os + + +def find_total_prove_time(metrics): + for record in metrics["gauge"]: + if record["metric"] == "total_proof_time_ms" and any( + l[0] == "group" and l[1] == "root" for l in record["labels"] + ): + return int(record["value"]) + return None + + +with open("root_params.json", "r") as f: + params = json.load(f) + +env = os.environ.copy() +metric_param_results = [] +failed = [] + +if os.path.exists("root_sweep_results.json"): + with open("root_sweep_results.json", "r") as f: + metric_param_results = json.load(f) +if os.path.exists("failed_params.json"): + with open("failed_params.json", "r") as f: + failed = json.load(f) + +log_file = open("root_sweep_log.txt", "w") + + +def fail(p): + failed.append(p) + print(f"failed {p}") + with open("failed_params.json", "w") as f: + json.dump(failed, f) + + +try: + for p in params: + if p in metric_param_results or p in failed: + print(f"skipping {p}") + env["OVERRIDE_ROOT_PARAMS"] = json.dumps(p) + + try: + code = subprocess.call( + [ + "./run.sh", + "--block", + "21345144", + "--perf", + "--mode", + "prove-root", + "--tco", + "--proof-cache", + "output", + ], + env=env, + stdout=log_file, + stderr=log_file, + timeout=150, + ) + except subprocess.TimeoutExpired: + print(f"timed out {p}") + fail(p) + continue + if code == 0: + with open("metrics.json", "r") as f: + metrics = json.load(f) + os.remove("metrics.json") + metric_param_results.append(metrics) + with open("root_sweep_results.json", "w") as f: + json.dump(metric_param_results, f) + ms = find_total_prove_time(metrics) + print(f"param:\n{p}\nroot_time: {ms}") + else: + fail(p) +finally: + log_file.close()