Repository navigation
Accelerate BN254 CRT export with AVX-512 IFMA - #182
Merged
Merged
Conversation
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.
Vectorize CRT reconstruction and BN254 export across eight coefficients, reducing the measured kernel time by approximately 64%.
The implementation:
• Uses AVX-512 IFMA for weighted CRT accumulation, exact bound certification, centering corrections, and Montgomery reduction.
• Incorporates radix adjustment into precomputed weights, producing the existing BN254 Montgomery representation directly.
• Preserves exact reconstruction fallback, rounding-mode handling, partial batches, and completed output prefixes when reconstruction encounters an invalid bound.
• Retains existing implementations for builds without the required instruction set.
All arithmetic remains exact. The fast-path certificate and accumulator bounds determine when vectorized reconstruction is valid; uncertified lanes use the existing exact fallback.
Measurements on an AMD EPYC 9454 with GCC 15.2, -O3 -march=native, and one pinned thread:
Output coefficients: Before, After, Speedup
14,938: 13.692 ms, 4.944 ms, 2.77×
29,875: 28.413 ms, 10.232 ms, 2.78×
These are median times from seven measured trials after two warmups, using clean production builds, eleven auxiliary primes, and twelve Fp12 coordinates. Measurements cover weighted CRT reconstruction and export, including output stores; setup, input conversion, and verification are excluded.