Skip to content

feat(bench): raw multiplication with short and balanced factors - #421

Merged
alexanderlhicks merged 3 commits into
mainfrom
bench/raw-mul-short
Nov 19, 2026
Merged

alexanderlhicks merged 3 commits into
mainfrom
bench/raw-mul-short

Conversation

@alexanderlhicks

Copy link
Copy Markdown
Collaborator

This PR adds benchmark groups for Raw.mulRaw with a short factor and with balanced factors, over three coefficient types. No group measured a short right factor before. In that shape Raw.mulRaw does a number of additions that is quadratic in the long factor (#419). CONTRIBUTING asks for a new group in its own PR, so this PR comes before the fix.

Groups

All groups are in bench/CompPolyBench/Univariate/RawMul.lean. The coefficient types are KoalaBear's native-word representation (KoalaBear.Fast.Field), the BN254 scalar field as ZMod (BN254.ScalarField), and Int with entries in [-2^20, 2^20].

  • univariate-raw-mul-short-koalabear-{8,64,1024}, univariate-raw-mul-short-bn254-1024 and univariate-raw-mul-short-int-1024 multiply a dense factor with that many coefficients by a short factor. Each group has six rows:
    • scalar-right and scalar-left: mulRaw p (C c) and mulRaw (C c) p;
    • linear-right and linear-left: mulRaw p (X - C a) and mulRaw (X - C a) p;
    • cpoly-linear-right and cpoly-linear-left: p * (X - C a) and (X - C a) * p through the CPolynomial instance, which trims the result.
  • univariate-raw-mul-balanced-bn254-64 and univariate-raw-mul-balanced-int-64 multiply two dense factors with 64 coefficients, as mulRaw p q and mulRaw q p. The univariate-mul-crossover-* groups already measure balanced products over KoalaBear.Fast.Field.

The three coefficient types are commutative, so the two orders of a product give the same array. Each pair of rows shares a digest class, and the group agreement check compares them. Every body indexes a pool of two inputs. The sink reads four entries of the result (arraySampleSink), so its cost does not grow with the size of the result.

Each registry entry passes a concrete coefficient type to a top-level task function, so the compiler specializes the group runner and mulRaw at that type. A first version built the entries with a local helper in the task list. The compiler lifted that helper to one generic declaration, and every coefficient type then ran unspecialized code with the instance passed at run time. The KoalaBear loop of the current version returns unboxed uint32_t values in the generated C.

univariate-raw-mul-short-koalabear-64, univariate-raw-mul-short-koalabear-1024 and univariate-raw-mul-balanced-bn254-64 join bench/ci-groups.txt. The BN254 group runs the balanced runner on a ZMod coefficient type. The other two match the two crossover sizes already in the file. The table in bench/README.md lists the new prefixes.

Validation

Run on this commit:

  • lake build CompPolyBenchLib CompPolyBench: passes.
  • lake exe CompPolyBench --medium --validate-only --groups <bench/ci-groups.txt>: passes (290 records in 72 groups).
  • lake exe CompPolyBench --medium --validate-only: passes (500 records in 135 groups).
  • scripts/check-docs-integrity.py: passes.

This PR changes no Lean code under CompPoly/. Not run: the benchmarks on the CI runner.

Refs #419

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🤖 PR Summary

Mathematical Formalization

  • Benchmarks for CPolynomial.Raw.mulRaw with two new factor shapes: a short factor (degree 1) and two balanced dense factors of equal degree.
  • Three coefficient types are covered: KoalaBear.Fast.Field (unboxed 32-bit), BN254.ScalarField (ZMod), and Int (unboxed small integers).

Protocols / Soundness

  • The core change is in bench/CompPolyBench/Univariate/RawMul.lean, a new file that defines:
    • RawMulCarrier structure bundling slug, field name, coefficient generator, and checksum; three instances koalaBearCarrier, bn254Carrier, intCarrier.
    • runRawMulShortGroup and runRawMulBalancedGroup group runners, wrapped into benchmark tasks via rawMulShortTask and rawMulBalancedTask.
    • rawMulTasks list registering seven specific benchmark groups:
      • Short-factor groups: KoalaBear at sizes 8, 64, 1024; BN254 at 1024; Int at 1024.
      • Balanced groups: BN254 at 64; Int at 64.
    • Within each short-factor group, six rows measure: scalar-right, scalar-left, linear-right, linear-left, cpoly-linear-right, cpoly-linear-left.
    • Input pools of size two and a constant-time sink (arraySampleSink reading four entries) keep measurement overhead independent of result size.
    • Every pair of rows (left vs. right) shares a digest class; group agreement cross-checks them.
    • The compiler specialises the group runner per coefficient type because each registry entry passes a concrete type to the top-level task function.
  • The remaining files are mechanical registration: bench/CompPolyBench/Univariate.lean adds public import CompPolyBench.Univariate.RawMul and appends rawMulTasks to univariateTasks; bench/ci-groups.txt adds four entries (univariate-raw-mul-short-koalabear-64, univariate-raw-mul-short-koalabear-1024, univariate-raw-mul-balanced-bn254-64, univariate-raw-mul-balanced-int-64).

Infrastructure / CI

  • The four CI groups listed in bench/ci-groups.txt include a balance of KoalaBear (short), BN254 (balanced), and Int (balanced) to catch regressions in the quadratic-time short-factor path (tracked as issue Raw.mulRaw does quadratic additions when the right factor is short #419).
  • The PR passes all validation steps (build, --validate-only on both the CI group set and the full suite, documentation integrity check).
  • No sorry or admit placeholders are introduced by this change.
  • No Lean code under CompPoly/ is modified; all changes are confined to the benchmark infrastructure.

Documentation

  • A module-level comment in RawMul.lean details design decisions (input pools, digest classes, sink).
  • bench/README.md is updated to list the new benchmark prefixes (mentioned in the PR body but not visible in the per-file summaries – the change is consistent with the body's description).

Statistics

Metric Count
📝 Files Changed 4
✅ Lines Added 207
❌ Lines Removed 1

Lean Declarations

✏️ Added: 8 declaration(s)

bench/CompPolyBench/Univariate/RawMul.lean (8)

  • def rawMulTasks : List BenchTask
  • private def bn254Carrier : RawMulCarrier BN254.ScalarField
  • private def intCarrier : RawMulCarrier Int
  • private def koalaBearCarrier : RawMulCarrier KoalaBear.Fast.Field
  • private def rawMulBalancedTask {R : Type} [CommSemiring R] (carrier : RawMulCarrier R)
  • private def rawMulShortTask {R : Type} [CommRing R] [BEq R] [LawfulBEq R]
  • private def runRawMulBalancedGroup {R : Type} [CommSemiring R]
  • private def runRawMulShortGroup {R : Type} [CommRing R] [BEq R] [LawfulBEq R]

sorry Tracking

  • No sorrys were added, removed, or affected.

📋 **Additional Analysis**

The contribution adds a benchmark group for raw polynomial multiplication over several coefficient types. It follows the library's benchmarking conventions: a new module in bench/CompPolyBench/Univariate/, registration in the task list and ci-groups.txt, an entry in bench/README.md, and the use of the established runTimedSpec / digest / sink API. There are no Lean definition, proof, or style changes outside the benchmarking infrastructure. The diff does not conflict with any of the


📄 **Per-File Summaries**
  • bench/CompPolyBench/Univariate.lean: Added public import CompPolyBench.Univariate.RawMul to expose the new module, and appended rawMulTasks to the univariateTasks list so that the raw-multiplication benchmarks are included in the benchmark suite. These changes register the newly available raw multiplication benchmarks (from the RawMul module) as part of the overall univariate benchmark task collection.
  • bench/CompPolyBench/Univariate/RawMul.lean: This new file adds benchmark groups for raw polynomial multiplication (CPolynomial.Raw.mulRaw) over three coefficient types: KoalaBear.Fast.Field (unboxed 32‑bit), BN254.ScalarField (ZMod via big‑nat closures), and Int (unboxed small integers). It defines a RawMulCarrier structure that bundles a slug, field name, coefficient generator, and checksum, then instantiates it for each type (koalaBearCarrier, bn254Carrier, intCarrier). Two group runners are provided: runRawMulShortGroup times short‑factor multiplications (by C c and X - C a, both left and right, including a CPolynomial path for linear factors) at a given degree, and runRawMulBalancedGroup times balanced products of two dense factors of the same degree (both orders). Helper tasks rawMulShortTask and rawMulBalancedTask wrap each runner into a BenchTask, and the final list rawMulTasks registers seven specific benchmarks: three short‑factor sizes for KoalaBear (8, 64, 1024) and one each for BN254 and Int (1024), plus two balanced‑product benchmarks for BN254 and Int (64). The module‑level comment details the design of input pools, digest classes, and the timed sink, enabling cross‑comparison of raw and CPolynomial paths.
  • bench/ci-groups.txt: Added four new benchmark entries to bench/ci-groups.txt in the univariate group: univariate-raw-mul-short-koalabear-64, univariate-raw-mul-short-koalabear-1024, univariate-raw-mul-balanced-bn254-64, and univariate-raw-mul-balanced-int-64. The included comment explains that these test raw (univariate) multiplication with a short right factor at sizes 64 and 1024 (the latter chosen because a quadratic-time product with a short right factor is more than 100× slower than the same product with the factor on the left, and thus catches regressions), and that the balanced variants run the ZMod and Int coefficient types.
  • 1 file(s) filtered as noise (lockfiles, generated, or trivial): bench/README.md

Last updated: 2026-11-19 23:35 UTC.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Build Timing Report

  • Commit: f17b98a
  • Message: Merge 750161f into cc71356
  • Ref: bench/raw-mul-short
  • Comparison baseline: 347f09b from the previous successful PR update.
  • Measured on ubuntu-latest with /usr/bin/time -p.
  • Commands: library build (warm) lake build; test path lake test.
  • Clean build was skipped (warm/incremental CI; no toolchain or lake-manifest change). Runs automatically when lean-toolchain or lake-manifest.json changes, or via Actions → Lean Action CI → Run workflow with clean_build.
Measurement Baseline (s) Current (s) Delta (s) Status
Library build (warm) 1.76 4.10 +2.34 ok
Test path 1.55 1.28 -0.27 ok

Incremental Rebuild Signal

  • Warm-only run: default CI reuses cached oleans and rebuilds dirty modules only. No same-job clean:warm ratio.

Slowest Current Build Files (warm library build)

Showing 3 slowest of 3 repo targets parsed from the current warm library build log.

Wall (s) Path
1.90 CompPoly/Fields/KoalaBear/Ext5/QuinticIrreducible.lean
1.00 CompPoly/Data/Polynomial/Rabin.lean
1.00 CompPoly/Fields/KoalaBear/Ext6/SexticIrreducible.lean

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Benchmarks (--medium)

Groups: the curated set in bench/ci-groups.txt

Timings come from a shared 2-vCPU GitHub runner and are
advisory. Read the Spread column before any ratio:
n=1 rows are a single unrepeated sample and carry no
dispersion at all. Correctness is gated separately, on every PR.

Evaluation Benchmark Report

  • Seed: 20260504
  • Preset: medium
  • Benchmark timings are informational and depend on runner hardware.

Runner Hardware

  • Runner: Linux X64
  • CPU: AMD EPYC 7763 64-Core Processor
  • Exposed CPUs: 4 logical CPUs
  • Topology: 2 cores per socket, 2 threads per core, 1 socket(s)
  • RAM: 15 GiB
  • Root disk: 145G
  • Hypervisor: Microsoft

Results

Harness loop and sink floor

  • Group key: harness-floor
  • Representation: UInt64
  • Field / configuration: none
  • Input shape: no input
  • Checksum iterations: 16
  • Total group time: 20.06 ms
  • Checksum: 18119557631070038941
Implementation Warmup Iterations Samples Total (ms) Median (ns) Spread
empty body 33554431 10723860 20 20.06 1 ±0.1%

Harness dead-code canary

  • Group key: harness-canary
  • Representation: UInt64
  • Field / configuration: none
  • Input shape: no input
  • Checksum iterations: 16
  • Total group time: 19.98 ms
  • Checksum: 15387632686669236936
Implementation Warmup Iterations Samples Total (ms) Median (ns) Spread
256 mixing rounds 131071 37040 20 19.98 539 ±0.0%

Chain loop floor, per operation

  • Group key: harness-chain-floor
  • Representation: UInt64
  • Field / configuration: none
  • Input shape: no input
  • Checksum iterations: 1
  • Total group time: 39.91 ms
  • Checksum: latency: 33882034072300, throughput: 56146324416
Implementation Warmup Iterations Samples Total (ms) Median (ns) Per unit (ps) Spread
1280x shift-add, dependent 65535 25660 20 20 778 607 ±0.0% !1
1280x shift-add, 10-wide 262143 88000 20 19.92 226 176 ±0.0% !2

Chain linearity check

  • Group key: harness-chain-linearity
  • Representation: UInt64
  • Field / configuration: none
  • Input shape: no input
  • Checksum iterations: 1
  • Total group time: 40 ms
  • Checksum: short: 33882034072300, long: 143616925857544455
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
1280 rounds 65535 25680 20 20.02 0.78 ±0.0% !2
10240 rounds 8191 3140 20 19.98 6.35 ±0.0% !3

Univariate dense evaluation (KoalaBear)

  • Group key: univariate-dense-koalabear
  • Representation: CPolynomial
  • Input shape: degree<512, dense, 32 points
  • Checksum iterations: 32
  • Total group time: 76.7 ms
  • Checksum: 11055469492244178969
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Sum of powers 511 100 20 17.17 171.83 ±0.1% !2
Horner 2047 700 20 19.75 28.21 ±0.0%
Sum of powers (fast KoalaBear) 4095 960 20 19.81 20.63 ±0.0% !2
Horner (fast KoalaBear) 32767 7860 20 19.96 2.54 ±0.0% !2

Univariate sparse evaluation (KoalaBear)

  • Group key: univariate-sparse-koalabear
  • Representation: CPolynomial
  • Input shape: degree<512, one nonzero per 4 coeffs, 32 points
  • Checksum iterations: 32
  • Total group time: 76.57 ms
  • Checksum: 2172971109597167173
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Sum of powers 511 100 20 17.25 171.68 ±0.2% !2
Horner 2047 700 20 19.67 28.03 ±0.1% !2
Sum of powers (fast KoalaBear) 4095 960 20 19.67 20.48 ±0.0% !2
Horner (fast KoalaBear) 32767 7920 20 19.98 2.52 ±0.0%

Univariate monic remainder, small (KoalaBear)

  • Group key: univariate-monic-remainder-small-koalabear
  • Representation: CPolynomial
  • Input shape: degree<128 dividend, degree=16 monic divisor
  • Checksum iterations: 1
  • Total group time: 2.72 s
  • Checksum: 13323218338012105879
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Long division 1 16 16 1.94 121.49 ±0.1% !1
Remainder-only division 127 20 20 0.01 0.72 ±0.3% !1
Reversal with convolution low product 15 20 20 0.08 4.03 ±0.1% !1
Reversal with NTT low product 15 20 20 0.08 3.89 ±0.4%
Reversal with fast NTT low product 63 20 20 0.02 1.23 ±0.1% !2
Long division (fast KoalaBear) 3 20 20 0.5 24.87 ±0.2%
Remainder-only division (fast KoalaBear) 511 100 20 0.02 0.19 ±0.0% !2
Reversal with convolution low product (fast KoalaBear) 31 20 20 0.03 1.67 ±2.6%
Reversal with NTT low product (fast KoalaBear) 127 20 20 0.01 0.54 ±0.5%
Reversal with fast NTT low product (fast KoalaBear) 255 80 20 0.02 0.23 ±0.4% !1

Univariate dense evaluation (Goldilocks)

  • Group key: univariate-dense-goldilocks
  • Representation: CPolynomial
  • Input shape: degree<512, dense, 32 points
  • Checksum iterations: 32
  • Total group time: 69.58 ms
  • Checksum: 16062090315130933973
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Sum of powers (Goldilocks.Field) 255 40 20 13.91 345.47 ±0.6% !2
Horner (Goldilocks.Field) 255 80 20 15.67 196.12 ±0.1%
Sum of powers (fast Goldilocks) 4095 1120 20 20 17.84 ±0.0% !1
Horner (fast Goldilocks) 32767 8460 20 20.01 2.36 ±0.0% !2

Univariate dense evaluation (BN254)

  • Group key: univariate-dense-bn254
  • Representation: CPolynomial
  • Input shape: degree<512, dense, 32 points
  • Checksum iterations: 32
  • Total group time: 62.83 ms
  • Checksum: 17077529006470095184
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Sum of powers (BN254.ScalarField) 127 20 20 12.54 622.87 ±0.5% !2
Horner (BN254.ScalarField) 255 80 20 19.89 248.55 ±0.2%
Sum of powers (BN254.Fast.ScalarField) 127 20 20 10.62 532.41 ±0.7%
Horner (BN254.Fast.ScalarField) 2047 440 20 19.8 44.78 ±0.3% !2

Univariate dense evaluation (BLS12-381)

  • Group key: univariate-dense-bls12-381
  • Representation: CPolynomial
  • Input shape: degree<512, dense, 32 points
  • Checksum iterations: 32
  • Total group time: 64.22 ms
  • Checksum: 1719341172658659424
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Sum of powers (BLS12_381.ScalarField) 127 20 20 12.58 629.97 ±0.7%
Horner (BLS12_381.ScalarField) 255 80 20 19.76 246.75 ±0.1% !1
Sum of powers (BLS12_381.Fast.ScalarField) 127 20 20 11.89 510.35 ±2.0%
Horner (BLS12_381.Fast.ScalarField) 2047 460 20 19.99 43.38 ±0.0% !2

Univariate dense evaluation (BLS12-377)

  • Group key: univariate-dense-bls12-377
  • Representation: CPolynomial
  • Input shape: degree<512, dense, 32 points
  • Checksum iterations: 32
  • Total group time: 71.27 ms
  • Checksum: 17760239055068452211
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Sum of powers (BLS12_377.ScalarField) 127 20 20 12.58 626.54 ±0.6% !1
Horner (BLS12_377.ScalarField) 255 80 20 19.15 239.41 ±0.2%
Sum of powers (BLS12_377.Fast.ScalarField) 127 40 20 19.97 495.64 ±0.2% !2
Horner (BLS12_377.Fast.ScalarField) 2047 440 20 19.58 43.64 ±0.3% !2

Univariate dense evaluation (BabyBear)

  • Group key: univariate-dense-babybear
  • Representation: CPolynomial
  • Input shape: degree<512, dense, 32 points
  • Checksum iterations: 32
  • Total group time: 77.01 ms
  • Checksum: 14945969849079160193
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Sum of powers 255 80 20 17.34 216.21 ±0.5%
Horner 2047 700 20 19.87 28.3 ±0.0% !2
Sum of powers (fast BabyBear) 4095 960 20 19.87 20.62 ±0.1% !1
Horner (fast BabyBear) 32767 7840 20 19.93 2.54 ±0.0%

Univariate batch evaluation, small (KoalaBear)

  • Group key: univariate-batch-small-koalabear
  • Representation: CPolynomial
  • Input shape: degree<128, dense, 16 points
  • Checksum iterations: 1
  • Total group time: 4.01 s
  • Checksum: 5727686308625674759
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Batch sum of powers 511 160 20 0.02 0.12 ±0.0% !1
Batch Horner 511 160 20 0.02 0.12 ±0.0% !2
Subproduct tree, naive mul/mod 1 7 7 2.11 301.19 ±0.9%
Subproduct tree, naive mul/remainder-only 63 20 20 0.03 1.46 ±0.5%
Subproduct tree, NTT mul/remainder-only 31 20 20 0.04 1.85 ±0.1%
Subproduct tree, fast NTT mul/remainder-only 31 20 20 0.03 1.63 ±0.2%
Subproduct tree, naive mul/reversal convolution 7 20 20 0.18 8.94 ±0.1% !2
Subproduct tree, NTT mul/reversal low product 7 20 20 0.18 8.97 ±0.0% !1
Subproduct tree, fast NTT mul/reversal low product 31 20 20 0.07 3.27 ±0.1%
Batch sum of powers (fast KoalaBear) 4095 1140 20 0.02 0.02 ±0.1% !2
Batch Horner (fast KoalaBear) 4095 1140 20 0.02 0.02 ±0.1%
Subproduct tree, naive mul/mod (fast KoalaBear) 1 20 20 1.13 56.08 ±0.1% !1
Subproduct tree, naive mul/remainder-only (fast KoalaBear) 127 40 20 0.02 0.41 ±0.2%
Subproduct tree, NTT mul/remainder-only (fast KoalaBear) 127 40 20 0.02 0.49 ±0.8%
Subproduct tree, fast NTT mul/remainder-only (fast KoalaBear) 127 40 20 0.02 0.47 ±0.3%
Subproduct tree, naive mul/reversal convolution (fast KoalaBear) 15 20 20 0.08 3.73 ±0.3% !2
Subproduct tree, NTT mul/reversal low product (fast KoalaBear) 63 20 20 0.03 1.4 ±0.2%
Subproduct tree, fast NTT mul/reversal low product (fast KoalaBear) 127 20 20 0.01 0.73 ±0.7% !1

Univariate many-polynomial one-point evaluation (KoalaBear)

  • Group key: univariate-many-one-point-koalabear
  • Representation: Array CPolynomial
  • Input shape: 512 dense polys, degree<4096, one shared point
  • Checksum iterations: 1
  • Total group time: 4.32 s
  • Checksum: 12839799678498798729
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Horner 1 18 18 2.03 111.53 ±0.6% !3
Shared powers 1 18 18 1.96 108.57 ±0.2% !1
Horner (fast KoalaBear) 7 20 20 0.21 10.72 ±0.1% !1
Shared powers (fast KoalaBear) 15 20 20 0.11 5.67 ±0.2%

Univariate multiplication (KoalaBear)

  • Group key: univariate-mul-koalabear
  • Representation: CPolynomial
  • Input shape: degree<1024 dense lhs/rhs
  • Checksum iterations: 1
  • Total group time: 2.72 s
  • Checksum: 15331384417522972793
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Naive 1 15 15 1.97 129.49 ±0.3% !3
NTT 7 20 20 0.21 10.63 ±0.6%
Fast NTT 15 20 20 0.07 3.64 ±0.3%
Fast NTT with cached plan 15 20 20 0.07 3.46 ±0.2%
Naive (fast KoalaBear) 7 20 20 0.31 15.26 ±0.0% !1
NTT (fast KoalaBear) 31 20 20 0.04 2.08 ±0.2% !1
Fast NTT (fast KoalaBear) 63 20 20 0.02 1.2 ±0.2% !1
Fast NTT with cached plan (fast KoalaBear) 63 20 20 0.03 1.32 ±0.2%

Univariate multiplication (BabyBear)

  • Group key: univariate-mul-babybear
  • Representation: CPolynomial
  • Input shape: degree<1024 dense lhs/rhs
  • Checksum iterations: 1
  • Total group time: 2.67 s
  • Checksum: 17883851889686433263
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Naive 1 15 15 1.95 130.3 ±1.4%
NTT 7 20 20 0.2 10.15 ±1.7%
Fast NTT 15 20 20 0.07 3.64 ±0.3%
Fast NTT with cached plan 15 20 20 0.07 3.43 ±0.1% !1
Naive (fast BabyBear) 7 20 20 0.3 14.91 ±0.3%
NTT (fast BabyBear) 31 20 20 0.04 1.91 ±0.0% !1
Fast NTT (fast BabyBear) 63 20 20 0.02 1.18 ±0.2% !2
Fast NTT with cached plan (fast BabyBear) 63 20 20 0.02 1.21 ±0.2%

Univariate low product (KoalaBear)

  • Group key: univariate-low-product-koalabear
  • Representation: CPolynomial.Raw
  • Input shape: degree<512 dense lhs/rhs, low<512
  • Checksum iterations: 1
  • Total group time: 1.46 s
  • Checksum: 16615129783079635176
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Naive 3 20 20 0.65 32.13 ±0.2% !2
Convolution 3 20 20 0.42 20.79 ±0.1%
NTT with fallback 15 20 20 0.09 4.42 ±0.0%
Fast NTT with fallback 63 20 20 0.03 1.41 ±0.2%
Naive (fast KoalaBear) 15 20 20 0.08 4.03 ±0.3%
Convolution (fast KoalaBear) 7 20 20 0.17 8.37 ±0.2% !1
NTT with fallback (fast KoalaBear) 127 20 20 0.01 0.72 ±0.1% !4
Fast NTT with fallback (fast KoalaBear) 127 40 20 0.02 0.43 ±0.2%

Univariate finite-field smooth-subgroup root search (KoalaBear)

  • Group key: univariate-roots-finite-field-koalabear
  • Representation: CPolynomial
  • Input shape: degree=66, 65 distinct roots, one of them repeated
  • Checksum iterations: 1
  • Total group time: 12.47 s
  • Checksum: 15734479945277451086
Implementation Warmup Iterations Samples Total (s) Median (s) Spread
Smooth subgroup 1 1 1 3.8 3.8 n=1
Smooth subgroup, NTT 1 2 2 1.66 0.83 ±0.0% (n=2)
Smooth subgroup, fast NTT 1 5 5 1.84 0.37 ±0.0%
Smooth subgroup (fast KoalaBear) 1 2 2 1.42 0.71 ±0.0% (n=2)
Smooth subgroup, NTT (fast KoalaBear) 1 13 13 1.92 0.15 ±0.3% !1
Smooth subgroup, fast NTT (fast KoalaBear) 1 20 20 1.84 0.09 ±0.1% !2

Multiplicative NTT, KoalaBear, n = 2^12

  • Group key: ntt-koalabear-l12
  • Representation: Array
  • Field / configuration: koalabear
  • Input shape: n = 2^12, two inputs
  • Checksum iterations: 2
  • Total group time: 77.17 ms
  • Checksum: forward: 15407938740885339470, inverse: 6021727414497265728
Implementation Warmup Iterations Samples Total (ms) Median (ms) Per unit (ps) Spread
radix-2 127 40 20 18.85 0.47 19188 ±0.1%
radix-4 DIF (plan) 511 120 20 17.44 0.15 5914 ±0.1% !3
radix-2 63 20 20 22.23 1.11 45191 ±0.0%
radix-4 DIT (plan) 511 120 20 18.64 0.16 6315 ±0.0% !4

Multiplicative NTT, BabyBear, n = 2^12

  • Group key: ntt-babybear-l12
  • Representation: Array
  • Field / configuration: babybear
  • Input shape: n = 2^12, two inputs
  • Checksum iterations: 2
  • Total group time: 79.97 ms
  • Checksum: forward: 859907655392287266, inverse: 16043543068773104175
Implementation Warmup Iterations Samples Total (ms) Median (ms) Per unit (ps) Spread
radix-2 127 40 20 19.17 0.48 19379 ±0.1% !4
radix-4 DIF (plan) 511 140 20 19.86 0.14 5766 ±0.0% !1
radix-2 63 20 20 22.05 1.1 44789 ±0.1% !1
radix-4 DIT (plan) 511 120 20 18.89 0.16 6409 ±0.0% !2

NTT plan construction (KoalaBear)

  • Group key: ntt-plan-koalabear
  • Representation: Plan
  • Field / configuration: koalabear
  • Checksum iterations: 2
  • Total group time: 33.38 ms
  • Checksum: l12: 6977350635822833048, l16: 15506466996543367334
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
ofDomain 1023 360 20 18.84 52.34 ±0.0% !1
ofDomain 127 20 20 14.54 725.92 ±0.7%

Reed-Solomon encoding, KoalaBear, n = 2^10

  • Group key: rs-encode-koalabear-l10
  • Representation: Vector
  • Field / configuration: koalabear
  • Input shape: n = 2^10, rate 1/2, two messages
  • Checksum iterations: 2
  • Total group time: 104.66 ms
  • Checksum: 11042508700611597092
Implementation Warmup Iterations Samples Total (ms) Median (ms) Per unit (ps) Spread
encode (Horner per node) 15 20 20 85.72 4.28 4179749 ±0.0%
nttCodeword 511 180 20 18.93 0.11 102540 ±0.0% !3

Schoolbook against NTT multiplication, degree<64

  • Group key: univariate-mul-crossover-64
  • Representation: CPolynomial
  • Field / configuration: KoalaBear.Fast.Field
  • Input shape: degree<64 dense lhs/rhs, two orderings
  • Checksum iterations: 2
  • Total group time: 36.45 ms
  • Checksum: 6451336114860894105
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
Naive 511 140 20 17.58 125.32 1958183 ±0.1% !5
NTTFast.Plan.fastMulImpl 1023 280 20 18.87 67.43 1053539 ±0.1% !1

Schoolbook against NTT multiplication, degree<256

  • Group key: univariate-mul-crossover-256
  • Representation: CPolynomial
  • Field / configuration: KoalaBear.Fast.Field
  • Input shape: degree<256 dense lhs/rhs, two orderings
  • Checksum iterations: 2
  • Total group time: 38.78 ms
  • Checksum: 16165228242284266953
Implementation Warmup Iterations Samples Total (ms) Median (ms) Per unit (ps) Spread
Naive 63 20 20 22.62 1.13 4414197 ±0.1%
NTTFast.Plan.fastMulImpl 255 60 20 16.15 0.27 1053108 ±0.0% !4

Interpolation on an NTT domain, KoalaBear, n = 2^6

  • Group key: univariate-interp-koalabear-l6
  • Representation: CPolynomial
  • Field / configuration: koalabear
  • Input shape: n = 2^6, nodes ωⁱ, two value vectors
  • Checksum iterations: 2
  • Total group time: 367.15 ms
  • Checksum: 17229810604017486706
Implementation Warmup Iterations Samples Total (ms) Median (ms) Per unit (ps) Spread
CLagrange.interpolatePow 7 20 20 171.1 8.54 133379625 ±0.3% !1
subproduct tree, naive 15 20 20 107.1 5.35 83554609 ±0.2%
subproduct tree, NTTFast 31 20 20 49.22 2.46 38397406 ±0.2% !1
NTT.interpolate 4095 1180 20 19.75 0.02 261561 ±0.0% !2
NTTFast.Plan.interpolate 16383 4620 20 19.98 4.32 us 67548 ±0.1% !1

Coset interpolation, KoalaBear, n = 2^12

  • Group key: univariate-interp-coset-koalabear-l12
  • Representation: CPolynomial
  • Field / configuration: koalabear
  • Input shape: n = 2^12, coset 3·⟨ω⟩, two value vectors
  • Checksum iterations: 2
  • Total group time: 41.93 ms
  • Checksum: 222190056691028618
Implementation Warmup Iterations Samples Total (ms) Median (ms) Per unit (ps) Spread
NTT.Coset.interpolate 63 20 20 28.6 1.43 348242 ±0.1%
NTTFast.CosetPlan.interpolate 255 40 20 13.33 0.33 81501 ±0.1%

Barycentric evaluation on an NTT domain, KoalaBear, n = 2^8

  • Group key: univariate-barycentric-koalabear-l8
  • Representation: BarycentricDomain
  • Field / configuration: koalabear
  • Input shape: n = 2^8, one off-node query, domain built per query
  • Checksum iterations: 2
  • Total group time: 228.11 ms
  • Checksum: 33673894954809713
Implementation Warmup Iterations Samples Total (ms) Median (ms) Spread
BarycentricDomain.mk' 7 20 20 207.99 10.42 ±0.1%
NTT.Domain.barycentric 2047 740 20 20.11 0.03 ±0.0% !3

Gao decoding, KoalaBear, n = 2^6

  • Group key: rs-gao-decode-koalabear-l6
  • Representation: Option CPolynomial
  • Field / configuration: koalabear
  • Input shape: n = 2^6, k = n/2, 16 errors
  • Checksum iterations: 2
  • Total group time: 382.14 ms
  • Checksum: 4523574932338764420
Implementation Warmup Iterations Samples Total (ms) Median (ms) Spread
decode (Lagrange interpolant) 7 20 20 247.86 12.4 ±0.3%
decodeNTT 15 20 20 67.24 3.36 ±0.6%
decodePlan 15 20 20 67.04 3.34 ±0.4% !1

Raw multiplication by a short factor, degree<64 (KoalaBear.Fast.Field)

  • Group key: univariate-raw-mul-short-koalabear-64
  • Field / configuration: KoalaBear.Fast.Field
  • Input shape: degree<64 dense times a factor of size 1 or 2, two inputs
  • Checksum iterations: 2
  • Total group time: 118.93 ms
  • Checksum: scalar: 17177499829494711529, linear: 12053004306157127635
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
mulRaw p (C c) 2047 800 20 19.71 24.12 ±0.4%
mulRaw (C c) p 65535 15840 20 20.04 1.26 ±0.0% !2
mulRaw p (X - C a) 2047 760 20 19.42 25.1 ±0.4%
mulRaw (X - C a) p 32767 8580 20 20.07 2.32 ±0.2% !2
p * (X - C a) 2047 760 20 19.86 26.09 ±1.8%
(X - C a) * p 32767 7620 20 19.83 2.6 ±0.3%

Raw multiplication by a short factor, degree<1024 (KoalaBear.Fast.Field)

  • Group key: univariate-raw-mul-short-koalabear-1024
  • Field / configuration: KoalaBear.Fast.Field
  • Input shape: degree<1024 dense times a factor of size 1 or 2, two inputs
  • Checksum iterations: 2
  • Total group time: 247.42 ms
  • Checksum: scalar: 8855434422786105504, linear: 8328623019188781912
Implementation Warmup Iterations Samples Total (ms) Median (ms) Spread
mulRaw p (C c) 31 20 20 61.51 3.05 ±0.8%
mulRaw (C c) p 4095 1440 20 19.96 0.01 ±0.0%
mulRaw p (X - C a) 31 20 20 65.08 3.27 ±0.7%
mulRaw (X - C a) p 2047 780 20 19.84 0.03 ±0.0% !3
p * (X - C a) 31 20 20 61.45 3.05 ±0.7%
(X - C a) * p 2047 680 20 19.57 0.03 ±0.0% !1

Balanced raw multiplication, degree<64 (BN254.ScalarField)

  • Group key: univariate-raw-mul-balanced-bn254-64
  • Representation: CPolynomial.Raw
  • Field / configuration: BN254.ScalarField
  • Input shape: two degree<64 dense factors, two inputs
  • Checksum iterations: 2
  • Total group time: 119.32 ms
  • Checksum: balanced: 5852069031288533127
Implementation Warmup Iterations Samples Total (ms) Median (ms) Spread
mulRaw p q 31 20 20 59.44 2.97 ±0.2%
mulRaw q p 31 20 20 59.88 2.99 ±0.1%

Balanced raw multiplication, degree<64 (Int)

  • Group key: univariate-raw-mul-balanced-int-64
  • Representation: CPolynomial.Raw
  • Field / configuration: Int
  • Input shape: two degree<64 dense factors, two inputs
  • Checksum iterations: 2
  • Total group time: 50.05 ms
  • Checksum: balanced: 6725379622955940132
Implementation Warmup Iterations Samples Total (ms) Median (ms) Spread
mulRaw p q 63 20 20 25 1.25 ±0.2% !1
mulRaw q p 63 20 20 25.05 1.25 ±0.2% !1

Multivariate dense evaluation (KoalaBear)

  • Group key: multivariate-dense-koalabear
  • Representation: CMvPolynomial
  • Input shape: 5 vars, 512 generated terms, exponent<16, dense coeffs, 32 points
  • Checksum iterations: 32
  • Total group time: 76.34 ms
  • Checksum: 12989022024804719439
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Direct evaluation 63 20 20 18.66 933.57 ±0.1% !1
Horner 127 40 20 18.49 460.02 ±0.2% !2
Direct evaluation (fast KoalaBear) 255 60 20 17.5 291.84 ±0.1%
Horner (fast KoalaBear) 511 160 20 21.7 124.84 ±0.7%

Multivariate sparse evaluation (KoalaBear)

  • Group key: multivariate-sparse-koalabear
  • Representation: CMvPolynomial
  • Input shape: 5 vars, 512 generated terms, exponent<16, one nonzero per 16 coeffs, 32 points
  • Checksum iterations: 32
  • Total group time: 78.63 ms
  • Checksum: 4702444785774290153
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Direct evaluation 1023 360 20 19.21 53.36 ±0.2%
Horner 2047 720 20 19.81 27.5 ±0.1% !1
Direct evaluation (fast KoalaBear) 4095 1140 20 19.66 17.23 ±0.2%
Horner (fast KoalaBear) 8191 2920 20 19.95 6.83 ±0.1%

Multilinear coefficient-form evaluation (KoalaBear)

  • Group key: multilinear-coeff-koalabear
  • Representation: CMlPolynomial
  • Input shape: 8 vars, 256 coefficients, 32 points
  • Checksum iterations: 32
  • Total group time: 75.86 ms
  • Checksum: 7574489561195638249
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Direct evaluation 255 80 20 18.45 230.05 ±0.1%
Horner 8191 1980 20 19.92 10.06 ±0.2%
Direct evaluation (fast KoalaBear) 511 100 20 17.57 175.74 ±0.2%
Horner (fast KoalaBear) 16383 3940 20 19.93 5.05 ±0.2%

Multilinear hypercube-form evaluation (KoalaBear)

  • Group key: multilinear-hypercube-koalabear
  • Representation: CMlPolynomialEval
  • Input shape: 8 vars, 256 hypercube values, 32 points
  • Checksum iterations: 32
  • Total group time: 76.24 ms
  • Checksum: 8527688633811526106
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Direct evaluation 255 80 20 18.54 231.17 ±0.2% !1
Multilinear extension 4095 1200 20 19.91 16.59 ±0.1%
Direct evaluation (fast KoalaBear) 511 100 20 17.66 175.63 ±0.3% !2
Multilinear extension (fast KoalaBear) 16383 3820 20 20.12 5.25 ±0.5% !1

Multilinear many-polynomial one-point evaluation (KoalaBear)

  • Group key: multilinear-many-mle-koalabear
  • Representation: Array CMlPolynomialEval
  • Input shape: 256 hypercube tables, 12 vars, 4096 values each, one shared point
  • Checksum iterations: 1
  • Total group time: 3.53 s
  • Checksum: 9316606161129943851
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Iterated direct evaluation 1 20 20 1.11 55.42 ±0.0%
Evaluation by layers 1 17 17 1.86 108.24 ±0.3%
Iterated direct evaluation (fast KoalaBear) 7 20 20 0.33 16.4 ±0.1%
Evaluation by layers (fast KoalaBear) 7 20 20 0.23 11.46 ±0.3% !2

Bivariate full evaluation (KoalaBear)

  • Group key: bivariate-full-koalabear
  • Representation: CBivariate
  • Input shape: xDegree<8, yDegree<64, one nonzero per 4 coeffs, 32 points
  • Checksum iterations: 32
  • Total group time: 119.95 ms
  • Checksum: 11087034476624545291
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Direct evaluation 2047 440 20 19.54 44.36 ±0.3%
Horner in Y, then in X 255 100 20 19.79 197.41 ±0.1% !2
Horner in X, then in Y 2047 760 20 19.56 25.73 ±0.0% !1
Direct evaluation (fast KoalaBear) 8191 3020 20 21.48 6.64 ±0.2% !1
Horner in Y, then in X (fast KoalaBear) 1023 300 20 19.63 65.4 ±0.1%
Horner in X, then in Y (fast KoalaBear) 65535 20460 20 19.94 0.97 ±0.0%

Bivariate division by Y - f (KoalaBear, yDeg<32)

  • Group key: bivariate-divlinear-koalabear-y32
  • Representation: CBivariate
  • Field / configuration: KoalaBear.Field
  • Input shape: xDegree<8, yDegree<32, divisor Y - f with deg f < 8
  • Checksum iterations: 64
  • Total group time: 1.97 s
  • Checksum: 12091257555579105626
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
divByLinearY 15 20 20 0.1 5.21 ±0.3%
divByMonic 1 7 7 1.87 266.82 ±0.1%

Guruswami-Sudan interpolation, small (KoalaBear)

  • Group key: guruswami-sudan-interp-small-koalabear
  • Representation: CBivariate
  • Input shape: n=64,k=16,m=2,D=75
  • Checksum iterations: 1
  • Total group time: 7.92 s
  • Checksum: 99
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Dense linear 1 2 2 1.4 700.89 ±0.2% (n=2)
Lee-O'Sullivan direct 3 20 20 0.39 19.36 ±0.1% !1
Lee-O'Sullivan subproduct 3 20 20 0.48 24.09 ±0.1% !1
Dense linear (fast KoalaBear) 1 20 20 1.45 72.32 ±0.1% !1
Lee-O'Sullivan direct (fast KoalaBear) 31 20 20 0.06 2.97 ±0.9%
Lee-O'Sullivan subproduct (fast KoalaBear) 15 20 20 0.09 4.55 ±0.1% !2
Approximant basis (PM-Basis) 1 7 7 1.88 268.36 ±0.3%
Hybrid (budgeted Lee-O'Sullivan with approximant fallback) 3 20 20 0.49 24.16 ±0.2% !1
Approximant basis (PM-Basis) (fast KoalaBear) 1 20 20 1.59 79.05 ±0.1% !2
Hybrid (budgeted Lee-O'Sullivan with approximant fallback) (fast KoalaBear) 15 20 20 0.09 4.54 ±0.1% !2

Guruswami-Sudan root finding (KoalaBear)

  • Group key: guruswami-sudan-root-koalabear
  • Representation: CBivariate
  • Input shape: k=32,Q=(Y-p)(Y-(p+7))
  • Checksum iterations: 1
  • Total group time: 3.73 s
  • Checksum: 969634314906216487
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Roth-Ruckenstein 1 20 20 1.06 51.69 ±0.3% !1
Roth-Ruckenstein, fast field roots 1 20 20 1.06 52.74 ±0.3% !2
Alekhnovich 3 20 20 0.43 21.48 ±0.1%
Alekhnovich, fast field roots 3 20 20 0.45 22.68 ±0.1%
Roth-Ruckenstein (fast KoalaBear) 7 20 20 0.25 12.44 ±0.2% !1
Roth-Ruckenstein, fast field roots (fast KoalaBear) 7 20 20 0.26 12.85 ±0.3%
Alekhnovich (fast KoalaBear) 15 20 20 0.11 5.32 ±0.2%
Alekhnovich, fast field roots (fast KoalaBear) 15 20 20 0.12 5.74 ±0.6% !1

Guruswami-Sudan full core, small (KoalaBear)

  • Group key: guruswami-sudan-core-small-koalabear
  • Representation: CBivariate
  • Input shape: n=64,k=16,m=2,D=75
  • Checksum iterations: 1
  • Total group time: 7.66 s
  • Checksum: 7498502499799494086
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Dense linear + RR roots 1 2 2 1.39 694.54 ±0.1% (n=2)
Dense linear + Alekhnovich roots 1 2 2 1.4 698.88 ±0.0% (n=2)
Lee-O'Sullivan direct + RR roots 7 20 20 0.3 14.92 ±0.2%
Lee-O'Sullivan direct + Alekhnovich roots 3 20 20 0.35 17.4 ±0.2% !2
Lee-O'Sullivan subproduct + RR roots 3 20 20 0.39 19.68 ±0.2%
Lee-O'Sullivan subproduct + Alekhnovich roots 3 20 20 0.44 22.18 ±0.1%
Dense linear + RR roots (fast KoalaBear) 1 20 20 1.48 73.85 ±0.1% !1
Dense linear + Alekhnovich roots (fast KoalaBear) 1 20 20 1.49 74.47 ±0.1% !1
Lee-O'Sullivan direct + RR roots (fast KoalaBear) 15 20 20 0.08 4 ±0.4% !1
Lee-O'Sullivan direct + Alekhnovich roots (fast KoalaBear) 15 20 20 0.1 4.86 ±0.3%
Lee-O'Sullivan subproduct + RR roots (fast KoalaBear) 15 20 20 0.11 5.62 ±0.2%
Lee-O'Sullivan subproduct + Alekhnovich roots (fast KoalaBear) 15 20 20 0.13 6.47 ±0.2% !1

Guruswami-Sudan filtered core, small (KoalaBear)

  • Group key: guruswami-sudan-filtered-core-small-koalabear
  • Representation: CBivariate
  • Input shape: n=64,k=16,m=2,D=75,r=0
  • Checksum iterations: 1
  • Total group time: 7.6 s
  • Checksum: 2488262235599587071
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Dense linear + RR roots + filter 1 2 2 1.37 682.65 ±0.1% (n=2)
Dense linear + Alekhnovich roots + filter 1 2 2 1.37 685.05 ±0.0% (n=2)
Lee-O'Sullivan direct + RR roots + filter 7 20 20 0.3 14.91 ±0.1% !1
Lee-O'Sullivan direct + Alekhnovich roots + filter 3 20 20 0.35 17.32 ±0.1%
Lee-O'Sullivan subproduct + RR roots + filter 3 20 20 0.39 19.56 ±0.2%
Lee-O'Sullivan subproduct + Alekhnovich roots + filter 3 20 20 0.44 22.15 ±0.3%
Dense linear + RR roots + filter (fast KoalaBear) 1 20 20 1.47 73.69 ±0.2%
Dense linear + Alekhnovich roots + filter (fast KoalaBear) 1 20 20 1.49 74.54 ±0.1% !1
Lee-O'Sullivan direct + RR roots + filter (fast KoalaBear) 15 20 20 0.08 3.99 ±0.5%
Lee-O'Sullivan direct + Alekhnovich roots + filter (fast KoalaBear) 15 20 20 0.1 4.87 ±0.2% !2
Lee-O'Sullivan subproduct + RR roots + filter (fast KoalaBear) 15 20 20 0.11 5.65 ±0.1% !1
Lee-O'Sullivan subproduct + Alekhnovich roots + filter (fast KoalaBear) 15 20 20 0.13 6.48 ±0.2% !2

Additive NTT BTF3 l=2 R_rate=2

  • Group key: additive-ntt-btf3-l2-r2
  • Field / configuration: ConcreteBTField 0 -> BTF3, l=2, R_rate=2
  • Input shape: 4 input coeffs, 16 output evals
  • Checksum iterations: 1
  • Total group time: 320.82 ms
  • Checksum: 9020180629482447344
Implementation Warmup Iterations Samples Total (ms) Median (ms) Spread
Reference implementation 7 20 20 297.23 14.84 ±0.0%
Fast implementation 63 20 20 23.59 1.17 ±0.3% !1

Additive NTT BTF3 l=4 R_rate=2

  • Group key: additive-ntt-btf3-l4-r2
  • Field / configuration: ConcreteBTField 0 -> BTF3, l=4, R_rate=2
  • Input shape: 16 input coeffs, 64 output evals
  • Checksum iterations: 1
  • Total group time: 1.49 s
  • Checksum: 2384991448222837060
Implementation Warmup Iterations Samples Total (s) Median (s) Spread
Reference implementation 1 1 1 1.35 1.35 n=1
Fast implementation 15 20 20 0.14 0.01 ±0.1%

Additive NTT BTF4 l=7 R_rate=2

  • Group key: additive-ntt-btf4-l7-r2
  • Representation: computableAdditiveNTTFast
  • Field / configuration: ConcreteBTField 0 -> BTF4, l=7, R_rate=2
  • Input shape: 128 input coeffs, 512 output evals
  • Checksum iterations: 1
  • Total group time: 1.82 s
  • Checksum: 4739150139317289007
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
Fast implementation 1 6 6 1.82 303.22 ±0.0%

Degree-4 extension multiplication (KoalaBear)

  • Group key: fields-extension-koalabear-ext4-mul
  • Representation: Extension.Ext
  • Field / configuration: KoalaBear.Ext4
  • Input shape: 64 random degree-4 elements, pairwise
  • Checksum iterations: 64
  • Total group time: 20.06 ms
  • Checksum: 14399668657116049225
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Naive 8191 2600 20 20.06 7.66 ±0.8%

Degree-4 extension inversion (KoalaBear)

  • Group key: fields-extension-koalabear-ext4-inv
  • Representation: Extension.Ext
  • Field / configuration: KoalaBear.Ext4
  • Input shape: 64 random degree-4 elements, pairwise
  • Checksum iterations: 64
  • Total group time: 24.98 ms
  • Checksum: 13348383282952825794
Implementation Warmup Iterations Samples Total (ms) Median (ms) Spread
inv (Fermat) 63 20 20 24.98 1.25 ±0.3%

Degree-4 extension multiplication (BabyBear)

  • Group key: fields-extension-babybear-ext4-mul
  • Representation: Extension.Ext
  • Field / configuration: BabyBear.Ext4
  • Input shape: 64 random degree-4 elements, pairwise
  • Checksum iterations: 64
  • Total group time: 20.06 ms
  • Checksum: 13972462817821445207
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
Naive 8191 2520 20 20.06 7.94 ±0.1% !1

Degree-4 extension inversion (BabyBear)

  • Group key: fields-extension-babybear-ext4-inv
  • Representation: Extension.Ext
  • Field / configuration: BabyBear.Ext4
  • Input shape: 64 random degree-4 elements, pairwise
  • Checksum iterations: 64
  • Total group time: 23.01 ms
  • Checksum: 12915459659462523593
Implementation Warmup Iterations Samples Total (ms) Median (ms) Spread
inv (Fermat) 63 20 20 23.01 1.15 ±0.1%

Scalar-field inversion (BN254)

  • Group key: fields-mont64x8-bn254-inv
  • Input shape: 256 random elements
  • Checksum iterations: 256
  • Total group time: 57.91 ms
  • Checksum: 14293953406368601621
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
inv (xgcd) (BN254.ScalarField) 1023 220 20 18.78 84.96 ±0.7% !1
inv (binary GCD) (BN254.Fast.ScalarField) 8191 1960 20 19.97 10.16 ±0.7%
inv (Fermat) (BN254.Fast.ScalarField) 1023 340 20 19.16 56.26 ±0.1% !2

Scalar-field inversion (BLS12-381)

  • Group key: fields-mont64x8-bls12-381-inv
  • Input shape: 256 random elements
  • Checksum iterations: 256
  • Total group time: 59.04 ms
  • Checksum: 3657240620154025436
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
inv (xgcd) (BLS12_381.ScalarField) 1023 220 20 19.57 88.7 ±0.4%
inv (binary GCD) (BLS12_381.Fast.ScalarField) 8191 1940 20 19.67 10.13 ±0.1%
inv (Fermat) (BLS12_381.Fast.ScalarField) 1023 340 20 19.8 58.08 ±0.1% !4

Scalar-field inversion (BLS12-377)

  • Group key: fields-mont64x8-bls12-377-inv
  • Input shape: 256 random elements
  • Checksum iterations: 256
  • Total group time: 59.2 ms
  • Checksum: 1215835870061878672
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
inv (xgcd) (BLS12_377.ScalarField) 1023 220 20 19.83 90.09 ±0.6%
inv (binary GCD) (BLS12_377.Fast.ScalarField) 8191 1980 20 19.66 9.92 ±0.1%
inv (Fermat) (BLS12_377.Fast.ScalarField) 1023 360 20 19.71 54.74 ±0.0%

Scalar-field inversion (secp256k1)

  • Group key: fields-mont64x8-secp256k1-scalar-inv
  • Input shape: 256 random elements
  • Checksum iterations: 256
  • Total group time: 58.35 ms
  • Checksum: 815995088702804024
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
inv (xgcd) (Secp256k1.ScalarField) 1023 220 20 18.96 86.18 ±0.4%
inv (binary GCD) (Secp256k1.Fast.ScalarField) 8191 2000 20 19.84 9.91 ±0.0% !1
inv (Fermat) (Secp256k1.Fast.ScalarField) 1023 320 20 19.56 61.05 ±0.0%

Base-field inversion (secp256k1)

  • Group key: fields-mont64x8-secp256k1-base-inv
  • Input shape: 256 random elements
  • Checksum iterations: 256
  • Total group time: 58.66 ms
  • Checksum: 2672592283322765590
Implementation Warmup Iterations Samples Total (ms) Median (us) Spread
inv (xgcd) (Secp256k1.BaseField) 1023 220 20 19.27 87.48 ±0.4%
inv (binary GCD) (Secp256k1.Fast.BaseField) 8191 1980 20 19.67 9.92 ±0.1% !1
inv (Fermat) (Secp256k1.Fast.BaseField) 1023 320 20 19.72 61.32 ±0.2% !1

Binary tower multiplication (GF(2^128))

  • Group key: fields-tower-bt128-mul
  • Field / configuration: GF(2^128)
  • Input shape: 64 random 128-bit elements, pairwise
  • Checksum iterations: 64
  • Total group time: 116.56 ms
  • Checksum: 8608794189506783967
Implementation Warmup Iterations Samples Total (ms) Median (ms) Spread
mul (ConcreteBTField) 15 20 20 96.57 4.81 ±0.0% !1
mul (FastBT128) 262143 65720 20 19.98 303 ns ±0.0%

Binary tower inversion (GF(2^128))

  • Group key: fields-tower-bt128-inv
  • Field / configuration: GF(2^128)
  • Input shape: 64 random 128-bit elements, pairwise
  • Checksum iterations: 64
  • Total group time: 183.33 ms
  • Checksum: 13003912736037943057
Implementation Warmup Iterations Samples Total (ms) Median (ms) Spread
inv (ConcreteBTField) 7 20 20 163.38 8.16 ±0.1%
inv (FastBT128) 262143 52440 20 19.94 379 ns ±0.1% !2

Binary tower coefficient evaluation (GF(2^128))

  • Group key: fields-tower-bt128-coeff-eval
  • Field / configuration: GF(2^128)
  • Input shape: 16 coefficients, 4 variables, 8 points; random 128-bit words
  • Checksum iterations: 8
  • Total group time: 1.84 s
  • Checksum: 266032619551138402
Implementation Warmup Iterations Samples Total (s) Median (ms) Spread
coefficient evaluation 1 5 5 1.82 364.92 ±0.0%
eager product accumulation 4095 1400 20 0.02 0.01 ±0.1%

Binary tower multiplication (GF(2^8)), table against recursive

  • Group key: fields-tower-bt8-mul
  • Representation: UInt64
  • Input shape: 64 seeds, 1280-operation chains
  • Checksum iterations: 64
  • Total group time: 79.69 ms
  • Checksum: latency: 13921908990847618300, throughput: 3057953892050006253
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
mul (latency) (GF(2^8) recursive) 2047 720 20 19.86 27.47 21462 ±0.0% !2
mul (latency) (GF(2^8) table) 8191 2980 20 19.9 6.67 5213 ±0.0% !1
mul (throughput) (GF(2^8) recursive) 4095 960 20 19.97 20.78 16233 ±0.0%
mul (throughput) (GF(2^8) table) 131071 27060 20 19.96 0.74 575 ±0.1%

Binary tower multiplication (GF(2^64)), table against recursive

  • Group key: fields-tower-bt64-mul
  • Representation: UInt64
  • Input shape: 64 seeds, 1280-operation chains
  • Checksum iterations: 64
  • Total group time: 61.33 ms
  • Checksum: latency: 8285340254721412103, throughput: 16507587829981949877
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
mul (latency) (GF(2^64) recursive) 127 20 20 10.81 542.52 423841 ±0.7%
mul (latency) (GF(2^64) table) 2047 560 20 19.98 35.52 27753 ±0.0% !2
mul (throughput) (GF(2^64) recursive) 127 20 20 11.05 551.82 431109 ±0.8% !1
mul (throughput) (GF(2^64) table) 2047 560 20 19.49 34.46 26919 ±0.0% !3

Binary tower inversion (GF(2^64)), table against recursive

  • Group key: fields-tower-bt64-inv-word
  • Representation: UInt64
  • Input shape: 64 seeds, 64-operation chains
  • Checksum iterations: 64
  • Total group time: 39.62 ms
  • Checksum: 1674174153629607468
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
inv (recursive) (GF(2^64) recursive) 2047 420 20 19.67 46.79 731159 ±0.0%
inv (table) (GF(2^64) table) 16383 4580 20 19.95 4.35 68009 ±0.1%

KoalaBear multiplication

  • Group key: fields-koalabear-mul
  • Input shape: 64 seeds, 1280-operation chains
  • Checksum iterations: 64
  • Total group time: 79.78 ms
  • Checksum: latency: 2361861519572402805, throughput: 6411130099385984238
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
mul (latency) 8191 1640 20 19.8 12.03 9401 ±0.5%
mul (latency) (fast KoalaBear) 16383 3860 20 19.95 5.17 4037 ±0.0% !1
mul (throughput) 8191 1680 20 20.01 11.86 9268 ±0.0% !3
mul (throughput) (fast KoalaBear) 32767 12700 20 20.03 1.57 1229 ±0.0% !2

KoalaBear addition

  • Group key: fields-koalabear-add
  • Input shape: 64 seeds, 1280-operation chains
  • Checksum iterations: 64
  • Total group time: 79.87 ms
  • Checksum: latency: 4492472002465610623, throughput: 5226033240933277116
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
add (latency) 8191 1740 20 19.88 11.42 8919 ±0.0% !2
add (latency) (fast KoalaBear) 65535 16700 20 19.96 1.19 933 ±0.0% !2
add (throughput) 8191 1640 20 20.06 12.17 9509 ±0.1%
add (throughput) (fast KoalaBear) 262143 54720 20 19.97 0.36 284 ±0.0% !1

KoalaBear inversion

  • Group key: fields-koalabear-inv
  • Input shape: 64 seeds, 64-operation chains
  • Checksum iterations: 64
  • Total group time: 39.82 ms
  • Checksum: 13309870041367228964
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
inv (ZMod.inv) 511 180 20 19.67 109.33 1708204 ±0.1% !1
inv (Fermat chain) (fast KoalaBear) 8191 2140 20 20.15 9.33 145819 ±0.0% !2

KoalaBear exponentiation

  • Group key: fields-koalabear-pow
  • Input shape: 64 seeds, 64-operation chains
  • Checksum iterations: 64
  • Total group time: 39.19 ms
  • Checksum: 14125835722032170532
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
pow (binary ladder) 511 180 20 19.35 107.47 1679277 ±0.0% !1
pow (binary ladder) (fast KoalaBear) 8191 2260 20 19.84 8.78 137128 ±0.0%

BabyBear multiplication

  • Group key: fields-babybear-mul
  • Input shape: 64 seeds, 1280-operation chains
  • Checksum iterations: 64
  • Total group time: 79.54 ms
  • Checksum: latency: 12306364085840251607, throughput: 18289692109709110097
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
mul (latency) 4095 1460 20 19.73 13.5 10547 ±0.0% !2
mul (latency) (fast BabyBear) 16383 3860 20 19.97 5.17 4035 ±0.0% !2
mul (throughput) 4095 1580 20 19.85 12.56 9808 ±0.0%
mul (throughput) (fast BabyBear) 32767 12700 20 19.99 1.57 1229 ±0.0% !2

Mersenne31 multiplication

  • Group key: fields-mersenne31-mul
  • Input shape: 64 seeds, 1280-operation chains
  • Checksum iterations: 64
  • Total group time: 79.72 ms
  • Checksum: latency: 15680827111443909147, throughput: 3783348257683227752
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
mul (latency) (Mersenne31.Field) 4095 1500 20 19.87 13.24 10341 ±0.0%
mul (latency) (Mersenne31.Fast.Field) 32767 7160 20 19.94 2.79 2176 ±0.0% !2
mul (throughput) (Mersenne31.Field) 8191 1660 20 19.85 11.95 9335 ±0.1%
mul (throughput) (Mersenne31.Fast.Field) 65535 22280 20 20.05 0.9 701 ±0.0% !2

Goldilocks multiplication

  • Group key: fields-goldilocks-mul
  • Input shape: 64 seeds, 1280-operation chains
  • Checksum iterations: 64
  • Total group time: 71.99 ms
  • Checksum: latency: 15592335880198651054, throughput: 3695224795086442034
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
mul (latency) (Goldilocks.Field) 255 60 20 16.91 282 220310 ±0.1%
mul (latency) (fast Goldilocks) 16383 4440 20 20.04 4.5 3518 ±0.1%
mul (throughput) (Goldilocks.Field) 255 60 20 15.09 251.87 196771 ±0.1% !4
mul (throughput) (fast Goldilocks) 65535 13420 20 19.95 1.49 1160 ±0.0% !1

Goldilocks inversion

  • Group key: fields-goldilocks-inv
  • Input shape: 64 seeds, 64-operation chains
  • Checksum iterations: 64
  • Total group time: 32.66 ms
  • Checksum: 16797144103061520050
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
inv (ZMod.inv) (Goldilocks.Field) 127 20 20 12.73 638.31 9973539 ±0.4%
inv (Fermat chain) (fast Goldilocks) 4095 1460 20 19.93 13.64 213124 ±0.0% !2

BN254 scalar multiplication

  • Group key: fields-bn254-mul
  • Input shape: 64 seeds, 320-operation chains
  • Checksum iterations: 64
  • Total group time: 77.84 ms
  • Checksum: latency: 10370687816916693840, throughput: 13074730707648729641
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
mul (latency) (BN254.ScalarField) 1023 260 20 18.73 72.05 225162 ±0.1% !1
mul (latency) (BN254.Fast.ScalarField) 4095 900 20 20.05 22.18 69315 ±0.6% !2
mul (throughput) (BN254.ScalarField) 1023 260 20 19.34 74.08 231490 ±0.2% !2
mul (throughput) (BN254.Fast.ScalarField) 4095 840 20 19.72 23.41 73153 ±0.0% !2

BN254 scalar addition

  • Group key: fields-bn254-add
  • Input shape: 64 seeds, 1280-operation chains
  • Checksum iterations: 64
  • Total group time: 74.08 ms
  • Checksum: latency: 1780155180742631468, throughput: 8058908430513663751
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
add (latency) (BN254.ScalarField) 255 80 20 16.19 201.84 157691 ±0.1% !5
add (latency) (BN254.Fast.ScalarField) 4095 940 20 19.91 21.06 16451 ±0.1%
add (throughput) (BN254.ScalarField) 255 80 20 18.52 231.25 180664 ±0.0% !3
add (throughput) (BN254.Fast.ScalarField) 2047 720 20 19.45 26.96 21064 ±0.1% !1

secp256k1 scalar-field multiplication

  • Group key: fields-secp256k1-scalar-mul
  • Input shape: 64 seeds, 320-operation chains
  • Checksum iterations: 64
  • Total group time: 77.2 ms
  • Checksum: latency: 4357555641235725023, throughput: 15795140193130748520
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
mul (latency) (Secp256k1.ScalarField) 1023 280 20 19.36 68.64 214497 ±0.4% !2
mul (latency) (Secp256k1.Fast.ScalarField) 4095 880 20 19.53 22.18 69304 ±0.1%
mul (throughput) (Secp256k1.ScalarField) 1023 260 20 18.72 71.97 224896 ±0.1%
mul (throughput) (Secp256k1.Fast.ScalarField) 4095 840 20 19.59 23.25 72663 ±0.3%

secp256k1 base-field multiplication

  • Group key: fields-secp256k1-base-mul
  • Input shape: 64 seeds, 320-operation chains
  • Checksum iterations: 64
  • Total group time: 77.33 ms
  • Checksum: latency: 14949290667516379241, throughput: 10034986259347234197
Implementation Warmup Iterations Samples Total (ms) Median (us) Per unit (ps) Spread
mul (latency) (Secp256k1.BaseField) 1023 280 20 19.31 68.98 215562 ±0.1% !1
mul (latency) (Secp256k1.Fast.BaseField) 4095 980 20 19.72 20.11 62845 ±0.0%
mul (throughput) (Secp256k1.BaseField) 1023 260 20 18.72 71.94 224797 ±0.2%
mul (throughput) (Secp256k1.Fast.BaseField) 4095 880 20 19.58 22.2 69368 ±0.1% !2

Add benchmark groups for Raw.mulRaw over KoalaBear's native-word
representation, BN254 as ZMod, and Int. These three coefficient
types have different arithmetic costs.

The groups univariate-raw-mul-short-koalabear-{8,64,1024},
univariate-raw-mul-short-bn254-1024 and
univariate-raw-mul-short-int-1024 multiply a dense factor by C c and
by X - C a. The short factor is on the right in one row and on the
left in the other. Two rows multiply by X - C a through the
CPolynomial instance. The groups univariate-raw-mul-balanced-bn254-64
and univariate-raw-mul-balanced-int-64 multiply two dense factors of
the same size, in both orders.

No group measured a short right factor before. In that shape mulRaw
does a number of additions that is quadratic in the long factor
(#419). The coefficient types are commutative, so the two orders of
a product give the same array, and each pair of rows shares a digest
class. The sink reads four entries of the result. Three of the
groups join the curated CI set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The module docstring and bench/README.md now name the sizes and the
coefficient types of each raw multiplication group. KoalaBear has the
sizes 8, 64 and 1024. BN254 and Int have size 1024 in the short groups
and size 64 in the balanced groups. The module docstring also says
that the Int inputs fit Lean's unboxed small integers, but their
products can allocate. It also says that the timed pass sinks four
entries of the result, and that the timed region includes their
checksum conversions.

The cpoly-linear rows now share the digest class of the linear rows.
The agreement check then compares the CPolynomial product with the raw
product. The two products agree because no seeded dense factor ends in
zero, so the trim removes nothing.

The generator field of RawMulCarrier is now generate. Its old name,
coeffs, was also the name of the size argument of the group runners.
The docstrings say "orders" of a product in place of "orientations".

univariate-raw-mul-balanced-int-64 joins bench/ci-groups.txt, so the
correctness gate also runs the Int coefficient type. A comment in that
file gives the reason for each raw multiplication group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexanderlhicks

Copy link
Copy Markdown
Collaborator Author

A fix-up commit, 347f09b, corrects the benchmark notes and makes the agreement check compare the CPolynomial path with the raw path. It changes only files under bench/.

  • The module docstring and bench/README.md name the sizes and the coefficient types of each group. They also state the sink and the Int range. Details are below.
  • The cpoly-linear-* rows now share the digest class of the linear-* rows. The agreement check then compares the CPolynomial product with the raw product. --validate-only passes with this change. The compare key of these rows changes from · cpoly-linear to · linear, so an A/B run against a binary built at 27841e8 reports them as missing.
  • The generator field of RawMulCarrier is now generate. The old name, coeffs, was also the size argument of the group runners.
  • univariate-raw-mul-balanced-int-64 joins bench/ci-groups.txt. A comment in that file gives the reason for each raw multiplication group.

Validation at 347f09b, run locally:

  • lake build --wfail passes.
  • lake build CompPolyBenchLib CompPolyBench passes with no warnings.
  • lake exe CompPolyBench --validate-only and lake exe CompPolyBench --medium --validate-only pass (500 records in 135 groups).
  • The CI command below passes (292 records in 73 groups).
  • scripts/check-docs-integrity.py passes.

The commit changes no benchmark body and no Lean code under CompPoly/, so the timings of #422 still apply.

Corrections to the description

Validation command. The description gives --groups <bench/ci-groups.txt>, which is not a valid shell command. CI runs this command, from .github/workflows/lean_action_ci.yml:

groups="$(sed -e 's/#.*//' -e 's/[[:space:]]//g' bench/ci-groups.txt \
  | grep -v '^$' | paste -sd, -)"
lake exe CompPolyBench --medium --validate-only --groups "$groups"

Where that run happened. The description says that the curated-group run (290 records in 72 groups) ran on 27841e8. It ran on 04fff5a, the head before the rebase onto #420. The rebase changed nothing under bench/. The command above now passes at 347f09b, with 292 records in 73 groups because of the added Int group.

Benchmarks on the CI runner. The description says that they were not run. The benchmark workflow ran on this PR and posted its report: #421 (comment). Its timings are advisory.

Why these CI groups. The description says that the new sizes match the two crossover sizes in bench/ci-groups.txt. That is not correct. The crossover groups in that file have sizes 64 and 256, and the new short-factor groups have sizes 64 and 1024. The reasons are these:

  • 64 is the middle of the short-factor sweep (8, 64, 1024). The policy at the top of bench/ci-groups.txt keeps the middle of a sweep.
  • 1024 is the largest size of the sweep. At this size, the old fold with a short right factor was 116 to 265 times slower than with the factor on the left. These ratios come from the baseline binary of the measurement in perf(univariate): compute each entry of a raw product as one sum #422. A quadratic regression is therefore easy to see in the timing report at this size.
  • univariate-raw-mul-balanced-bn254-64 and univariate-raw-mul-balanced-int-64 run the ZMod and Int coefficient types in the correctness gate.

Workloads. KoalaBear has the sizes 8, 64 and 1024. BN254 and Int have size 1024 in the short groups and size 64 in the balanced groups. The Int inputs are in [-2^20, 2^20] and fit Lean's unboxed small integers, but their products can allocate big integers. The timed pass sinks four entries of the result, and the timed region includes the checksum conversions of these four entries.

Specialization. I checked the generated C of 347f09b. The short-group runner has one specialization for each of its three coefficient types. The balanced-group runner has one for each of its two types. In the KoalaBear specialization, the loops of addRaw and smul compute on uint32_t values. The array stores each result with lean_box_uint32, which does not allocate on a 64-bit target.

@alexanderlhicks
alexanderlhicks merged commit 728227c into main Nov 19, 2026
8 checks passed
@alexanderlhicks
alexanderlhicks deleted the bench/raw-mul-short branch November 20, 2026 02:38
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