Skip to content
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

[WIP] experiment devirgo-style sumcheck + FRI fold #653

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions ceno_zkvm/benches/riscv_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ fn bench_add(c: &mut Criterion) {
let timer = Instant::now();
let num_instances = 1 << instance_num_vars;
let mut transcript = Transcript::new(b"riscv");
let commit_proof_dur = std::time::Instant::now();
let commit =
Pcs::batch_commit_and_write(&prover.pk.pp, &wits_in, &mut transcript)
.unwrap();
let challenges = [
transcript.read_challenge().elements,
transcript.read_challenge().elements,
];
// println!("ADD commit proof took {:?}", commit_proof_dur.elapsed(),);

let _ = prover
.create_opcode_proof(
Expand Down
22 changes: 22 additions & 0 deletions ceno_zkvm/src/scheme/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> ZKVMProver<E, PCS> {
let mut wits = BTreeMap::new();

let commit_to_traces_span = entered_span!("commit_to_traces");
let commit_to_trace_dur = std::time::Instant::now();
// commit to opcode circuits first and then commit to table circuits, sorted by name
for (circuit_name, witness) in witnesses.into_iter_sorted() {
let num_instances = witness.num_instances();
Expand All @@ -107,6 +108,10 @@ impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> ZKVMProver<E, PCS> {
exit_span!(span);
wits.insert(circuit_name, (witness, num_instances));
}
println!(
"commit to trace duration {:?}",
commit_to_trace_dur.elapsed(),
);
exit_span!(commit_to_traces_span);

// squeeze two challenges from transcript
Expand Down Expand Up @@ -214,6 +219,7 @@ impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> ZKVMProver<E, PCS> {
transcript: &mut Transcript<E>,
challenges: &[E; 2],
) -> Result<ZKVMOpcodeProof<E, PCS>, ZKVMError> {
let main_proof_dur = std::time::Instant::now();
let cs = circuit_pk.get_cs();
let next_pow2_instances = next_pow2_instance_padding(num_instances);
let log2_num_instances = ceil_log2(next_pow2_instances);
Expand Down Expand Up @@ -598,6 +604,11 @@ impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> ZKVMProver<E, PCS> {
.map(|poly| poly.evaluate(&input_open_point))
.collect();
exit_span!(span);
println!(
"[opcode {}] main proof took {:?}",
name,
main_proof_dur.elapsed(),
);

let pcs_open_span = entered_span!("pcs_open");
let opening_dur = std::time::Instant::now();
Expand All @@ -621,8 +632,19 @@ impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> ZKVMProver<E, PCS> {
name,
opening_dur.elapsed(),
);
println!(
"[opcode {}] build opening proof took {:?}",
name,
opening_dur.elapsed(),
);
exit_span!(pcs_open_span);
let wits_commit_dur = std::time::Instant::now();
let wits_commit = PCS::get_pure_commitment(&wits_commit);
println!(
"[opcode {}] wits_commit took {:?}",
name,
wits_commit_dur.elapsed(),
);

Ok(ZKVMOpcodeProof {
num_instances,
Expand Down
4 changes: 4 additions & 0 deletions mpcs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ rand_chacha.workspace = true
rayon = { workspace = true, optional = true }
serde.workspace = true
transcript = { path = "../transcript" }
sumcheck = { version = "0", path = "../sumcheck" }
tracing.workspace = true
tracing-flame.workspace = true
tracing-subscriber.workspace = true

[dev-dependencies]
criterion.workspace = true
Expand Down
4 changes: 4 additions & 0 deletions mpcs/src/basefold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ pub use encoding::{coset_fft, fft, fft_root_table};
use multilinear_extensions::virtual_poly_v2::ArcMultilinearExtension;

mod query_phase;

// TODO share with ceno_zkvm
mod virtual_polys;

// This sumcheck module is different from the mpcs::sumcheck module, in that
// it deals only with the special case of the form \sum eq(r_i)f_i().
mod sumcheck;
Expand Down
Loading