Skip to content

perf(akita): share prepared A tiles across trace blocks - #53

Open
RadNi wants to merge 44 commits into
amir/akita-batchfrom
codex/akita-shared-a-commit
Open

RadNi wants to merge 44 commits into
amir/akita-batchfrom
codex/akita-shared-a-commit

Conversation

@RadNi

@RadNi RadNi commented Oct 3, 2026 •

Copy link
Copy Markdown

Summary

Trace one-hot commitment repeatedly prepares the same setup-matrix A entries across trace blocks. Share A preparation within bounded block groups and use canonical 16-bit paired digit tables for K16 accumulation. On Apple M4 Max, the latest SHA2-chain K16/D512 trace-2^28 comparison reduced commitment time from 40.18 s to 35.13 s (12.6%) and total proving time from 163.08 s to 156.48 s (4.1%). Opening time increased from 17.98 s to 18.45 s (2.6%).

These current measurements use one fresh baseline run and the best unsampled verified candidate run; they are not a repeated-run statistical estimate. The requested 30% commitment reduction has not been demonstrated. The older multi-scale sweep below measures an earlier snapshot with different profile selection.

Changes

  • Prepare canonical positive/negative negacyclic A windows once per position, part, and rank in bounded tiles shared across trace blocks.
  • Use canonical 16-bit paired digit tables for K16 accumulation; retain the general digit-window path for other supported geometries.
  • Derive a column's shifts once, reuse them across ranks, and retain wide/reduced partials and the accumulation budget across tile boundaries. Flush before exceeding the existing wide-accumulation limit.
  • Preserve output ordering, committed-zero handling, K>=D and flat fallbacks, schedules, and cryptographic parameters.
  • Cover shared tiles, flush boundaries, multiple ranks, worker-count independence, one trace visit per row, committed zeros, and boundary negacyclic shifts against materialized/algebraic ground truth.

Current K16 measurements

SHA2-chain, trace length 2^28 (268,435,456 rows), K16/D512, 57 columns, 128 trace blocks, n_a=1, and 65,536 A positions per block. Apple M4 Max, 64 GiB RAM, release builds with identical akita,profiling features and schedules, 16 prover workers.

Baseline: target eca990e4f6d795df946190d0f18ce3d5573b37a0, freshly rerun with the saved baseline binary. Optimized: selected candidate-u16 binary; final source at 167e24f95af88712f11a7d573cf4a1ae1ca66467 differs from the benchmarked patch only by a private-method/test rename and discarding a test-only return value for linting.

Metric Fresh baseline Optimized Change
Akita commitment 40.178 s 35.131 s 12.6% reduction
Total proving 163.082 s 156.476 s 4.1% reduction
Akita opening 17.983 s 18.448 s 2.6% increase

Both runs passed parallel and single-worker verification. Serialized proof size was unchanged at 98,070 bytes. Commitment and opening use the same span definitions as the historical table below; total proving excludes guest tracing and PCS setup.

Measurement caveat: one fresh baseline run is compared with the best unsampled verified run of the selected candidate. This does not establish a repeated-run average or a 30% commitment reduction. The earlier 46.95 s baseline would imply 25.2%, but the fresh measured baseline gives 12.6%, which is the comparison reported here.

Baseline binary SHA-256: 00c8410237375843fb687074687bbe764ad92d4f74686fdd63c7c1ecac6eeaa0. Candidate binary SHA-256: b27ed2dab2c450306eaf5c8d6f24e8b4dc5fda457b4b923f4958b8ba868d593f. Raw samples and consolidated results are retained locally in benchmark-runs/akita-k16-block-groups-20261004/.

Historical measurements (earlier snapshot)

Benchmark provenance: the tables below measure the original patch on amir/akita-batch at 2f48e7fad, which used four-coefficient tiles on ARM. Before publishing, this single optimization commit was transplanted onto the current target eca990e4f6d795df946190d0f18ce3d5573b37a0, preserving that target's eight-coefficient ARM tile and expanded K16 schedules. The rebased PR head is validated separately below; these historical benchmark numbers are not measurements of the rebased head. Its timing and profile selection need a fresh benchmark before extrapolating these gains to the latest target.

