Skip to content

Commit

Permalink
Merge branch 'main' into feat/offline-memory-paged-vec
Browse files Browse the repository at this point in the history
  • Loading branch information
Golovanov399 committed Jan 21, 2025
2 parents 82ecab5 + 3a19b7a commit 91ca222
Show file tree
Hide file tree
Showing 219 changed files with 5,043 additions and 3,820 deletions.
1 change: 1 addition & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "crates/circuits/**"
- "crates/toolchain/**"
- "crates/prof/**"
- "crates/sdk/**"
- "crates/vm/**"
- "extensions/**"
- ".github/workflows/benchmark-call.yml"
Expand Down
51 changes: 15 additions & 36 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ lto = "thin"

[workspace.dependencies]
# Stark Backend
openvm-stark-backend = { git = "https://github.com/openvm-org/stark-backend.git", rev = "47a0bda", default-features = false }
openvm-stark-sdk = { git = "https://github.com/openvm-org/stark-backend.git", rev = "47a0bda", default-features = false }
openvm-stark-backend = { git = "https://github.com/openvm-org/stark-backend.git", rev = "d2788c", default-features = false }
openvm-stark-sdk = { git = "https://github.com/openvm-org/stark-backend.git", rev = "d2788c", default-features = false }

# OpenVM
openvm-sdk = { path = "crates/sdk", default-features = false }
Expand Down Expand Up @@ -247,7 +247,6 @@ tiny-keccak = { version = "2.0.2", features = ["keccak"] }
k256 = { version = "0.13.3", default-features = false }
elliptic-curve = { version = "0.13.8", default-features = false }
ecdsa = { version = "0.16.9", default-features = false }
num-bigint-dig = { version = "0.8.4", default-features = false }
num-bigint = { version = "0.4.6", default-features = false }
num-integer = { version = "0.1.46", default-features = false }
num-traits = { version = "0.2.19", default-features = false }
Expand Down
7 changes: 2 additions & 5 deletions benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ k256 = { workspace = true, features = ["ecdsa"] }
tiny-keccak.workspace = true
derive-new.workspace = true
derive_more = { workspace = true, features = ["from"] }
num-bigint-dig = { workspace = true, features = ["std", "serde"] }
num-bigint = { workspace = true, features = ["std", "serde"] }
serde.workspace = true
bincode = { version = "2.0.0-rc.3" }

