Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

[word-lo-hi] fine tune copy circuit to reduce degree #1508

Merged
merged 1 commit into from
Jul 3, 2023

Conversation

hero78119
Copy link
Member

@hero78119 hero78119 commented Jul 3, 2023

Description

[PR description]

Issue Link

#1499

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Contents

This pr is to rewrite/split copy circuit constrains to trade more gates with less degree.
copy table tag field is binary number decomposition with degree N (N represent number of bits, in copy table case N = 3). Once put in or::expr([#num_or_condition]), gate degrees will be exploded quickly by N*#num_or_condition.

Before PR, copy circuit max is degree 12,
After PR, copy circuit max 6 degree with 2 more gates.

However, circuit degree upper bound still increase by 1 (9 -> 10) for word-lo-hi refactor, due to state-circuit batch_is_zero-"is_zero is 1 if values are all zero"> gate degrees from 6 -> 10 Due to we fold 2 extra column, each contribute 2 degrees
https://github.com/privacy-scaling-explorations/zkevm-circuits/blob/word-lo-hi/zkevm-circuits/src/state_circuit.rs#L129-L141.

State circuit need some discussion, as I thought rewrite it might be a bit over-engineering.

@hero78119 hero78119 changed the title fine tune copy circuit to reduce degree [word-lo-hi] fine tune copy circuit to reduce degree Jul 3, 2023
@hero78119
Copy link
Member Author

hero78119 commented Jul 3, 2023

+ @adria0, might have thought on state-circuit case

@ChihChengLiang ChihChengLiang linked an issue Jul 3, 2023 that may be closed by this pull request
Copy link
Member

@ed255 ed255 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution looks good to me!

@hero78119 hero78119 mentioned this pull request Jul 3, 2023
6 tasks
Copy link
Collaborator

@ChihChengLiang ChihChengLiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hero78119
Copy link
Member Author

Will merge it first to unblock word-lo-hi back to main. state circuit case can fine tune later

@hero78119 hero78119 merged commit c5a34fd into word-lo-hi Jul 3, 2023
10 checks passed
@hero78119 hero78119 deleted the feat/degree branch July 3, 2023 09:03
@adria0
Copy link
Member

adria0 commented Jul 3, 2023

+ @adria0, might have thought on state-circuit case

Nice improvment! What do you have in mind (overengineered?) for the 4-batched zero check in state circuit?

@hero78119
Copy link
Member Author

hero78119 commented Jul 3, 2023

+ @adria0, might have thought on state-circuit case

Nice improvment! What do you have in mind (overengineered?) for the 4-batched zero check in state circuit?

Hi @adria0 my option is intuitively quick fix is separating into 4 zero check then and 4 is_zero expr() naturally. It lead to 4 extra is_zero config fields. It also implies BatchedIsZeroChip usage easily to lead to degree booming pitfall. Maybe we need to remove or redesign BatchedIsZeroChip

@adria0
Copy link
Member

adria0 commented Jul 3, 2023

BatchedIsZeroChip usage easily to lead to degree booming pitfall.

fortunately I see that only is used in state circuit :) Maybe 4 extra is_zero it's ok for now.
Crazy tradeoffs :neckbeard:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

optimise to reduce super circuit degree
4 participants