Skip to content

Cache fixed FFT operands and shorten polynomial modular reduction - #171

Merged
odraccir1 merged 4 commits into
masterfrom
ra/fft_optimizations
Oct 8, 2026
Merged

odraccir1 merged 4 commits into
masterfrom
ra/fft_optimizations

Conversation

@odraccir1

@odraccir1 odraccir1 commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

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).

@odraccir1
odraccir1 requested a review from spaceships October 8, 2026 16:44
@odraccir1
odraccir1 merged commit 598b22d into master Oct 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant