Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,16 @@ jobs:
MOCK_PROVING: 1
run: cargo run --package ceno_zkvm --features sanity-check --bin e2e -- --platform=ceno --hints=10 --public-io=4191 examples/target/riscv32im-ceno-zkvm-elf/debug/examples/fibonacci

- name: Run fibonacci (debug) + feature u16limb_circuit
- name: Run fibonacci (release)
env:
RUST_LOG: debug
RUSTFLAGS: "-C opt-level=3"
run: cargo run --package ceno_zkvm --features u16limb_circuit --bin e2e -- --platform=ceno --hints=10 --public-io=4191 examples/target/riscv32im-ceno-zkvm-elf/debug/examples/fibonacci

run: cargo run --release --package ceno_zkvm --bin e2e -- --platform=ceno --hints=10 --public-io=4191 examples/target/riscv32im-ceno-zkvm-elf/release/examples/fibonacci

- name: Run fibonacci (release)
- name: Run fibonacci (release + goldilocks)
env:
RUSTFLAGS: "-C opt-level=3"
run: cargo run --release --package ceno_zkvm --bin e2e -- --platform=ceno --hints=10 --public-io=4191 examples/target/riscv32im-ceno-zkvm-elf/release/examples/fibonacci
run: cargo run --release --package ceno_zkvm --no-default-features --features goldilocks --bin e2e -- --field=goldilocks --platform=ceno --hints=10 --public-io=4191 examples/target/riscv32im-ceno-zkvm-elf/release/examples/fibonacci


- name: Install cargo make
run: |
Expand Down
3 changes: 2 additions & 1 deletion ceno_zkvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ ceno-examples = { path = "../examples-builder" }
glob = "0.3"