Expand All @@ -54,10 +54,7 @@ pprof = { version = "0.13", features = [

[features]
default = ["parallel", "mimalloc", "bench-metrics"]
bench-metrics = [
"openvm-native-recursion/bench-metrics",
"openvm-native-compiler/bench-metrics",
]
bench-metrics = ["openvm-native-recursion/bench-metrics"]
profiling = ["openvm-sdk/profiling"]
aggregation = []
static-verifier = ["openvm-native-recursion/static-verifier"]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/bin/ecrecover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clap::Parser;
use derive_more::derive::From;
use eyre::Result;
use k256::ecdsa::{SigningKey, VerifyingKey};
use num_bigint_dig::BigUint;
use num_bigint::BigUint;
use openvm_algebra_circuit::{
ModularExtension, ModularExtensionExecutor, ModularExtensionPeriphery,
};
Expand Down
10 changes: 8 additions & 2 deletions benchmarks/src/bin/fib_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use openvm_rv32im_circuit::Rv32ImConfig;
use openvm_rv32im_transpiler::{
Rv32ITranspilerExtension, Rv32IoTranspilerExtension, Rv32MTranspilerExtension,
};
use openvm_sdk::{commit::commit_app_exe, prover::ContinuationProver, Sdk, StdIn};
use openvm_sdk::{
commit::commit_app_exe, keygen::RootVerifierProvingKey, prover::ContinuationProver, Sdk, StdIn,
};
use openvm_stark_sdk::bench::run_with_metric_collection;
use openvm_transpiler::{transpiler::Transpiler, FromElf};

Expand All @@ -35,7 +37,11 @@ async fn main() -> Result<()> {
.unwrap_or(PathBuf::from(DEFAULT_PARAMS_DIR)),
);
let app_pk = Arc::new(sdk.app_keygen(app_config)?);
let full_agg_pk = sdk.agg_keygen(agg_config, &halo2_params_reader)?;
let full_agg_pk = sdk.agg_keygen(
agg_config,
&halo2_params_reader,
None::<&RootVerifierProvingKey>,
)?;
let elf = args.build_bench_program("fibonacci")?;
let exe = VmExe::from_elf(
elf,
Expand Down
14 changes: 11 additions & 3 deletions benchmarks/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use openvm_sdk::{
DEFAULT_INTERNAL_LOG_BLOWUP, DEFAULT_LEAF_LOG_BLOWUP, DEFAULT_ROOT_LOG_BLOWUP,
},
keygen::{leaf_keygen, AppProvingKey},
prover::{AppProver, LeafProver},
prover::{
vm::local::VmLocalProver, AppProver, LeafProvingController, DEFAULT_NUM_CHILDREN_LEAF,
},
StdIn,
};
use openvm_stark_backend::utils::metrics_span;
Expand Down Expand Up @@ -234,8 +236,14 @@ where
.expect("Verification failed");
if let Some(leaf_vm_config) = leaf_vm_config {
let leaf_vm_pk = leaf_keygen(app_config.leaf_fri_params.fri_params, leaf_vm_config);
let leaf_prover = LeafProver::new(leaf_vm_pk, app_pk.leaf_committed_exe);
leaf_prover.generate_proof(&app_proof);
let leaf_prover = VmLocalProver::<SC, NativeConfig, BabyBearPoseidon2Engine>::new(
leaf_vm_pk,
app_pk.leaf_committed_exe,
);
let leaf_controller = LeafProvingController {
num_children: DEFAULT_NUM_CHILDREN_LEAF,
};
leaf_controller.generate_proof(&leaf_prover, &app_proof);
}
Ok(())
}
2 changes: 1 addition & 1 deletion crates/circuits/mod-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ halo2curves-axiom = { workspace = true, optional = true }
openvm-pairing-guest = { workspace = true, optional = true }

rand.workspace = true
num-bigint-dig.workspace = true
num-bigint.workspace = true
num-traits.workspace = true
tracing.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/circuits/mod-builder/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ There are two independent properties of the chip built by `ExprBuilder`: whether


1. For the first type (modular and Fp2), there are two flags (e.g. `add_flag` and `sub_flag`) and `setup = is_valid - sum(all_flags)`. That is, when doing setup both flags are 0.
2. For the second type (EcAdd and EcDouble), the chip only supports one operation so technically it doesn't need a flag. But for impelementation simplicity, we still create a dummy flag for it, and it's always 1 unless it's doing setup. And this `setup = is_valid - sum(all_flags)` still holds.
2. For the second type (EcAdd and EcDouble), the chip only supports one operation so technically it doesn't need a flag. But for implementation simplicity, we still create a dummy flag for it, and it's always 1 unless it's doing setup. And this `setup = is_valid - sum(all_flags)` still holds.
3. No chip is in the third type right now.
4. For the fourth type, there is no setup needed and no flags for selecting operations. Only `is_valid` is needed.

Expand Down
11 changes: 8 additions & 3 deletions crates/circuits/mod-builder/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{cell::RefCell, ops::Deref, rc::Rc};

use num_bigint_dig::{BigInt, BigUint, Sign};
use num_bigint::{BigInt, BigUint, Sign};
use num_traits::Zero;
use openvm_circuit_primitives::{
bigint::{
Expand Down Expand Up @@ -31,7 +31,7 @@ pub struct ExprBuilderConfig {

impl ExprBuilderConfig {
pub fn check_valid(&self) {
assert!(self.modulus.bits() <= self.num_limbs * self.limb_bits);
assert!(self.modulus.bits() <= (self.num_limbs * self.limb_bits) as u64);
}
}

Expand Down Expand Up @@ -289,7 +289,12 @@ impl<AB: InteractionBuilder> SubAir<AB> for FieldExpr {
if self.builder.needs_setup() {
let is_setup = flags.iter().fold(is_valid.into(), |acc, &x| acc - x);
builder.assert_bool(is_setup.clone());
builder.when_first_row().assert_one(is_setup.clone());
// TODO[jpw]: currently we enforce at the program code level that:
// - a valid program must call the correct setup opcodes to be correct
// - it would be better if we can constraint this in the circuit,
// however this has the challenge that when the same chip is used
// across continuation segments,
// only the first segment will have setup called
for i in 0..inputs[0].len().max(self.builder.prime_limbs.len()) {
let lhs = if i < inputs[0].len() {
inputs[0][i].into()
Expand Down
6 changes: 5 additions & 1 deletion crates/circuits/mod-builder/src/core_chip.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use itertools::Itertools;
use num_bigint_dig::BigUint;
use num_bigint::BigUint;
use openvm_circuit::arch::{
AdapterAirContext, AdapterRuntimeContext, DynAdapterInterface, DynArray, MinimalInstruction,
Result, VmAdapterInterface, VmCoreAir, VmCoreChip,
Expand Down Expand Up @@ -156,6 +156,10 @@ where
};
ctx.into()
}

fn start_offset(&self) -> usize {
self.offset
}
}

#[serde_as]
Expand Down
Loading

0 comments on commit 91ca222

Please sign in to comment.