-
Notifications
You must be signed in to change notification settings - Fork 172
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
feat(icicle): Add icicle MSM support #503
base: main
Are you sure you want to change the base?
Conversation
sagar-a16z
commented
Nov 15, 2024
•
edited
Loading
edited
- Rebased feat(icicle): Add icicle msm support #322
- Updated to latest icicle release
- Fixed it to use the GPU correctly
- Fall back to JOLT's CPU implementations when GPU is unavailable - much faster than the default CPU impl.
- Added msm benchmarks
- Overall Perf is up ~20%.
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
14cde19
to
5ea4227
Compare
With the newest benchmark I added, the GPU perf is actually really good. (This is a WSL machine on a 5800X3D + 3080TI) CPU
GPU
It’s WAY faster. For some reason it's much slower when running the examples. Maybe because my CPU usage was low while this benchmark ran where as the CPU is pinned when running the examples or maybe because I have plenty of left over memory. |
8bc1af1
to
705070a
Compare
4c0a59c
to
4a714c8
Compare
5a62f3e
to
146b4b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work! main question is: I think we need to move the icicle init into prove
; otherwise if someone is e.g. loading the preprocessing from disk and running prove
by itself, icicle won't be initialized. wdyt?
#[cfg(feature = "icicle")] | ||
let gpu_bases = Some( | ||
bases | ||
.par_iter() | ||
.map(|base| G1Projective::from_ark_affine(base)) | ||
.collect(), | ||
); | ||
|
||
let max_num_bits = scalars | ||
.par_iter() | ||
.map(|s| s.clone().into_bigint().num_bits()) | ||
.max() | ||
.unwrap(); | ||
|
||
println!("Using max num bits: {}", max_num_bits); | ||
#[cfg(not(feature = "icicle"))] | ||
let gpu_bases = None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[cfg(feature = "icicle")] | |
let gpu_bases = Some( | |
bases | |
.par_iter() | |
.map(|base| G1Projective::from_ark_affine(base)) | |
.collect(), | |
); | |
let max_num_bits = scalars | |
.par_iter() | |
.map(|s| s.clone().into_bigint().num_bits()) | |
.max() | |
.unwrap(); | |
println!("Using max num bits: {}", max_num_bits); | |
#[cfg(not(feature = "icicle"))] | |
let gpu_bases = None; | |
#[cfg(feature = "icicle")] | |
let gpu_bases = Some( | |
bases | |
.par_iter() | |
.map(|base| G1Projective::from_ark_affine(base)) | |
.collect(), | |
); | |
#[cfg(not(feature = "icicle"))] | |
let gpu_bases = None; | |
let max_num_bits = scalars | |
.par_iter() | |
.map(|s| s.clone().into_bigint().num_bits()) | |
.max() | |
.unwrap(); | |
println!("Using max num bits: {}", max_num_bits); |
let values: [u64; 4] = [ | ||
rng.next_u64(), | ||
rng.next_u64(), | ||
rng.next_u64(), | ||
rng.next_u64(), | ||
]; | ||
let bigint = ark_ff::BigInteger256::new(values); | ||
<Fr as JoltField>::from_bytes(&bigint.to_bytes_le()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should be able to just do
let values: [u64; 4] = [ | |
rng.next_u64(), | |
rng.next_u64(), | |
rng.next_u64(), | |
rng.next_u64(), | |
]; | |
let bigint = ark_ff::BigInteger256::new(values); | |
<Fr as JoltField>::from_bytes(&bigint.to_bytes_le()) | |
Fr::random(&mut rng) |
let values: [u64; 4] = [ | ||
rng.next_u64(), | ||
rng.next_u64(), | ||
rng.next_u64(), | ||
rng.next_u64(), | ||
]; | ||
let bigint = ark_ff::BigInteger256::new(values); | ||
<Fr as JoltField>::from_bytes(&bigint.to_bytes_le()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let values: [u64; 4] = [ | |
rng.next_u64(), | |
rng.next_u64(), | |
rng.next_u64(), | |
rng.next_u64(), | |
]; | |
let bigint = ark_ff::BigInteger256::new(values); | |
<Fr as JoltField>::from_bytes(&bigint.to_bytes_le()) | |
Fr::random(&mut rng) |
//TODO(sagar): This should be moved to a more appropriate place - icicle makes a network request | ||
// which impacts prover time. | ||
icicle::icicle_init(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be moved to prove
?