Skip to content

Conversation

hero78119
Copy link
Collaborator

No description provided.

@hero78119 hero78119 requested a review from spherel August 25, 2025 07:03
@@ -12,6 +12,7 @@ args = [
"--workspace",
]
command = "cargo"
env = { RUST_MIN_STACK = "33554432" }
Copy link
Collaborator Author

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.


self.require_reps_equal::<32, _, _>(
self.require_reps_equal::<16, _, _>(
Copy link
Collaborator Author

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

@hero78119 hero78119 mentioned this pull request Aug 25, 2025
3 tasks
Copy link
Member

@spherel spherel left a 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 => (),
Copy link
Member

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?

Copy link
Collaborator Author

@hero78119 hero78119 Aug 26, 2025

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

Comment on lines +1062 to +1084
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(),
)?,
Copy link
Member

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?

Copy link
Collaborator Author

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

@hero78119 hero78119 added this pull request to the merge queue Aug 26, 2025
Merged via the queue into scroll-tech:master with commit bad8dca Aug 26, 2025
4 checks passed
@hero78119 hero78119 deleted the feat/keccak_patch branch August 26, 2025 02:51
github-merge-queue bot pushed a commit that referenced this pull request Aug 26, 2025
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]     |
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants