CurveFFT: Use one-inversion affine GLV ladders - #164
Draft
ValarDragon wants to merge 4 commits into
Draft
Conversation
This was referenced Aug 23, 2026
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
This draft collects the remaining CurveFFT affine-ladder optimizations above
#157. It is intentionally split into a portable algorithm commit and an Apple
AArch64 assembly commit so they can be reviewed and benchmarked independently.
The portable change replaces the two dependent inversion batches used for an
active affine
2P + Qladder column with a direct formula whose denominator isThis leaves one batch inversion for the column. It also:
slope and x-coordinate vectors;
work in the different-scalar ladder;
Q = PandQ = -2P;Q = -Pishandled directly by the new formula;
multiplications by one. A one-element batch keeps its dedicated path.
The Apple-specific commit then:
independent field products;
out == lhsaliasing by loading each pair before storing it;lanes while keeping the carried accumulators in their permitted lazy range;
and
Non-Apple targets retain the generic portable field path.
Commit split
1dc0e71— portable one-inversion formula, workspace reuse, seededtwo-chain inversion, exceptional-case changes, and tests.
2b1766b— Apple AArch64 paired Montgomery multiplication and pairedinversion back-substitution.
CurveFFT benchmark
Lower is better. Each cell is the arithmetic mean of six Criterion center
estimates.
Portable -> finalis the ASM step on macOS and a non-ASM controlbuild on Linux.
The Linux
portable -> finalresidual is not assembly: the Apple overrides arenot compiled there. Its 0.04–0.59% range is the observed control floor from
separate optimized builds and the two benchmark VMs. The replicated 5.40–5.55%
single-core step on the two M4 hosts is therefore well separated from that
floor. The smaller multicore step is expected because the per-worker field
kernel is a smaller fraction of wall time.
Method
curve-fft/affine-eisenstein-k11.--no-default-features --features batch.samples per estimate.
base/portable/final/final/portable/baseand two rotated orders.no competing Cargo, rustc, Criterion, or CurveFFT process appeared in the
snapshots.
The benchmarked revisions were
cfa5a2b,0914b72, and8372e98. The targetthen advanced by
ec3c137, which only registers and adds a separate GLV-tablemicrobenchmark. The two patches were mechanically rebased to the commit IDs
listed above; no library or CurveFFT benchmark code changed in that target
advance.
Correctness and validation
Q = -Pand the exceptionalQ = PandQ = -2Pcases.boundary, and
TWIDDLE_MAJOR_MAX_CHUNK-sized batches.Q = -Pnow takes the optimizeddirect formula.
cargo test --manifest-path pasta_curves/Cargo.toml --all-featurescargo test --manifest-path pasta_curves/Cargo.toml --no-default-featurescargo check --release --manifest-path pasta_curves/Cargo.toml --all-featurescargo fmt --all -- --checkgit diff --checkAPI surface
There is no new downstream-public API and no existing public signature or
visibility change.
Review-relevant internal additions are:
glv::private::Sealedhooks for paired base-field multiplication and,on Apple AArch64, batch-inversion back-substitution;
pub(crate)Fp/Fqruntime helpersmul_assign_pairs_runtimeandbatch_invert_backsub_runtime; andpub(super)AArch64 assembly wrappersmul_pairsandbatch_invert_backsub.The changelog records both the portable formula/inversion change and the Apple
assembly backend change.