Skip to content

Recursive verifier: inline trivial functions - #553

Merged
gabriel-barrett merged 4 commits into
mainfrom
multistark-inline-gl-wrappers
Aug 12, 2026
Merged

Recursive verifier: inline trivial functions#553
gabriel-barrett merged 4 commits into
mainfrom
multistark-inline-gl-wrappers

Conversation

@gabriel-barrett

Copy link
Copy Markdown
Member

No description provided.

@gabriel-barrett

Copy link
Copy Markdown
Member Author

!benchmark aiur-recursive fresh

Aiur compiles every non-inlined function to its own circuit, so the
single-op base-field wrappers (gl_add, gl_sub, gl_mul, gl_sq) each cost
a circuit for what is one native op. Drop them and call the operation
directly at the call sites; delete the unused ones outright (gl_neg,
gl_is_zero, gl_eq) along with the constant fns (gl_zero/one/two/seven),
whose uses are literal constants now. Regenerated aiur_multi_stark.rs
(225 -> 214 circuits).
Drop gl_div (rewritten as a * @gl_inverse(b) at its single call site) and
switch every call of gl_inverse, gl_val, gl_lt_p and gl_to_bytes to the
inline form (@fn), so their bodies splice into the callers and they stop
being reachable through constrained call edges: committed circuits go
204 -> 201. gl_val keeps a circuit only because bytecode dedup merges it
with limb_to_field, which is still called normally. Regenerated
aiur_multi_stark.rs.
The previous commit's rewrite missed the two nested calls in
gl_to_bytes(gl_val(x)) (canon_lanes, rows_pop), which alone kept the
gl_val circuit constrained. With those fixed, limb_to_field still pins
the circuit (bytecode dedup merges the two), so inline-call its sites
too. Measured on bench-recursive-verifier --execute-only (factorial(5),
q=100, RAYON_NUM_THREADS=1), inlining limb_to_field on top of the
nested-call fix is a strict win: the gl_val circuit disappears
(212 -> 211 circuits), and its callers get NARROWER, not wider -- a
call's channel columns cost more than the spliced 8-term byte fold
(lanes_to_gl 31 -> 28, digest_eq 99 -> 83). Total committed width
11454 -> 11421, total FFT cost 7.9829e9 -> 7.9800e9 (-0.035%).
Regenerated aiur_multi_stark.rs.
Switch every call of eg_add/eg_sub/eg_neg/eg_mul/eg_inverse/eg_div/eg_eq
to the inline form (@fn), including eg_div's internal eg_mul/eg_inverse.
All seven circuits disappear (constrained fns 201 -> 193; the extra one
is a dedup-class merge among rewritten callers), and the hot callers get
narrower, same as with limb_to_field: ro_fold 56 -> 48 at height 13502,
rollin 39 -> 35, from_ext_basis 18 -> 10; only trivial-height circuits
widen (trace_selectors 38 -> 52 at height 3). bench-recursive-verifier
--execute-only (factorial(5), q=100, RAYON_NUM_THREADS=1): circuits
211 -> 204, total width 11421 -> 11239, total FFT cost
7.9800e9 -> 7.9407e9 (-0.49%). Regenerated aiur_multi_stark.rs.
@gabriel-barrett
gabriel-barrett force-pushed the multistark-inline-gl-wrappers branch from 761a6a6 to 43c89ef Compare August 12, 2026 15:40
@argument-ci-bot

argument-ci-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

!benchmark — main vs 761a6a6

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

