Specialize x86_64 Pasta field squaring - #56
Closed
ValarDragon wants to merge 1 commit into
Closed
Conversation
Contributor
Author
|
We'll likely go about this via inline ASM |
ValarDragon
force-pushed
the
agent/pasta-field-x86-asm
branch
from
August 19, 2026 22:15
e386dce to
717ff5a
Compare
ValarDragon
force-pushed
the
agent/pasta-x86-specialized-square
branch
from
August 19, 2026 22:15
1e4f6e4 to
9a5e02a
Compare
Contributor
Author
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.
What changed
Replace the x86-64 ADX/BMI2 field-square wrapper with a dedicated Pasta
Montgomery square in each checked-in object format:
The implementation forms each off-diagonal product once, doubles the
off-diagonal half, adds the four diagonal products, and then performs four
specialized Montgomery cancellation rounds. It uses the existing Pasta
modulus identities
p[2] = 0andp[3] = 2^62.The multiplication routine, Rust dispatch, Cargo feature, and native entry
symbol remain unchanged.
Why
The
x86_64-asmsquare path in #53 passes the same operand twice to thegeneral multiplication helper. The dedicated schedule reduces the square from
28 to 18
mulxinstructions while retaining the same fourimulinstructions.
The current optimized one-Action Orchard profile attributes 12.39 percentage
points of samples to the square call path. This made a specialized square a
larger concrete target than the remaining evaluator and FFT cleanups, subject
to direct measurement because the new carry schedule is more serial.
Performance
The accepted incremental DigitalOcean Linux/x86_64 bracket compares
signed-Booth production control
136b5e9with candidate6188da5on the samehost. Its balanced A/B/B/A mean centers were:
The two paired reductions were 1.537903870% and 1.412473176%; the median
reduction was 1.488702281%. The clean A/A retry had 0.299914844% median drift.
All accepted legs had zero CPU steal, swap activity, and competing processes.
An earlier A/A attempt was rejected after its first leg observed one steal
jiffy, before any candidate timing, and is retained in the archive.
The comparison uses Rust 1.88, locked dependencies, a genuine valid one-Action
Orchard proof at protocol
k = 11,RAYON_NUM_THREADS=1, and CPU pinning.Keys, fixtures, and proof verification remain outside the timed region. Both
binaries are built before A/A qualification and the balanced A/B/B/A bracket.
The preserved result archive has SHA-256
d6553d54a93a3a755f90c453a09ac8d49897af8e4dd07ead6c616acfd6d3461e.This is an incremental result, not a cumulative or root-to-tip claim; no root
benchmark or profile was run for this change.
Correctness and provenance
the existing
pasta_mul-armv8.Sbackend.cores.
cases against an independent big-integer Montgomery reference, including
stack, nonvolatile-register, canonical-output, and memory-trace checks.
.xdatabytes match it.proof creation and verification, pass on the available local lanes.
run on the benchmark host before timing.
The files retain the Semolina v0.1.4 Apache-2.0 provenance headers and explain
that multiplication remains generator-derived while the square is translated
from the existing AArch64 schedule.
API and compatibility surface
No public or
pub(crate)Rust item, signature, visibility, trait method, enumvariant, type alias, constant, constructor, Cargo feature, dependency,
lockfile, unsafe boundary, or serialized format changes.
The existing private square symbol keeps the same name, visibility, calling
convention, arguments, and output contract on every object format. Only its
body and the corresponding Windows unwind metadata change. Circuit
expressions, constraints, keys, transcripts, proof encoding, and proof
acceptance are unchanged.
Current final-MSM stack benchmark (2026-08-19)
The exact four-format square patch was replayed over the accepted general x86
backend and the GLV/XYZZ/multicore/c=10 stack. The incremental production
boundary was
12e8971->89f60eb.Standard balanced A/B/B/A geometric centers of means were:
B2's control drift was 2.16%, so that center is diagnostic. Serial B64 paired
reductions were 0.890957% and 1.048351%; eight-worker B64 paired reductions
were 1.583354% and 0.634702%. One prover attempt was rejected after a steal
jiffy; the complete retry had zero steal in all four legs and produced the
result above.
This layer composes with #53 to give 5.956128% lower proving latency,
2.239169% lower serial B64 latency, and 4.165871% lower eight-worker B64
latency over PR #93. Those are composed from the two direct incremental
brackets, not a separate endpoint run.
Current-stack archive SHA-256:
f35c6c98d9e1aa88f2280c4310ebef573b79ae6f621f59be0f47bd306013521f.