-
Notifications
You must be signed in to change notification settings - Fork 36
fix lookup keccak rotation to use max 16 limb #1034
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
Conversation
@@ -12,6 +12,7 @@ args = [ | |||
"--workspace", | |||
] | |||
command = "cargo" | |||
env = { RUST_MIN_STACK = "33554432" } |
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.
lookup_keccak
involving some deep recursion when build the circuit. I think it's a existing issue, just the new change hit the threshold unluckily. With that, we temporarily increase RUST_MIN_STACK to make tests pass. It doesn't break functional correctness.
f87b99b
to
98a23d3
Compare
|
||
self.require_reps_equal::<32, _, _>( | ||
self.require_reps_equal::<16, _, _>( |
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.
key highlights: constrain on 16 bits limb individually instead of 32 bits (limb_16 + (1 << 16( * limb_16) because later are larger than some finite field characteristic, e.g. babybear
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.
Approve it temporarily. Will have a detailed review when next PR is ready.
if *size != 32 { | ||
lk_multiplicity.assert_ux_in_u16(*size, rep[j]); | ||
match *size { | ||
32 | 1 => (), |
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.
Why not checking it when size
is 1?
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.
because size 1 means bit check, and we compiled it into (1-expr)*expr
with zero check already. So size 1 we can skip multiplicity += 1
match *size { | ||
32 => (), | ||
18 => { | ||
self.assert_ux::<_, _, 18>(|| format!("{}_{}", name().into(), i), elem.clone())? | ||
} | ||
16 => { | ||
self.assert_ux::<_, _, 16>(|| format!("{}_{}", name().into(), i), elem.clone())? | ||
} | ||
14 => { | ||
self.assert_ux::<_, _, 14>(|| format!("{}_{}", name().into(), i), elem.clone())? | ||
} | ||
8 => { | ||
self.assert_ux::<_, _, 8>(|| format!("{}_{}", name().into(), i), elem.clone())? | ||
} | ||
5 => { | ||
self.assert_ux::<_, _, 5>(|| format!("{}_{}", name().into(), i), elem.clone())? | ||
} | ||
1 => self.assert_bit(|| format!("{}_{}", name().into(), i), elem.clone())?, | ||
_ => self.assert_ux_in_u16( | ||
|| format!("{}_{}", name().into(), i), | ||
*size, | ||
elem.clone(), | ||
)?, |
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.
Shall we put this in a helper function?
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.
yes will do it in next PR #1036 to fix precompile e2e sound
To close #953 , build on top of #1034 ### prover latency > test on AMD 5900XT (32 cores) + 64GB RAM e2e with fibonacci. switch all to Babybear got around 5% improvement | Benchmark | Median Time (s) | Median Change (%) | |------------------------------|------------------|-----------------------------------| | fibonacci_max_steps_1048576 | 2.3926 | -3.13% (Performance has improved) | | fibonacci_max_steps_2097152 | 4.3848 | -3.61% (Performance has improved) | | fibonacci_max_steps_4194304 | 8.2578 | -4.77% (Performance has improved) | ### proof size babybear overall reduce ~20% proof size | Benchmark | Proof Size (MB) | Change (↓ better) | |------------------------------|-----------------|--------------------| | fibonacci_max_steps_1048576 | 1.36 | -19.53% | | fibonacci_max_steps_2097152 | 1.44 | -18.64% | | fibonacci_max_steps_4194304 | 1.51 | -18.38% | ### circuit stats ```diff +---------------+---------------+---------+-------+-----------+--------+------------+---------------------+ | opcode_name | num_instances | lookups | reads | witnesses | writes | 0_expr_deg | 0_expr_sumcheck_deg | +---------------+---------------+---------+-------+-----------+--------+------------+---------------------+ - | OPCODES TOTAL | 0 | 1498 | 210 | 2688 | 210 | [1: 360] | [2: 114] | + | OPCODES TOTAL | 0 | 1636 | 216 | 2940 | 216 | [1: 478] | [2: 378,3: 148] | ```
No description provided.