Add opt-in AVX-512 IFMA batched field arithmetic for the Pasta fields - #286
Open
lamb356 wants to merge 2 commits into
Open
Add opt-in AVX-512 IFMA batched field arithmetic for the Pasta fields#286lamb356 wants to merge 2 commits into
lamb356 wants to merge 2 commits into
Conversation
Contributor
|
Nice work! Excited to test this soon! |
Adds an ifma feature to zakura-pasta-curves with 8-way AVX-512 IFMA kernels for batched Montgomery multiplication, squaring, scaling, and a deferred-reduction dot product over Fp/Fq, with runtime CPU detection and scalar fallbacks. halo2 gains a TypeId-dispatched batch module used for iFFT divisor scaling and deferred inner products. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration
Bot
force-pushed
the
devin/split-2-ifma
branch
from
September 2, 2026 00:19
b8c820c to
2ca2308
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds opt-in AVX-512 IFMA batched field arithmetic for the Pasta fields behind a new
ifmafeature (off by default, runtime CPU detection, scalar fallback always available).crates/pasta_curves/src/fields/ifma.rs: 8-way radix-52 kernels forFp/Fqbatched multiplication, squaring, and scaling (fp_mul_slice,fp_sqr_slice,fq_mul_slice,fq_sqr_slice, ...). Inputs/outputs stay in the canonical 4x64 Montgomery form; the radix-52 transpose happens inside the kernel.crates/pasta_curves/src/deferred.rs: accumulates unreduced 576-bit sums matching the scalar deferred accumulator exactly (composes with the deferred inner products that landed in Add deferred field inner products #277/Process deferred inner products in 32-product blocks #280), exposed asfp_inner_product/fq_inner_product.is_x86_feature_detected!dispatch — non-AVX-512 CPUs and non-x86 targets take the scalar path; default builds don't compile any of it.Isolated speedup ~1.85x per field mul (21.05ns → 11.41ns); end-to-end Orchard k=11 proving improved ~147ms → ~137ms at the point this was measured in the full stack (8 threads). Benchmarks in this series were 8-thread only — 16-core numbers from your side would be appreciated:
RAYON_NUM_THREADS=16 ORCHARD_K11_PROVER_THREADS=16 cargo bench -p zakura-orchard --features circuit,orbits --bench orchard_k11_proverPart of the split of #273 (piece 2 of 6). The FFT/evaluator PR (piece 6) builds on the batched slice ops added here.
Testing
cargo test --release --features ifmaincrates/pasta_curves: batch-op tests sweep lengths 0→5000 including carry-normalization boundaries, validated against the scalar path on an AVX-512 IFMA box.cargo check --locked --all-features --all-targets, MSRV (1.91) check, andcargo fmt --all -- --checkclean.