[features]
default = ["forbid_overflow"]
default = ["forbid_overflow", "nightly-features", "u16limb_circuit"]
flamegraph = ["pprof2/flamegraph", "pprof2/criterion"]
forbid_overflow = []
goldilocks = ["forbid_overflow", "nightly-features"]
jemalloc = ["dep:tikv-jemallocator", "dep:tikv-jemalloc-ctl"]
jemalloc-prof = ["jemalloc", "tikv-jemallocator?/profiling"]
nightly-features = [
Expand Down
4 changes: 2 additions & 2 deletions ceno_zkvm/benches/fibonacci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ceno_zkvm::{
mod alloc;
use criterion::*;

use ff_ext::GoldilocksExt2;
use ff_ext::BabyBearExt4;
use gkr_iop::cpu::{CpuBackend, CpuProver};
use mpcs::BasefoldDefault;
use transcript::BasicTranscript;
Expand All @@ -26,7 +26,7 @@ criterion_main!(fibonacci_prove_group);
const NUM_SAMPLES: usize = 10;

type Pcs = BasefoldDefault<E>;
type E = GoldilocksExt2;
type E = BabyBearExt4;

// Relevant init data for fibonacci run
fn setup() -> (Program, Platform) {
Expand Down
6 changes: 3 additions & 3 deletions ceno_zkvm/benches/fibonacci_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ceno_zkvm::{
use std::{fs, path::PathBuf, rc::Rc, time::Duration};
mod alloc;
use criterion::*;
use ff_ext::GoldilocksExt2;
use ff_ext::BabyBearExt4;
use gkr_iop::cpu::{CpuBackend, CpuProver};
use mpcs::BasefoldDefault;

Expand All @@ -21,7 +21,7 @@ criterion_main!(fibonacci);

const NUM_SAMPLES: usize = 10;
type Pcs = BasefoldDefault<E>;
type E = GoldilocksExt2;
type E = BabyBearExt4;

// Relevant init data for fibonacci run
fn setup() -> (Program, Platform) {
Expand Down Expand Up @@ -79,5 +79,5 @@ fn fibonacci_witness(c: &mut Criterion) {

group.finish();

type E = GoldilocksExt2;
type E = BabyBearExt4;
}
6 changes: 2 additions & 4 deletions ceno_zkvm/benches/is_prime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ceno_zkvm::{
};
mod alloc;
use criterion::*;
use ff_ext::GoldilocksExt2;
use ff_ext::BabyBearExt4;
use gkr_iop::cpu::{CpuBackend, CpuProver};
use mpcs::BasefoldDefault;

Expand All @@ -22,7 +22,7 @@ criterion_main!(is_prime);

const NUM_SAMPLES: usize = 10;
type Pcs = BasefoldDefault<E>;
type E = GoldilocksExt2;
type E = BabyBearExt4;

// Relevant init data for fibonacci run
fn setup() -> (Program, Platform) {
Expand Down Expand Up @@ -75,6 +75,4 @@ fn is_prime_1(c: &mut Criterion) {

group.finish();
}

type E = GoldilocksExt2;
}
4 changes: 2 additions & 2 deletions ceno_zkvm/benches/keccak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ceno_zkvm::{
mod alloc;
use criterion::*;

use ff_ext::GoldilocksExt2;
use ff_ext::BabyBearExt4;
use gkr_iop::cpu::{CpuBackend, CpuProver};
use mpcs::BasefoldDefault;

Expand All @@ -24,7 +24,7 @@ criterion_main!(keccak_prove_group);
const NUM_SAMPLES: usize = 10;

type Pcs = BasefoldDefault<E>;
type E = GoldilocksExt2;
type E = BabyBearExt4;

// Relevant init data for keccak run
fn setup() -> (Program, Platform) {
Expand Down
17 changes: 8 additions & 9 deletions ceno_zkvm/benches/lookup_keccakf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::time::Duration;

use ceno_zkvm::precompiles::{run_faster_keccakf, setup_lookup_keccak_gkr_circuit};
use criterion::*;
use ff_ext::GoldilocksExt2;
use ff_ext::BabyBearExt4;

use itertools::Itertools;
use mpcs::BasefoldDefault;
Expand Down Expand Up @@ -41,14 +41,13 @@ fn keccak_f_fn(c: &mut Criterion) {
let circuit =
setup_lookup_keccak_gkr_circuit().expect("setup circuit error");
#[allow(clippy::unit_arg)]
let _ =
run_faster_keccakf::<GoldilocksExt2, BasefoldDefault<GoldilocksExt2>>(
circuit,
black_box(states),
false,
false,
)
.expect("unable to get proof");
let _ = run_faster_keccakf::<BabyBearExt4, BasefoldDefault<BabyBearExt4>>(
circuit,
black_box(states),
false,
false,
)
.expect("unable to get proof");
let elapsed = instant.elapsed();
println!(
"keccak_f::create_proof, instances = {}, time = {}",
Expand Down
6 changes: 2 additions & 4 deletions ceno_zkvm/benches/quadratic_sorting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ceno_zkvm::{
};
mod alloc;
use criterion::*;
use ff_ext::GoldilocksExt2;
use ff_ext::BabyBearExt4;
use gkr_iop::cpu::{CpuBackend, CpuProver};
use mpcs::BasefoldDefault;
use rand::{RngCore, SeedableRng};
Expand All @@ -23,7 +23,7 @@ criterion_main!(quadratic_sorting);

const NUM_SAMPLES: usize = 10;
type Pcs = BasefoldDefault<E>;
type E = GoldilocksExt2;
type E = BabyBearExt4;

// Relevant init data for fibonacci run
fn setup() -> (Program, Platform) {
Expand Down Expand Up @@ -77,6 +77,4 @@ fn quadratic_sorting_1(c: &mut Criterion) {

group.finish();
}

type E = GoldilocksExt2;
}
4 changes: 2 additions & 2 deletions ceno_zkvm/benches/riscv_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ mod alloc;
use criterion::*;

use ceno_zkvm::scheme::constants::MAX_NUM_VARIABLES;
use ff_ext::GoldilocksExt2;
use gkr_iop::cpu::{CpuBackend, CpuProver};
use mpcs::{BasefoldDefault, PolynomialCommitmentScheme, SecurityLevel};

use ff_ext::BabyBearExt4;
use rand::rngs::OsRng;
use transcript::{BasicTranscript, Transcript};
use witness::RowMajorMatrix;
Expand Down Expand Up @@ -121,5 +121,5 @@ fn bench_add(c: &mut Criterion) {
group.finish();
}

type E = GoldilocksExt2;
type E = BabyBearExt4;
}
2 changes: 1 addition & 1 deletion ceno_zkvm/src/bin/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ fn main() {
max_steps,
args.proof_file,
args.vk_file,
Checkpoint::PrepVerify, // FIXME: when whir and babybear is ready
Checkpoint::Complete,
)
}
(PcsKind::Whir, FieldType::Goldilocks) => {
Expand Down
2 changes: 1 addition & 1 deletion ceno_zkvm/src/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ pub enum PcsKind {
)]
pub enum FieldType {
#[default]
Goldilocks,
BabyBear,
Goldilocks,
}

pub struct FullMemState<Record> {
Expand Down
1 change: 1 addition & 0 deletions ceno_zkvm/src/instructions/riscv/im_insn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct IMInstructionConfig<E: ExtensionField> {
}

impl<E: ExtensionField> IMInstructionConfig<E> {
#[allow(clippy::too_many_arguments)]
pub fn construct_circuit(
circuit_builder: &mut CircuitBuilder<E>,
insn_kind: InsnKind,
Expand Down
12 changes: 9 additions & 3 deletions ceno_zkvm/src/instructions/riscv/rv32im.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use super::{
use crate::instructions::riscv::auipc::AuipcInstruction;
#[cfg(feature = "u16limb_circuit")]
use crate::instructions::riscv::lui::LuiInstruction;
#[cfg(not(feature = "u16limb_circuit"))]
use crate::tables::PowTableCircuit;
use crate::{
error::ZKVMError,
instructions::{
Expand All @@ -28,9 +30,8 @@ use crate::{
},
structs::{ZKVMConstraintSystem, ZKVMFixedTraces, ZKVMWitnesses},
tables::{
AndTableCircuit, LtuTableCircuit, OrTableCircuit, PowTableCircuit, TableCircuit,
U5TableCircuit, U8TableCircuit, U14TableCircuit, U16TableCircuit, U18TableCircuit,
XorTableCircuit,
AndTableCircuit, LtuTableCircuit, OrTableCircuit, TableCircuit, U5TableCircuit,
U8TableCircuit, U14TableCircuit, U16TableCircuit, U18TableCircuit, XorTableCircuit,
},
};
use ceno_emul::{
Expand Down Expand Up @@ -127,6 +128,7 @@ pub struct Rv32imConfig<E: ExtensionField> {
pub or_table_config: <OrTableCircuit<E> as TableCircuit<E>>::TableConfig,
pub xor_table_config: <XorTableCircuit<E> as TableCircuit<E>>::TableConfig,
pub ltu_config: <LtuTableCircuit<E> as TableCircuit<E>>::TableConfig,
#[cfg(not(feature = "u16limb_circuit"))]
pub pow_config: <PowTableCircuit<E> as TableCircuit<E>>::TableConfig,
}

Expand Down Expand Up @@ -204,6 +206,7 @@ impl<E: ExtensionField> Rv32imConfig<E> {
let or_table_config = cs.register_table_circuit::<OrTableCircuit<E>>();
let xor_table_config = cs.register_table_circuit::<XorTableCircuit<E>>();
let ltu_config = cs.register_table_circuit::<LtuTableCircuit<E>>();
#[cfg(not(feature = "u16limb_circuit"))]
let pow_config = cs.register_table_circuit::<PowTableCircuit<E>>();

Self {
Expand Down Expand Up @@ -272,6 +275,7 @@ impl<E: ExtensionField> Rv32imConfig<E> {
or_table_config,
xor_table_config,
ltu_config,
#[cfg(not(feature = "u16limb_circuit"))]
pow_config,
}
}
Expand Down Expand Up @@ -350,6 +354,7 @@ impl<E: ExtensionField> Rv32imConfig<E> {
fixed.register_table_circuit::<OrTableCircuit<E>>(cs, &self.or_table_config, &());
fixed.register_table_circuit::<XorTableCircuit<E>>(cs, &self.xor_table_config, &());
fixed.register_table_circuit::<LtuTableCircuit<E>>(cs, &self.ltu_config, &());
#[cfg(not(feature = "u16limb_circuit"))]
fixed.register_table_circuit::<PowTableCircuit<E>>(cs, &self.pow_config, &());
}

Expand Down Expand Up @@ -480,6 +485,7 @@ impl<E: ExtensionField> Rv32imConfig<E> {
witness.assign_table_circuit::<OrTableCircuit<E>>(cs, &self.or_table_config, &())?;
witness.assign_table_circuit::<XorTableCircuit<E>>(cs, &self.xor_table_config, &())?;
witness.assign_table_circuit::<LtuTableCircuit<E>>(cs, &self.ltu_config, &())?;
#[cfg(not(feature = "u16limb_circuit"))]
witness.assign_table_circuit::<PowTableCircuit<E>>(cs, &self.pow_config, &())?;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion gkr_iop/src/cpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> Default for CpuBacke

impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> CpuBackend<E, PCS> {
pub fn new(max_poly_size_log2: usize, security_level: SecurityLevel) -> Self {
let param = PCS::setup(E::BaseField::TWO_ADICITY, security_level).unwrap();
let param = PCS::setup(1 << E::BaseField::TWO_ADICITY, security_level).unwrap();
let (pp, vp) = PCS::trim(param, 1 << max_poly_size_log2).unwrap();
Self {
pp,
Expand Down