a16z / jolt

The simplest and most extensible zkVM. Fast and fully open source from a16z crypto and friends. ⚡
https://jolt.a16zcrypto.com
MIT License
580 stars 105 forks source link

Optimize SparseGrandProductLayer #404

Open sragss opened 1 week ago

sragss commented 1 week ago

In grand_product.rs we have a sparse version of GKR which uses the type SparseGrandProductLayer<F> = Vec<(usize, F)>. Due to strict alignment rules I believe this takes up 64 bytes per element rather than 8 + 32 = 40. Switching the order to store the sparse tuples Vec<(F, usize)> might work, but I'd need to look into alignment rules. Does every tuple start on a 32-byte or 64-byte memory boundary adding implicit packing?

Alternatively we could move the indices to their own vector which would have tighter packing.