-
Notifications
You must be signed in to change notification settings - Fork 18
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
Feat/structural witin add #740
Feat/structural witin add #740
Conversation
- Add check for structural witnesses
Just to avoid falling too far behind. There seem to be no issues with the update.
This PR try to turn `Transcript` into a trait so we can apply different implenents (For example, the `TranscriptSyncronized`) in the future. We try to split the trait into a basic `Transcript` trait and a extended `Forkable` (with the `fork` method being provided) one. The original `Transcript` struct has been renamed into `BasicTranscript`.
Fixes scroll-tech#691. - Refactors e2e into smaller steps. - Introduces a `run_partial` method which takes a `prefix` argument, indicating when to stop the run of the pipeline. According to this argument, different parts of the state are yielded back. This part isn't too pretty type-wise, but ultimately I think it's not dangerous and a reasonable compromise for the moment. Later edit: I've also included a benchmark for witness generation of the Fibonacci program, since it is a consumer of this refactor and helps to exemplify it.
Extracted from scroll-tech#667 to make that PR smaller and easier to review.
…croll-tech#721) This PR has fixed issue scroll-tech#715 by respect the assertion in `from_base` method of the Godilock extension field Notice there is two method `from_base` and `form_limbs` in the `ExtensionField` trait which is not well illustrated and maybe we should update them later. The two running mentioned in scroll-tech#715 have been success under this PR `cargo run --package ceno_zkvm --bin e2e -- --platform=sp1 ceno_zkvm/examples/fibonacci.elf` `cargo run --package ceno_zkvm --example riscv_opcodes -- --start 10 --end 11`
To catch some bugs, like the recent breakage. --------- Co-authored-by: noelwei <[email protected]>
Just use `cargo fmt` or `cargo fmt --all` for the same effect. Especially the `fmt` target was obsolote: why would you want to format specifically only `ceno_zkvm`?
To make the diff for scroll-tech#596 easier to read.
To help make scroll-tech#596 easier to read and reason about. Also introduce a few more conversion helpers.
…ch#723) Features `non_pow2_rayon_thread` and `riv64` are not tested: we can't even compile with them. Because `riv64` is gone, we can make `riv32` invisible: it's effects are now just the default.
Implementing a TODO from scroll-tech#596
…#737) Extracted from scroll-tech#736 for ease of review.
…ceno into feat/structural_witin_add
- cargo fmt check
- Modify create_structural_witin() & create_witin() to improve readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work! most looks neat
left some comment of missing functionality
- Remove SetTableAddrType - Add more meta information in StructuralWitIn - Remove from_expr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just left some comments related to core design
ceno_zkvm/src/expression.rs
Outdated
@@ -25,6 +25,9 @@ use crate::{ | |||
pub enum Expression<E: ExtensionField> { | |||
/// WitIn(Id) | |||
WitIn(WitnessId), | |||
/// StructuralWitIn(WitnessId) | |||
/// same as witin, but it's structual witness and be evaluated by verifier succinctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I have a bit of a hard time understanding what you are trying to say.
Could you please fix the grammar? That might already help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
ceno_zkvm/src/expression.rs
Outdated
@@ -71,6 +75,7 @@ impl<E: ExtensionField> Expression<E> { | |||
&self, | |||
fixed_in: &impl Fn(&Fixed) -> T, | |||
wit_in: &impl Fn(WitnessId) -> T, // witin id | |||
structural_wit_in: &impl Fn(WitnessId) -> T, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The arguments to this function are getting quite involved, I wonder whether we should make a struct to hold all the arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far, it doesn't seem to need other arguments yet.
ceno_zkvm/src/witness.rs
Outdated
@@ -59,7 +59,11 @@ impl<T: Sized + Sync + Clone + Send + Copy> RowMajorMatrix<T> { | |||
} | |||
|
|||
pub fn num_instances(&self) -> usize { | |||
self.values.len() / self.num_col - self.num_padding_rows | |||
let mut num = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for mutation:
diff --git a/ceno_zkvm/src/witness.rs b/ceno_zkvm/src/witness.rs
index 88bfdcf5..47d4f2ee 100644
--- a/ceno_zkvm/src/witness.rs
+++ b/ceno_zkvm/src/witness.rs
@@ -59,11 +59,11 @@ impl<T: Sized + Sync + Clone + Send + Copy> RowMajorMatrix<T> {
}
pub fn num_instances(&self) -> usize {
- let mut num = 0;
- if self.num_col != 0 {
- num = self.values.len() / self.num_col - self.num_padding_rows
+ if self.num_col == 0 {
+ 0
+ } else {
+ self.values.len() / self.num_col - self.num_padding_rows
}
- num
}
pub fn num_padding_instances(&self) -> usize {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Please resolve the merge conflicts. |
Feat/structural witin add
- StructuralWitIn: Addr -> u32 - Combine witness RowMajorMatrix and structural witness RowMajorMatrix
Modify annotations for StructuralWitIn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall LGTM! 👍 thanks for the effort!
.all_equal(); | ||
// in table proof, we always skip same point sumcheck for now | ||
// as tower sumcheck batch product argument/logup in same length | ||
let is_skip_same_point_sumcheck = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related to respective "prover.rs", an advice to make thing consistent:
diff --git a/ceno_zkvm/src/scheme/prover.rs b/ceno_zkvm/src/scheme/prover.rs
index daaa1099..1a690fa0 100644
--- a/ceno_zkvm/src/scheme/prover.rs
+++ b/ceno_zkvm/src/scheme/prover.rs
@@ -965,12 +965,9 @@ impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> ZKVMProver<E, PCS> {
);
exit_span!(tower_span);
- // same point sumcheck is optional when all witin + fixed are in same num_vars
- let is_skip_same_point_sumcheck = witnesses
- .iter()
- .chain(fixed.iter())
- .map(|v| v.num_vars())
- .all_equal();
+ // in table proof, we always skip same point sumcheck for now
+ // as tower sumcheck batch product argument/logup in same length
+ let is_skip_same_point_sumcheck = true;
let (input_open_point, same_r_sumcheck_proofs, rw_in_evals, lk_in_evals) =
if is_skip_same_point_sumcheck {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is required that all the lengths are equal, right?
If yes, an assertion would be nice (restore the formula and add assert!(is_skip_same_point_sumcheck)
).
Hey @naure would kindly request you to have a quick review on this design, see whether any frontend/backend information leaked in between |
Inspired by reviewing scroll-tech#740
dbdddeb
to
c60475b
Compare
@@ -75,12 +67,13 @@ pub struct DynamicAddr { | |||
|
|||
#[derive(Clone, Debug)] | |||
pub struct SetTableSpec { | |||
pub addr_type: SetTableAddrType, | |||
pub len: usize, | |||
pub len: Option<usize>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does Some(0)
differ from None
?
Work for #654