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

MSM optimizations #608

Merged
merged 4 commits into from
Jun 23, 2022
Merged

MSM optimizations #608

merged 4 commits into from
Jun 23, 2022

Conversation

ebfull
Copy link
Contributor

@ebfull ebfull commented Jun 22, 2022

  • This removes the parallelize calls from inside the MSM when operating on scalars, which has enormous overhead even for relatively large circuits.
  • We also now deduplicate the extra bases to minimize the width of the MSM. (Closes Allow MSM to deduplicate group elements #606)

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

ACK with question.

halo2_proofs/src/poly/commitment/msm.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK with suggestions for how to avoid the memory overhead in the map.

daira and others added 2 commits June 23, 2022 14:15
…ests.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
bases.extend(
self.other
.iter()
.map(|(x, (_, y))| C::from_xy(*x, *y).unwrap()),
Copy link
Contributor

Choose a reason for hiding this comment

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

See ebfull#1 (comment) for performance analysis of doing this vs storing x-coordinate -> (scalar, point).

Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK

@ebfull ebfull merged commit 7087c33 into zcash:main Jun 23, 2022
@ebfull ebfull deleted the msm-optimization branch June 23, 2022 16:49
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

ACK. I verified that the orchard tests (including the pinned proof) pass with this change.

Comment on lines +39 to +49
self.other
.entry(*x)
.and_modify(|(our_scalar, our_y)| {
if our_y == y {
*our_scalar += *scalar;
} else {
assert!(*our_y == -*y);
*our_scalar -= *scalar;
}
})
.or_insert((*scalar, *y));
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking: this could be de-duplicated from add_msm and append_term with a helper method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I couldn't quite get that to work, so deferred it for a later cleanup.

str4d added a commit that referenced this pull request Jun 23, 2022
`BatchVerifier` now manages the entire batch verification process.
Individual proofs are verified on a threadpool, and the resulting MSMs
are then batch-checked as before. The addition of parallelism here
couples with #608 to make parallelism less fine-grained and
reduce the overhead of multi-threading.
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.

Allow MSM to deduplicate group elements
3 participants