Skip to content
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

Improve the interpolation performance and avoid unnecessary state clones #55

Merged
merged 16 commits into from
May 26, 2022

Conversation

zhenfeizhang
Copy link
Contributor

@zhenfeizhang zhenfeizhang commented May 20, 2022

Description

This PR

  • improve the internal API to avoid unnecessary clones of prover and verifier states during IOP
  • improve the verifier complexity from O(num_vars^3) to O(num_vars^2)

with this PR

Verify/ML/10            time:   [143.88 us 144.17 us 144.48 us]

Verify/ML/11            time:   [156.66 us 157.11 us 157.58 us]

with 3d5c532 (prior to this PR)

Verify/ML/10            time:   [261.08 us 261.52 us 262.06 us]
                        change: [+78.989% +80.218% +82.102%] (p = 0.00 < 0.05)

Verify/ML/11            time:   [290.51 us 291.10 us 291.71 us]
                        change: [+83.756% +85.006% +86.476%] (p = 0.00 < 0.05)

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (master)
  • Linked to Github issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests
  • Updated relevant documentation in the code
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

@weikengchen weikengchen changed the title improve verifier complexity; improve api Improve the interpolation performance and avoid unnecessary state clones May 22, 2022
@weikengchen
Copy link
Member

I updated the code a little bit.

I would not say that the complexity reduces, but we know that the concrete efficiency generally improves. I adjusted the comments for this.

@zhenfeizhang
Copy link
Contributor Author

I would not say that the complexity reduces, but we know that the concrete efficiency generally improves. I adjusted the comments for this.

Is it because get_divisor is still a quadratic function?
We can actually use a similar method to compute divisors in linear time -- at a cost of 2 field divisions (where as the current code only has one division) per iteration. But it appears that O(n^2) primitive type multiplications is still faster than 1 field division.

Anyway, thanks for the review, and I am okay with the changes.

@weikengchen
Copy link
Member

Do you have the code for that? I am thinking about including a general-purpose case, even if it can be slightly slow (note that this interpolation usually is not the bottleneck).

@zhenfeizhang
Copy link
Contributor Author

zhenfeizhang commented May 23, 2022

I just pushed the code for that, and I managed to avoid the extra field division I thought that I needed.
Here are the latest benchmark result

Verify/ML/10            time:   [127.30 us 128.11 us 128.94 us]  
Verify/ML/11            time:   [147.69 us 148.81 us 150.05 us]              

Wait -- the code is currently buggy: the numerator for denominator may explode for pi.len = 20. Let me fix this.
fixed

@weikengchen
Copy link
Member

Should field_factorial also use field elements in the middle of the computation?

@zhenfeizhang
Copy link
Contributor Author

Should field_factorial also use field elements in the middle of the computation?

I think not. i64 already allows for 2^60+ number of elements in a single commit, or a zk circuit with 2^60+ variables. i would argue that one will never need to use a large commitment that will overflow i64.

@tsunrise tsunrise self-requested a review May 23, 2022 21:50
tsunrise
tsunrise previously approved these changes May 25, 2022
Copy link
Member

@tsunrise tsunrise left a comment

Choose a reason for hiding this comment

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

Looks good to me! I will make a new benchmark diagram later, and we can merge it then.

@weikengchen
Copy link
Member

I will need to look at the field_factorial again. Please wait for me :)

@tsunrise
Copy link
Member

tsunrise commented May 25, 2022

I will need to look at the field_factorial again. Please wait for me :)

sure, no rush (temporarily un-approve this for now in case someone merges this accidentally)

@tsunrise tsunrise dismissed their stale review May 25, 2022 04:43

temporarily unapprove this because we have more things to do: #55 (comment)

@zhenfeizhang
Copy link
Contributor Author

field_factorial

My bad. Misunderstood your point @weikengchen . fixed with e6d4b9d

@weikengchen weikengchen merged commit 0119955 into arkworks-rs:master May 26, 2022
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.

3 participants