Baseline: amir/akita-batch at 2f48e7fad7b7f4d911bd73c2f23234ce185747f7. Akita dependency: 83574331d4e51f8cce1d8689d05592fa4ef4c138.

Apple M4 Max, 64 GiB RAM, release builds with identical akita,profiling features and schedules, 16 prover workers. Sequential paired runs alternated version order each repetition. Four runs per version and scale (56 proofs total); discard minimum/maximum independently for every metric and average the middle two. All 56 proofs verified with both 16-worker and single-worker verification (112 successful verification checks).

Arrows mean baseline → optimized. Commitment is akita_main_commit_with_precommitted, opening is akita_main_batched_prove, and prove time is the full root prover span, excluding guest tracing and PCS setup. Times are seconds; verification times are milliseconds. Proof bytes are the complete serialized Jolt proof size, unchanged between versions at every scale.

log₂ trace Akita commit, s Akita opening, s Prove, s Prove reduction
28 132.837 → 80.735 17.219 → 17.093 234.793 → 182.048 +22.5%
27 29.478 → 29.277 8.873 → 9.501 75.882 → 76.394 -0.7%
26 35.509 → 22.535 6.076 → 5.977 59.927 → 47.095 +21.4%
25 17.332 → 11.082 3.048 → 2.998 29.945 → 23.517 +21.5%
24 3.421 → 3.919 1.671 → 1.675 11.549 → 12.069 -4.5%
23 1.634 → 1.876 1.027 → 1.016 6.072 → 6.344 -4.5%
22 0.849 → 0.945 0.658 → 0.664 3.366 → 3.477 -3.3%

Verification time (milliseconds). Parallel verification uses 16 workers; single verification uses one.

log₂ trace Parallel verify, ms Single verify, ms Proof bytes, unchanged
28 23.315 → 22.373 39.680 → 40.058 98,496
27 23.698 → 21.686 39.656 → 40.044 98,112
26 17.851 → 17.877 30.206 → 30.273 96,688
25 12.587 → 12.555 27.968 → 27.889 94,189
24 11.246 → 11.317 18.319 → 18.492 94,641
23 10.297 → 10.259 19.608 → 19.475 94,021
22 10.110 → 10.215 17.568 → 17.643 93,554

Prover process memory in GiB. Commit/opening RSS is the peak sample during stages 0/8, sampled every 100 ms and including live trace/witness storage.

log₂ trace Commit RSS Opening RSS Lifetime peak RSS Peak physical footprint
28 18.601 → 18.933 28.875 → 28.950 28.936 → 29.081 36.792 → 36.821
27 11.929 → 11.929 23.740 → 23.965 23.781 → 23.978 22.912 → 22.886
26 6.365 → 6.138 12.053 → 11.678 13.395 → 12.988 12.725 → 12.016
25 5.752 → 6.474 6.784 → 6.611 6.814 → 6.684 6.517 → 6.677
24 2.007 → 2.069 2.346 → 2.359 3.571 → 3.726 3.354 → 3.461
23 1.306 → 1.349 1.919 → 1.923 1.959 → 1.969 1.805 → 1.802
22 0.656 → 0.708 1.187 → 1.192 1.188 → 1.192 1.043 → 0.981

The branch's selected profile is K256/D512 at scales 28, 26, and 25; K256/D256 at scale 27; and K16/D512 at scales 24, 23, and 22. Memory is sampled process RSS during stages 0/8 every 100 ms, including live trace/witness storage; lifetime RSS and physical-footprint peaks are also reported above. Memory samples vary with macOS compression, so timing gains should not be interpreted as a general memory reduction.

The local audit checked all 56 unique sample identities, matching binary/source/schedule identities and trace geometry, and independently recomputed every trimmed mean. It found no suspension-sized gaps in the accepted runs. Stale-build and superseded scalar-shortcut diagnostic candidates were excluded. Raw samples, summaries, Chrome traces, build identities and the consolidated report are retained locally under benchmark-runs/akita-shared-a-batch-20261003/; benchmark binaries and trace artifacts are not committed.

Testing

