Avoid reciprocal correction for ordinary normalized moduli - #220
Open
perfloop-agent wants to merge 2 commits into
Open
Avoid reciprocal correction for ordinary normalized moduli#220perfloop-agent wants to merge 2 commits into
perfloop-agent wants to merge 2 commits into
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.
Summary
Keep the full reciprocal-product correction for the saturated initial seed at the 1/2 normalization boundary, but move it out of the ordinary path. Other normalized inputs use the downward-rounded Newton result directly, avoiding the five-by-four product and carry chain during reciprocal construction. The exceptional boundary retains the existing full-precision correction and its cost.
Performance
On workload
Reciprocal over dense four-word moduli, median metricns/opchanged from 69.49 to 52.34; paired median delta -17.27 (-24.8% of baseline; at least 19/20 confidence interval -17.45 to -16.59 from 10 pairs).On workload
Uncached MulMod over dense four-word moduli, median metricns/opchanged from 114.3 to 98.32; paired median delta -15.05 (-13.2% of baseline; at least 19/20 confidence interval -17.62 to -14.73 from 10 pairs).Testing
Ran the full test suite, the ternary modular-operation fuzz target, lint, and 386/ppc64 test compilation. Added reciprocal bound coverage across normalization and saturated-seed boundaries, plus big.Int modular-product differential coverage for adversarial operands and moduli.
All 5 declared correctness checks passed.
Full verification record: https://app.perfloop.ai/t/oss/case_gv3jgpm74s