aiur-recursive · InitStd — main from: base run @ 6c34232 (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 29.234 s 26.376 s -9.8% (1.11× faster) 🟢 84.87 GiB 81.19 GiB -4.3% 🟢 5.60 MiB 5.48 MiB -2.1% 35.4 ms 33.0 ms -6.8% (1.07× faster) 🟢 5.260 s 4.132 s -21.4% (1.27× faster) 🟢 157.17B 148.08B -5.8% (1.06× fewer) 🟢 1.057 s 1.045 s -1.1% 9.11 MiB 9.11 MiB +0.0% 57.4 ms 57.0 ms -0.8% 3.45 GiB 4.42 GiB +28.0% (1.28× larger) ⚠️

Workflow logs

@gabriel-barrett

Copy link
Copy Markdown
Member Author

!benchmark aiur fresh

@argument-ci-bot

argument-ci-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

!benchmark — main vs 43c89ef

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

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

13 constants · 1 with regressions · 5 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) Δ%
ByteArray.utf8DecodeChar?_utf8EncodeChar_append 39.179 s 39.363 s +0.5% 68.690 68.360 -0.5% 79.87 GiB 79.91 GiB +0.0% 9.825 s 9.868 s +0.4% 144.5 ms 138.2 ms -4.4% 🟢 22.03 MiB 22.03 MiB +0.0% 151.82B 151.82B +0.0%
Array.extract_append 39.182 s 38.043 s -2.9% 39.350 40.530 +3.0% 77.06 GiB 77.01 GiB -0.1% 9.658 s 9.573 s -0.9% 145.5 ms 143.8 ms -1.1% 21.93 MiB 21.93 MiB +0.0% 141.66B 141.66B +0.0%
Char.ofOrdinal_le_of_le 29.721 s 29.397 s -1.1% 89.030 90.010 +1.1% 61.93 GiB 61.93 GiB -0.0% 6.840 s 6.599 s -3.5% 🟢 139.5 ms 131.6 ms -5.7% (1.06× faster) 🟢 21.98 MiB 21.98 MiB +0.0% 108.99B 108.99B +0.0%
Vector.extract_append._proof_2 21.618 s 21.648 s +0.1% 60.230 60.150 -0.1% 41.40 GiB 41.38 GiB -0.0% 5.289 s 5.415 s +2.4% 131.4 ms 134.7 ms +2.5% 21.64 MiB 21.64 MiB +0.0% 81.14B 81.14B +0.0%
_private.Init.Data.Range.Polymorphic.SInt.0.Int64.instRxcHasSize_eq 18.092 s 18.188 s +0.5% 100.150 99.620 -0.5% 38.16 GiB 38.21 GiB +0.1% 3.642 s 3.662 s +0.5% 135.6 ms 140.5 ms +3.6% ⚠️ 21.82 MiB 21.82 MiB +0.0% 60.56B 60.56B +0.0%
String.split 17.445 s 16.959 s -2.8% 101.180 104.070 +2.9% 36.08 GiB 36.10 GiB +0.1% 3.416 s 3.343 s -2.1% 135.4 ms 131.7 ms -2.8% 22.02 MiB 22.02 MiB +0.0% 55.29B 55.29B +0.0%
List.mergeSort 12.141 s 12.329 s +1.5% 119.260 117.450 -1.5% 25.42 GiB 25.42 GiB -0.0% 2.378 s 2.421 s +1.8% 132.3 ms 133.9 ms +1.2% 21.87 MiB 21.87 MiB +0.0% 40.03B 40.03B +0.0%
Vector.append 4.000 s 4.010 s +0.3% 121.240 120.940 -0.2% 7.29 GiB 7.30 GiB +0.1% 680.6 ms 670.0 ms -1.6% 124.5 ms 123.6 ms -0.7% 20.47 MiB 20.47 MiB +0.0% 8.83B 8.83B +0.0%
Nat.gcd_comm 3.254 s 3.323 s +2.1% 119.860 117.350 -2.1% 6.17 GiB 5.89 GiB -4.6% 🟢 525.8 ms 535.3 ms +1.8% 122.1 ms 119.2 ms -2.4% 20.24 MiB 20.24 MiB +0.0% 5.93B 5.93B +0.0%
String.append 2.434 s 2.410 s -1.0% 124.900 126.140 +1.0% 4.61 GiB 4.64 GiB +0.6% 404.7 ms 401.2 ms -0.9% 118.2 ms 117.4 ms -0.7% 19.51 MiB 19.51 MiB +0.0% 3.27B 3.27B +0.0%
Int.gcd 1.977 s 2.004 s +1.4% 105.220 103.770 -1.4% 5.46 GiB 4.55 GiB -16.7% (1.20× smaller) 🟢 344.3 ms 347.1 ms +0.8% 125.5 ms 124.3 ms -1.0% 19.07 MiB 19.07 MiB +0.0% 2.10B 2.10B +0.0%
Nat.sub_le_of_le_add 1.825 s 1.818 s -0.4% 93.130 93.510 +0.4% 5.45 GiB 5.43 GiB -0.4% 337.6 ms 338.0 ms +0.1% 114.3 ms 113.2 ms -0.9% 19.42 MiB 19.42 MiB +0.0% 1.79B 1.79B +0.0%
Nat.add_comm 1.033 s 1.050 s +1.7% 40.670 39.990 -1.7% 3.92 GiB 3.59 GiB -8.4% (1.09× smaller) 🟢 247.9 ms 250.9 ms +1.2% 107.2 ms 105.5 ms -1.6% 17.60 MiB 17.60 MiB +0.0% 292.23M 292.23M +0.0%

Workflow logs

@gabriel-barrett
gabriel-barrett merged commit 5392d37 into main Aug 12, 2026
11 checks passed
@gabriel-barrett
gabriel-barrett deleted the multistark-inline-gl-wrappers branch August 12, 2026 16:49
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