The checks below were rerun after transplanting the patch onto eca990e4f and preserving the current ARM tile. The full benchmark sweep belongs to the original snapshot described above.

  • cargo nextest run -p jolt-akita --cargo-quiet — 85 passed, 0 failed, 0 skipped.
  • cargo clippy -p jolt-akita --all-targets -q -- -D warnings.
  • cargo clippy --all --features host -q --all-targets -- -D warnings.
  • cargo clippy --all --features host,zk -q --all-targets -- -D warnings.
  • cargo fmt -q and git diff --check.
  • Full SHA2-chain proof/verification sweep at scales 28 through 22, four runs per version/scale.

Security Considerations

The change reorganizes prover-side evaluation of the same commitment; verifier relations, transcript absorption, proof encoding, setup parameters, and commitment output ordering are unchanged. Canonical negacyclic digits preserve field negation, and the existing wide-accumulation bound is carried across tile boundaries and enforced before accumulation. Materialized/algebraic tests check commitment values independently of the optimized kernel, and every benchmark proof passed both verifiers.

Breaking Changes

None.

0xAndoroid and others added 30 commits September 27, 2026 22:04
Akita main (includes LayerZero-Labs/akita#37): akita-transcript on
spongefish 0.7.4 rev ef974134 (u64 squeeze counters, pointer-width
independent challenges). One workspace spongefish source; jolt-poly joins
the a16z/jolt path patch because akita now depends on it via git.
akita db5efa20 (akita#37) replaces the typed batched proof and its
transcript with Spongefish argument bytes keyed by a session label, moves
the CPU prover behind an owning CpuBackend with CommitmentHandles, and
verifies through AkitaVerifier. Bridge Jolt's statement-bound challenge
into the session bytes, commit via CpuBackend::import_source/commit, keep
the retained source in the handle instead of a second copy in the hint,
cache prepared AkitaVerifiers per flavor, and port TracePackedOneHot to the
akita_pcs::custom_source contracts. The proof-shape guard goes away with
the structured proof layer; only the commitment payload guard remains.
The akita_prover groups commit through CpuBackend::commit and prove to
Spongefish argument bytes; sources are imported once outside the timed
region. akita-prover and akita-transcript are no longer direct
dependencies of jolt-dory.
cargo metadata per sub-workspace; no wholesale update.
akita#37 changed the planner policy identity (cost model
NativeNoncePayloadAndSetupEnvelopeV2, selection objectives V5/V6), so the
checked-in .aks envelopes no longer pass the policy-digest check. Rows:
k16 46 (37 changed), k256 64 (38 changed), dense 42 (40 changed); no rows
added or removed, and the direct/offloaded cutover is unchanged.
An Akita CommitmentHandle proves only on the CpuBackend that committed it,
and advice / committed-program objects are committed on their own
transparent setups' dense backends. Import each precommitted handle into
the trace one-hot backend before the grouped batched_prove; Akita
recomputes the dense commitment from the retained source and checks it
against the shared public matrix. The trailing-garbage fold_paths test now
expects Akita's own EOF rejection (VerificationFailed) since the adapter no
longer deserializes the proof.
a16z#1941 rewrote the K<D commit accumulate on digit windows and added a
streamed-vs-materialized commit test built on akita-internal hooks
(compile_commitment_request, ComputeBackendSetup::prepare_setup,
commit_resolved_inner_host) that db5efa20 keeps crate-private or dropped.
commit_packed now takes the expanded setup directly, and the test's oracle
is the single-digit inner map over Akita's canonical one-hot table.
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

📏 PR diff

Note

Actual code changed: 548 lines

🟢 +351 added    🔴 −197 removed

Tests, docs, fixtures, and helper scripts excluded.

Category 🟢 Added 🔴 Removed
⌨️ Actual code +351 −197
🧪 Tests +148 0
📚 Docs +8 −2
📦 Fixtures 0 0
🔧 Helper scripts 0 0
Total diff +507 −199

Every changed line is classified once.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

Warning

This PR has more than 500 changed lines of actual code (548 added+removed; tests, docs, fixtures, and helper scripts are excluded) and does not include a spec.

Large features and architectural changes benefit from a spec-driven workflow.
See CONTRIBUTING.md for details on how to create a spec.

If this PR is a bug fix, refactor, or doesn't warrant a spec, feel free to ignore this message.

@RadNi
RadNi force-pushed the amir/akita-batch branch 2 times, most recently from 1ef80d5 to 2e3ed2f Compare October 6, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-spec PR has no spec file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants