Repository navigation
Cache fixed FFT operands and shorten polynomial modular reduction - #171
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.
When reducing multiple polynomials modulo the same divisor, the existing implementation repeats FFTs of fixed operands and reconstructs each remainder using a full-length linear convolution.
This PR reduces that work through two optimizations:
Cache the FFTs of the reversed-divisor inverse prefix and the divisor representation. Preparations belong to the immutable divisor context, retain at most two spectra, and never grow during division.
Reconstruct the remainder with a shorter cyclic convolution when a suitable transform exists. Folding both the dividend and the complete divisor preserves the exact remainder because their wrapped high coefficients cancel.
The mixed-radix backend exposes optional prepared-operand operations through the existing arithmetic context. Division falls back to its existing paths for incompatible precision, transform lengths, or degree ranges. Generic multiply_low semantics, quotient computation, and cached Frobenius composition remain unchanged.
On the benchmarked BN254 Fp12 workload on the x86 machine, warm squaremod time decreased from 11.26 s to 7.07 s, a 37.2% reduction (1.59× speedup).