Repository navigation
Small prime ntt - #173
Merged
Merged
Small prime ntt#173
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.
Adds bn254_small_prime_fft_backend, an opt-in polynomial backend that accelerates BN254 Fp12 arithmetic using transforms over 50-bit primes and exact signed CRT reconstruction.
The backend supports multiplication, dedicated squaring, low products, prepared low products, and prepared cyclic remainders. It integrates with the existing polynomial context and divisor context, allowing division and modular arithmetic to reuse transformed operands.
Implementation details:
• Scalar radix-4/radix-2 transforms with cached plans and reusable spectrum buffers.
• Exact FMA-based residue arithmetic using integer-valued doubles, with an integer fallback when the required floating-point conditions are unavailable.
• Explicit coefficient bounds, CRT capacity checks, and transform-size/storage checks.
• Owned prepared spectra that can be reused across compatible backend instances.
Performance
Measured on an AMD EPYC 9454 under KVM, pinned to one CPU, using GCC 15.2 with -O3 -march=native. Inputs are deterministic, dense synthetic BN254 Fp12 polynomials with modulus degree 14,938. Times are medians of five trials after two warmups; setup is measured separately.
Operation : Mixed-radix backend, Small-prime backend, Speedup
Multiplication : 4.235 s , 0.769 s, 5.51×
Squaring: 2.883 s , 0.603 s , 4.78×
Modular multiplication: 8.458 s , 1.621 s, 5.22×
Modular squaring: 7.072 s, 1.454 s, 4.86×