Skip to content

aiur: verify u32 addition from hinted sum - #556

Merged
gabriel-barrett merged 4 commits into
mainfrom
perf/u32-add-hint
Aug 13, 2026
Merged

aiur: verify u32 addition from hinted sum#556
gabriel-barrett merged 4 commits into
mainfrom
perf/u32-add-hint

Conversation

@gabriel-barrett

@gabriel-barrett gabriel-barrett commented Aug 12, 2026

Copy link
Copy Markdown
Member

u32_add optimization

Instead of defining u32 addition as a bunch of u8 addition, we can define it through the native addition:
u32_add(x, y), for x: u32, y: u32 is a z: u32 such that x + y - z is either 0 or 2^32, that is,
such that (x + y - z)/2^32 is a boolean. We also extend that to addition on 3 numbers:
u32_add3(x, y, z) is a w: u32 such that (x + y + z - w)/2^32 is either 0, 1, or 2

Codegen regenerated; all 71 kernel FFT pins and the shard-pipeline
aggregate re-measured: every pin drops (median -3.7%, up to -7.9% on
the string/byte-heavy checks), shard aggregate -9.9%. aiur (cargo +
prove suite incl. parity), ixvm, multi-stark and recursive-verifier
suites pass; fmt, clippy, deny clean.
@gabriel-barrett

This comment was marked as outdated.

@argument-ci-bot

This comment was marked as outdated.

Codegen regenerated; all 71 kernel FFT pins and the shard-pipeline
aggregate re-measured: every pin drops again (median -1.5%, up to
-3.4% on the string/byte-heavy checks), shard aggregate -4.3% on top
of the hinted-adder commit (-13.8% combined). aiur (cargo + prove
suite incl. parity), ixvm, multi-stark and recursive-verifier suites
pass; fmt, clippy, deny clean.
@gabriel-barrett

This comment was marked as outdated.

@argument-ci-bot

This comment was marked as outdated.

@gabriel-barrett

Copy link
Copy Markdown
Member Author

!benchmark aiur-recursive fresh

@argument-ci-bot

argument-ci-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

!benchmark — main vs 52f9ff7

backends: aiur-recursive · envs: InitStd · set: primary · shard: 0 · baseline: fresh (base-SHA run, bencher bypassed)

aiur-recursive · InitStd — main from: base run @ 5392d37 (fresh — bencher bypassed)

1 constant · 1 with regressions · 1 with improvements (|Δ| > 3.0% on any metric).

constant recursive-prove-time (main) recursive-prove-time (PR) Δ% recursive-peak-ram (main) recursive-peak-ram (PR) Δ% recursive-proof-size (main) recursive-proof-size (PR) Δ% recursive-verify-time (main) recursive-verify-time (PR) Δ% recursive-execute-time (main) recursive-execute-time (PR) Δ% recursive-fft-cost (main) recursive-fft-cost (PR) Δ% prove-time (main) prove-time (PR) Δ% proof-size (main) proof-size (PR) Δ% verify-time (main) verify-time (PR) Δ% peak-ram (main) peak-ram (PR) Δ%
Nat.add_comm 26.994 s 21.577 s -20.1% (1.25× faster) 🟢 81.01 GiB 58.98 GiB -27.2% (1.37× smaller) 🟢 5.48 MiB 5.30 MiB -3.3% 🟢 33.2 ms 37.0 ms +11.3% (1.11× slower) ⚠️ 4.203 s 3.741 s -11.0% (1.12× faster) 🟢 148.08B 113.85B -23.1% (1.30× fewer) 🟢 1.012 s 1.054 s +4.2% ⚠️ 9.11 MiB 8.93 MiB -2.0% 57.4 ms 53.0 ms -7.7% (1.08× faster) 🟢 4.09 GiB 4.11 GiB +0.5%

Workflow logs

Plus the trailing integration: BytecodeEval's new hint arms index the
value map via getD (no Inhabited G instance is exposed for `!`), the
u32_sum helpers and the codegen template emit clippy-clean casts
(u128::from / masked try_from), codegen regenerated, and all 71 kernel
FFT pins + the shard aggregate re-measured (median -0.4%, shard -1.3%
on top of the fused adder). aiur (cargo + prove suite incl. parity),
ixvm, multi-stark and recursive-verifier suites pass; fmt, clippy,
deny clean.
@gabriel-barrett

Copy link
Copy Markdown
Member Author

!benchmark aiur fresh

@argument-ci-bot

argument-ci-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

!benchmark — main vs 7cff837

backends: aiur=prove · envs: InitStd · set: primary · shard: 0 · baseline: fresh (base-SHA run, bencher bypassed)

aiur · InitStd · prove — main from: base run @ 5392d37 (fresh — bencher bypassed)

13 constants · 4 with regressions · 13 with improvements (|Δ| > 3.0% on any metric).

