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

Optimized Pippenger #60

Open
swasilyev opened this issue May 14, 2020 · 9 comments
Open

Optimized Pippenger #60

swasilyev opened this issue May 14, 2020 · 9 comments
Labels
T-feature Type: new features T-performance Type: performance improvements

Comments

@swasilyev
Copy link
Contributor

I assume that Zexe variable base multiexp is inherited from bellman. In section "New advances in multi-scalar-multiplication over elliptic curves" of this document by Aztec team it is shown that there is a 2x improvement.

@Pratyush
Copy link
Member

Yeah, this is definitely a good thing to investigate; it would provide an immediate speed up to many downstream SNARK applications

@adria0
Copy link
Contributor

adria0 commented May 21, 2020

Here is an implementation of the matter-labs team https://github.com/matter-labs/eip1962/blob/master/src/multiexp.rs, and the algo described here https://github.com/matter-labs/eip1962/blob/master/documentation/Algorithms_for_EIP1962.pdf (Algorithm 12)

@swasilyev
Copy link
Contributor Author

swasilyev commented May 21, 2020

Here is an implementation of the matter-labs team

It looks identical to bellman/zexe. Are you sure it uses the described trick?

Dusk PLONK uses zexe implementation, so i doubt a rust implementation already exists, only Aztec's in C++, see also

@adria0
Copy link
Contributor

adria0 commented May 25, 2020

It looks identical to bellman/zexe. Are you sure it uses the described trick?

Did not check it, @swasilyev, since it was a new implementation I wanted just to share it, in case is valuable.

@burdges
Copy link
Contributor

burdges commented Jun 7, 2020

@Pratyush
Copy link
Member

Pratyush commented Jun 7, 2020

From what I understand, the impl in PLONK has some different components in the MSM, namely it directly computes with affine elements, and then does a batch inversion. I think the fork in o1-labs/Zexe has a partial impl of this, so it could be a good idea to try and upstream that

@jon-chuang
Copy link
Contributor

jon-chuang commented Sep 11, 2020

This affine based MSM with a radix sort of the bucket index followed by a vectorised addition tree is available in celo-org/zexe#4

@jon-chuang
Copy link
Contributor

I assume that Zexe variable base multiexp is inherited from bellman. In section "New advances in multi-scalar-multiplication over elliptic curves" of this document by Aztec team it is shown that there is a 2x improvement.

Btw, ~2.2x is because 1.6-1.7x is due to adox/adcx. The other 1.4x is explained by the batch affine addition tree. Which we have achieved.

@jon-chuang
Copy link
Contributor

jon-chuang commented Sep 11, 2020

Results for 2^20 pippenger on 8-core Ryzen 4800H w/ 8MB L3 and 4.1GHz sustained all core boost, with SMT on:
barretenberg: 520ms (490ms CPU)
Zexe: 551ms.

The fat to be trimmed is not a Zexe issue, but lies in the radix sort used from an external library, which takes around 90ms compared to barretenberg's < 48ms. Once we trim the radix sort to be more cache friendly for multicore, hopefully we can close the gap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-feature Type: new features T-performance Type: performance improvements
Projects
None yet
Development

No branches or pull requests

5 participants