-
Notifications
You must be signed in to change notification settings - Fork 305
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
Relax restriction to a single looked table for CTL #1575
Relax restriction to a single looked table for CTL #1575
Conversation
2bebb8f
to
d1e57ba
Compare
starky/src/cross_table_lookup.rs
Outdated
}, | ||
) in cross_table_lookups.iter().enumerate() | ||
{ | ||
for (index, CrossTableLookup { looking_tables }) in cross_table_lookups.iter().enumerate() { | ||
// Get elements looking into `looked_table` that are not associated to any STARK. | ||
let extra_sum_vec: &[F] = ctl_extra_looking_sums |
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.
ctl_extra_looking_sums
are now indexed the same as cross_table_lookups
, not like looked tables.
@@ -1041,26 +971,21 @@ pub mod debug_utils { | |||
} | |||
} | |||
|
|||
fn check_ctl<F: Field>( | |||
fn check_ctl<F: PrimeField64>( |
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.
I'm not sure these functions are actually in use anywhere? They don't seem to have been updated to reflect the greater capabilities of logup vs the old product argument.
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.
They are being used on the zk_evm
side here: prover.rs
a274126
to
2e21697
Compare
In our use of plonky2, we have a few instances where we need both several looked and several looking tables. Think of these lookups as many-to-many multiplexers, or a kind of bus. Looking tables can be thought of as pushing values with an obligation to process them onto the bus, looked tables can be seen as pulling values to discharge that obligation. My first attempt changed from `looked_table` to `looked_tables`, but then I noticed that thanks to logup, we don't need this complication: looked_tables are just looking_tables with negative multiplicities. Thus we can get a simpler system by just removing `looked_table` completely, and giving people tools to negate the multiplicities of their lookup tables. We also preserve the old `CrossTableLookup::new`, which applies the negation to the passed `looked_table` automatically to keep the API as compatible as possible.
2e21697
to
6ef8270
Compare
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.
Thank you @matthiasgoergens , it's a good idea!
But I tried running this PR against the integration tests in zk_evm
(for example add11_yml
), and CTLs and Lookups failed. So I was wondering whether this was also the case for you or if maybe I had messed something up when testing?
This branch is based on an older version of #1577 which was broken (and that @matthiasgoergens now fixed). After rebasing this should go away I believe. |
Indeed, it works with those changes, thanks! |
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 changes look great (once it includes the fix from #1577 ), thank you @matthiasgoergens !
Could you please tell me how to run the zk_evm tests? Is it just 'cargo test' in there (after fixing the dependencies to point at my plonky2 branch)? Or something more involved? Thanks! Btw, do you have a way to run some benchmarks for zk_evm? I mean, I found some micro-benchmarks in the repo, but I'm looking for something more substantial that covers more of the system (but hopefully doesn't run for longer than a minute or perhaps five at most for one iteration). That's because I have some ideas for speeding up plonky2 that work for our system, but I want to make sure they don't make life worse for you. (And chances are, if it helps two unrelated system, it's probably a good idea in general.) |
@matthiasgoergens For testing, yes you can just run For benchmarking purposes, we usually would do it against real-life examples, with |
@matthiasgoergens Could you address the few comments / rebase with latest |
5ef7b30
to
e1c2acb
Compare
Please see the new version. |
.map(|table| table.table) | ||
.counts() | ||
.into_iter() | ||
.sorted() |
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.
We sort to keep the debug output deterministic.
log::debug!( | ||
"Processing CTL for {:?}", | ||
looking_tables | ||
.iter() | ||
.map(|table| table.table) | ||
.counts() | ||
.into_iter() | ||
.sorted() | ||
.collect::<Vec<_>>() | ||
); |
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.
At this point I think I may prefer just specifying for which table the CTL is, i.e.
log::debug!( | |
"Processing CTL for {:?}", | |
looking_tables | |
.iter() | |
.map(|table| table.table) | |
.counts() | |
.into_iter() | |
.sorted() | |
.collect::<Vec<_>>() | |
); | |
log::debug!( | |
"Processing CTL for STARK table {:?}", | |
looking_tables | |
.last(). | |
.expect("We always have a looked table.") | |
.table | |
); |
or otherwise removing it altogether. The current display doesn't carry much meaning (especially with the sorting which kind of hides which table is being looked at). For example this is our zkEVM output with this implem:
[DEBUG starky::cross_table_lookup] Processing CTL for [(0, 1), (2, 1)]
[DEBUG starky::cross_table_lookup] Processing CTL for [(1, 1), (2, 4)]
[DEBUG starky::cross_table_lookup] Processing CTL for [(2, 1), (4, 1)]
[DEBUG starky::cross_table_lookup] Processing CTL for [(3, 1), (4, 1)]
[DEBUG starky::cross_table_lookup] Processing CTL for [(3, 1), (4, 1)]
[DEBUG starky::cross_table_lookup] Processing CTL for [(2, 1), (4, 5), (5, 1)]
[DEBUG starky::cross_table_lookup] Processing CTL for [(1, 32), (2, 7), (4, 136), (6, 1)]
@matthiasgoergens thanks for this PR. Can I be of any help getting this across the line? Happy to take it from here or just get it caught up to |
Closing for inactivity. |
EDIT: it's perhaps better to get #1577 in first, and then I rebase this PR.
In our use of plonky2, we have a few instances where we need both several looked and several looking tables. Think of these lookups as many-to-many multiplexers, or a kind of bus. Looking tables can be thought of as pushing values with an obligation to process them onto the bus, looked tables can be seen as pulling values to discharge that obligation.
My first attempt changed from
looked_table
tolooked_tables
, but then I noticed that thanks to logup, we don't need this complication: looked_tables are just looking_tables with negative multiplicities.Thus we can get a simpler system by just removing
looked_table
completely, and giving people tools to negate the multiplicities of their lookup tables.We also preserve the old
CrossTableLookup::new
, which applies the negation to the passedlooked_table
automatically to keep the API as compatible as possible.This PR only touches cross table lookups. We could do the same for the intra-table lookups in
starky/src/lookup.rs
. But that's for a separate PR.