comparison table (13 constants)
constant prove-time (main) prove-time (PR) Δ% throughput (const/s) (main) throughput (const/s) (PR) Δ% peak-ram (main) peak-ram (PR) Δ% execute-time (main) execute-time (PR) Δ% verify-time (main) verify-time (PR) Δ% proof-size (main) proof-size (PR) Δ% fft-cost (main) fft-cost (PR) Δ%
Array.extract_append 39.061 s 38.016 s -2.7% 39.480 40.560 +2.7% 77.01 GiB 73.74 GiB -4.3% 🟢 9.909 s 9.661 s -2.5% 138.9 ms 130.7 ms -5.9% (1.06× faster) 🟢 21.93 MiB 21.59 MiB -1.6% 141.66B 136.02B -4.0% 🟢
ByteArray.utf8DecodeChar?_utf8EncodeChar_append 39.708 s 37.083 s -6.6% (1.07× faster) 🟢 67.770 72.570 +7.1% (1.07× faster) 🟢 79.86 GiB 73.12 GiB -8.4% (1.09× smaller) 🟢 9.778 s 9.594 s -1.9% 139.5 ms 133.0 ms -4.6% 🟢 22.03 MiB 21.69 MiB -1.6% 151.82B 138.80B -8.6% (1.09× fewer) 🟢
Char.ofOrdinal_le_of_le 30.010 s 28.793 s -4.1% 🟢 88.170 91.900 +4.2% 🟢 61.91 GiB 58.56 GiB -5.4% (1.06× smaller) 🟢 6.711 s 6.636 s -1.1% 135.9 ms 132.5 ms -2.5% 21.98 MiB 21.64 MiB -1.6% 108.99B 99.42B -8.8% (1.10× fewer) 🟢
Vector.extract_append._proof_2 21.876 s 21.111 s -3.5% 🟢 59.520 61.670 +3.6% 🟢 41.37 GiB 39.66 GiB -4.1% 🟢 5.331 s 5.330 s -0.0% 133.4 ms 136.5 ms +2.3% 21.64 MiB 21.30 MiB -1.6% 81.14B 77.08B -5.0% (1.05× fewer) 🟢
_private.Init.Data.Range.Polymorphic.SInt.0.Int64.instRxcHasSize_eq 18.413 s 17.092 s -7.2% (1.08× faster) 🟢 98.410 106.010 +7.7% (1.08× faster) 🟢 38.17 GiB 34.79 GiB -8.9% (1.10× smaller) 🟢 3.636 s 3.522 s -3.1% 🟢 135.3 ms 141.9 ms +4.9% ⚠️ 21.82 MiB 21.47 MiB -1.6% 60.56B 54.85B -9.4% (1.10× fewer) 🟢
String.split 17.416 s 16.172 s -7.1% (1.08× faster) 🟢 101.340 109.140 +7.7% (1.08× faster) 🟢 36.10 GiB 32.70 GiB -9.4% (1.10× smaller) 🟢 3.384 s 3.307 s -2.3% 133.8 ms 131.7 ms -1.6% 22.02 MiB 21.68 MiB -1.6% 55.29B 50.25B -9.1% (1.10× fewer) 🟢
List.mergeSort 12.612 s 11.817 s -6.3% (1.07× faster) 🟢 114.810 122.530 +6.7% (1.07× faster) 🟢 25.42 GiB 23.73 GiB -6.6% (1.07× smaller) 🟢 2.475 s 2.356 s -4.8% (1.05× faster) 🟢 133.5 ms 134.4 ms +0.7% 21.87 MiB 21.53 MiB -1.6% 40.03B 36.10B -9.8% (1.11× fewer) 🟢
Vector.append 4.123 s 3.951 s -4.2% 🟢 117.630 122.740 +4.3% 🟢 7.48 GiB 6.67 GiB -10.8% (1.12× smaller) 🟢 689.6 ms 668.1 ms -3.1% 🟢 126.0 ms 135.1 ms +7.3% (1.07× slower) ⚠️ 20.47 MiB 20.13 MiB -1.7% 8.83B 8.02B -9.2% (1.10× fewer) 🟢
Nat.gcd_comm 3.299 s 3.200 s -3.0% 118.230 121.880 +3.1% 🟢 5.81 GiB 5.75 GiB -1.1% 531.7 ms 531.4 ms -0.0% 123.2 ms 124.4 ms +1.0% 20.24 MiB 19.90 MiB -1.7% 5.93B 5.25B -11.5% (1.13× fewer) 🟢
String.append 2.409 s 2.390 s -0.8% 126.190 127.180 +0.8% 5.84 GiB 4.64 GiB -20.6% (1.26× smaller) 🟢 418.0 ms 399.0 ms -4.5% 🟢 117.2 ms 123.1 ms +5.1% (1.05× slower) ⚠️ 19.51 MiB 19.17 MiB -1.8% 3.27B 2.90B -11.1% (1.13× fewer) 🟢
Int.gcd 2.014 s 2.010 s -0.2% 103.280 103.480 +0.2% 4.53 GiB 4.53 GiB +0.0% 349.8 ms 349.7 ms -0.0% 125.3 ms 117.4 ms -6.3% (1.07× faster) 🟢 19.07 MiB 18.73 MiB -1.8% 2.10B 1.87B -10.9% (1.12× fewer) 🟢
Nat.sub_le_of_le_add 1.842 s 1.818 s -1.3% 92.300 93.530 +1.3% 4.65 GiB 4.61 GiB -0.7% 341.9 ms 343.2 ms +0.4% 114.3 ms 113.7 ms -0.5% 19.42 MiB 19.08 MiB -1.8% 1.79B 1.60B -10.5% (1.12× fewer) 🟢
Nat.add_comm 1.055 s 1.044 s -1.0% 39.820 40.230 +1.0% 3.61 GiB 3.84 GiB +6.3% (1.06× larger) ⚠️ 253.3 ms 248.5 ms -1.9% 105.9 ms 106.0 ms +0.1% 17.60 MiB 17.25 MiB -1.9% 292.23M 271.37M -7.1% (1.08× fewer) 🟢

Workflow logs

@gabriel-barrett
gabriel-barrett marked this pull request as ready for review August 13, 2026 15:35
@gabriel-barrett
gabriel-barrett merged commit 613feac into main Aug 13, 2026
11 checks passed
@gabriel-barrett
gabriel-barrett deleted the perf/u32-add-hint branch August 13, 2026 15:35
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.

2 participants