Skip to content

perf(akita)!: batch native trace columns with first-fold cycle locality - #51

Closed
RadNi wants to merge 14 commits into
codex/bump-akita-e2c49edfrom
amir/akita-batch
Closed

RadNi wants to merge 14 commits into
codex/bump-akita-e2c49edfrom
amir/akita-batch

Conversation

@RadNi

@RadNi RadNi commented Oct 2, 2026 •

Copy link
Copy Markdown

Summary

Replace the selector-packed Akita trace polynomial with one native commitment group containing the actual trace columns. Every column has log_T + log_K variables and opens at the same point; the prover and verifier share the canonical group claim. Native batching establishes first-fold cycle locality: each chunk owns the same cycle range across all trace columns.

Later folds still halve one flat recursive witness, so boundary blocks and the tail can cross chunk owners from the second fold onward. Recursive ownership alignment is tracked separately in Akita #175, which is outside this PR's pinned revision. Adopting that change requires a later pin upgrade and regeneration of the affected Jolt multi-chunk catalogs.

Changes

  • Intentionally carry the Akita pin upgrade in this PR, from e2c49ed450f1999a743e7fd4a648f230ce45472f to its immediate successor 83574331d4e51f8cce1d8689d05592fa4ef4c138. The successor merges Akita #169, adding batched opening preparation and source evaluation, including batch-only source kernels; the fused trace opening uses this batch dispatch.

  • Import lightweight column views over one shared trace owner. Fuse commitment, evaluation/folding, decomposition, and coefficient packing across columns while retaining the streaming kernels, rotations, SIMD paths, deferred reductions, and position tiling. Source coefficient materialization remains unavailable.

  • Remove trace selector reduction from stage 8, retain one trace commitment slot and one joint PCS proof, and keep auxiliary object layouts.

  • Carry the native group layout and actual polynomial count through setup and scheduling; retain K=16 production coverage plus explicit fixtures, and restrict native K=256 trace keys to the exact benchmark, cutover, advice, and forced-guest fixtures, and update layout digests and transcript domains. The ten checked-in catalogs contain 1,611 rows (1,548 one-hot and 63 dense), totaling 20,256,534 bytes. The updated base's one- and two-polynomial adapter/planner grids are retained alongside the native trace keys, including smaller multi-chunk arities. The generator and key-membership tests share the admitted keys. Shipped K=256 native trace keys provide fixture and benchmark coverage only; the scalar adapter/planner grid remains available. They do not provide a general production trace range. Other K=256 shapes require a deployment-owned catalog containing the exact shape; grouped setup rejects missing shapes with guidance to use production K=16 or supply that catalog.

  • Preserve the updated base's chunk-profile validation and transcript label, conservative dense producer catalogs, cross-profile advice commitment reuse, and grouped-planner diagnostic.

  • Use the checked-out SDK in both generated-project CI jobs so fork PR merge commits are not fetched from a16z/jolt.

Review follow-ups

  • Accumulate opening folds and coefficient-packing coordinates directly into the final column-owned vectors. Merge commitment partials into the final coefficient buffers and move those buffers into RingVec, removing the intermediate per-column copies while preserving fused trace traversal and tiled accumulation.
  • Resolve all 266 production K=16 keys (widths 51–64, arities 16–34) through the production field-inline provisioner under Single, W2R2, W4R2, and W8R2. Keep the explicit K=256 fixture checks and advice-subset coverage.
  • Extend opening parity to nonconstant Subfield multipliers for K=16/K=256 and D=64/128/256/512, including partial-block geometry and committed digit zero. Verify the original statement before asserting that swapping distinct column evaluations rejects. Existing shared-owner/dimension/column-order rejection remains covered.
  • Replace obsolete trace/protocol “packed” vocabulary in code, test labels, CI labels, and current documentation. Rename the protocol config variant and commitment absorption helpers to Akita; freeze the unchanged binary enum encoding. Retain terminology for actual auxiliary prefix layouts and coefficient packing, and mark historical format investigations explicitly.

Testing

Post-review follow-up validation:

  • 94 field-inline adapter tests across runs, including all 1,064 production width/arity/profile combinations, Base/Subfield source parity, and swapped evaluation rejection. The unchanged scalar grouped-cutover test is excluded here; it passed in merge validation below.
  • 116 ordinary and 113 field-inline Akita prover/verifier tests, including acceptance matrices, backend proof parity, cross-profile advice reuse, tampering, and Fiat-Shamir inventory.
  • Clear muldiv and four ZK completeness/BlindFold fixtures; explicit binary wire-format assertions in both modes.
  • Workspace Clippy with host and host,zk; Akita/field-inline/profiling/prover-fixtures/FS-audit Clippy; formatting and repository style checks.

The exhaustive production-grid tests run real schedule adaptation per key. Local runtimes were 1.5 s for Single, 6.6 minutes for W8R2, 13.2 minutes for W4R2, and 20.7 minutes for W2R2.

Validation after merging base revision 45fc2e03a:

  • 189 Akita/claims tests, including scalar and native-column grouped cutover coverage; 91 field-inline adapter tests. The shared cutover test was run once.
  • 116 ordinary Akita prover/verifier tests and 113 field-inline prover/verifier tests, including both guest matrices, advice and committed-program proofs, cross-profile advice commitment reuse, tampering, and Fiat-Shamir inventory checks.
  • Clear muldiv verifier fixture and four ZK completeness/BlindFold shape fixtures.
  • Workspace Clippy with host and host,zk; Akita/field-inline/prover-fixtures/FS-audit Clippy across adapter, prover, and verifier targets; formatting and repository style checks.
  • Jolt CLI rebuilt from the merged checkout before guest testing.
  • Canonical catalog rendering and validation: 1,611 rows audited, 87 scalar rows replanned for the native cutover, 1,524 unchanged rows reused. The Akita pin upgrade changes no planner, config, params, or schedules source.

Catalog freshness enforcement was run locally: gen_jolt_schedules crates/jolt-akita/schedules k256 --check replanned all 12 rows across the four K=256 catalogs and reproduced every artifact byte for byte. A negative check against a stale temporary dense-full catalog rejected it with stale schedule artifacts, confirming content drift fails the check. A complete ten-catalog --check replan and CI enforcement remain follow-ups.

Performance

Measured 2026-10-06 on an Apple M4 Max, 16 workers, 64 GiB RAM, macOS 26.5.2, Rust 1.95.0. Exact PR base 45fc2e03a versus head f00ec0b5c, including the intentional Akita pin upgrade. Both use ci, akita,profiling, optimized backend, and tracing disabled. Three fresh-process samples per revision/case, alternating base/head, head/base, base/head; tables show medians. All 48 proofs passed both 16-worker and one-worker verification (96 successful calls); guest ELF hashes and raw trace lengths match across revisions.

Workload / profile Prove base → head (s) Change Peak RSS base → head (MiB) Change Peak footprint base → head (MiB)
fibonacci 2^18 / single 1.319 → 0.913 -30.8% 343.4 → 370.9 +8.0% 259.0 → 284.3
fibonacci 2^20 / single 4.635 → 4.638 +0.1% 585.3 → 625.6 +6.9% 513.7 → 556.1
sha2-chain 2^20 / single 4.350 → 4.385 +0.8% 575.7 → 616.6 +7.1% 521.8 → 540.3
sha2-chain 2^22 / single 16.868 → 16.397 -2.8% 1261.2 → 1230.0 -2.5% 936.7 → 1058.5
fibonacci 2^20 / w2r2 4.323 → 4.246 -1.8% 625.7 → 607.3 -2.9% 529.3 → 559.9
fibonacci 2^20 / w4r2 4.491 → 4.561 +1.6% 735.2 → 736.1 +0.1% 636.3 → 637.6
fibonacci 2^20 / w8r2 4.610 → 4.601 -0.2% 994.8 → 799.0 -19.7% 892.9 → 703.2
fibonacci 2^24 / w8r2 65.762 → 71.078 +8.1% 3959.8 → 5696.9 +43.9% 3713.3 → 5684.8
Workload / profile Parallel verify base → head (ms) Single-thread verify base → head (ms) Proof base → head (bytes)
fibonacci 2^18 / single 9.77 → 8.72 15.80 → 13.70 87,672 → 86,042
fibonacci 2^20 / single 11.47 → 10.94 22.31 → 24.52 89,124 → 88,781
sha2-chain 2^20 / single 11.39 → 11.52 21.77 → 26.27 89,527 → 89,173
sha2-chain 2^22 / single 10.83 → 12.26 19.49 → 24.51 93,497 → 93,473
fibonacci 2^20 / w2r2 11.35 → 11.31 25.80 → 26.15 89,158 → 89,120
fibonacci 2^20 / w4r2 11.81 → 11.63 25.62 → 26.28 89,755 → 89,771
fibonacci 2^20 / w8r2 13.15 → 12.87 32.61 → 30.54 91,559 → 91,464
fibonacci 2^24 / w8r2 17.01 → 25.80 47.44 → 82.62 97,657 → 99,173

The level-3 witness growth is real: 2,514,944 → 8,831,232 coefficients (3.51×).
At the measured W8R2/2^24 shape, total proving changes by
+8.1%, peak RSS by +43.9%,
parallel verification by +51.7%, and single-threaded
verification by +74.2%. Its proof changes from
97,657 to 99,173 bytes.
The first recursive input shrinks while subsequent schedules change; the
level-3 ratio alone does not predict whole-proof time or process memory.

The measured W8R2/2^24 packing-versus-batching regression is tracked in Akita #191, related to the planner cost-model investigation in Akita #183. Both measured schedules have six recursive folds; native batching adds a second setup-prefix group and changes per-fold geometry. This is a suspected schedule-cost issue, not a demonstrated cheaper valid native schedule. Per-fold timing/allocation attribution and alternative-schedule benchmarks are needed to establish the cause and fix.

PCS setup is measured separately; it ranges from 20.9–203.1 ms at base and 88.2–2249.7 ms at head. Guest compilation, tracing, witness construction, catalog loading, and other preprocessing are outside the prove timer. RSS/footprint are process lifetime peaks. The host had about 8.94 GiB of swap in use, unchanged between the before/after readings; these are three-sample observations, not confidence intervals. Full ranges, setup timings, witness lengths, reproduction patches, and binary hashes are in the benchmark report, with all 48 individual samples in the CSV. Source snapshots, binaries, and process logs are retained under benchmark-runs/pr51-performance-20261006/.

Security Considerations

The common-point claim assembler checks canonical column order and arity. Batch construction checks shared trace ownership, dimensions, and source order. Native decomposition indexes challenges by column and block and aggregates by witness chunk. Existing verifier and tamper tests cover the changed opening statement; transcript domains and the trace layout digest change with the new geometry.

Breaking Changes

The obsolete Rust/textual config name CommitmentConfig::Packed becomes CommitmentConfig::Akita, and commitment-absorption helper names follow suit. The binary enum ordinal remains unchanged and is pinned by a wire-format test.

Jolt Akita proof and preprocessing compatibility changes. Setup now uses the actual native column arity and count. The trace source API and grouped schedule parameters change accordingly; there is one current trace path without a packing/batching runtime switch.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

📏 PR diff

Note

Actual code changed: 1,246 lines

🟢 +699 added    🔴 −547 removed

Tests, docs, fixtures, and helper scripts excluded.

Category 🟢 Added 🔴 Removed
⌨️ Actual code +699 −547
🧪 Tests +707 −386
📚 Docs +941 −238
📦 Fixtures +23 −22
🔧 Helper scripts +15,868 −1,733
Total diff +18,238 −2,926

Every changed line is classified once.

@github-actions github-actions Bot added the no-spec PR has no spec file label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

Warning

This PR has more than 500 changed lines of actual code (857 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 changed the title Replace packed Akita trace with fused native column batching perf(akita)!: replace packed trace with fused native column batching Oct 2, 2026
@RadNi
RadNi changed the base branch from codex/akita-multi-chunk-on-1948 to codex/bump-akita-e2c49ed October 2, 2026 18:08
@RadNi
RadNi force-pushed the amir/akita-batch branch 2 times, most recently from 2f48e7f to 4b9ff2f Compare October 3, 2026 06:35
@RadNi
RadNi force-pushed the codex/bump-akita-e2c49ed branch from 0e7f486 to 9aa1f8c Compare October 3, 2026 06:35
@RadNi
RadNi force-pushed the amir/akita-batch branch from 4b9ff2f to eca990e Compare October 3, 2026 06:54
@quangvdao

Copy link
Copy Markdown

Review at head eca990e4f6d795df946190d0f18ce3d5573b37a0 (base 15e14a21a). The code looks correct to me: removing the selector reduction loses nothing (one leaf per canonical column at one shared point; commitments incl. poly_count and ordered evaluations are absorbed before Akita derives batching challenges; the layout digest is injective and checked on the verifier), and the kernel orderings match Akita at the pinned rev (poly-major challenges i·B + j, shared block weights, source-ordered outputs). Items below, most important first.

1. Moderate: spec and book still describe the deleted design. The PR touches nothing under specs/ or book/.

  • specs/lattice-claims.md:36-38 (calls itself the current claim boundary; one physical polynomial + selector reduction)
  • book/src/how/akita.md:15,23-33 (packing equation and selector sampling)
  • book/src/how/architecture/opening-proof.md:42 ((slot || cycle || address))
  • Also stale: CLAUDE.md ("Akita packs the one-hot trace"), module name stage8/packed.rs, "packed setup's …" error strings in jolt-prover/src/akita/stage0.rs, witness.rs:114,120, doc comments at scheme.rs:61 and adapters.rs:166,475,542.

2. Low: the 64-column limit lost its single owner. OneHotTraceLayout::plan dropped the TooManyOneHotTraceColumns check (strategy.rs#L48-L77), while jolt-prover/src/akita/witness.rs:239-243 does an unchecked 1u64 << column; the typed check is later in trace_onehot/source.rs:99. Not reachable today because catalog admission at preprocessing rejects wider shapes (schedule_registry.rs:402-406), but the shift's safety now depends on a catalog constant in another crate. Suggest restoring the check in plan() with a 64-ok / 65-typed-error test.

3. Low: PR-body numbers and the "drift test". Head has 1,410 catalog rows / 18.9 MB (1,347 one-hot + 63 dense) against 503 rows / 5.9 MB at base; "2,984 → 1,011" and "1,074" describe intermediate commits (the last commit added 336 rows). tests/schedules.rs:425-505 compares key sets only and shares one_hot_keys with the generator, so it cannot detect stale row content or a missing reachable key. The width/arity ranges in schedules/mod.rs are hand-maintained rather than derived from one_hot_trace_columns.

4. Low: K=256 grid. 276 rows / 4.4 MB at head (232 / 2.8 MB at base), but jolt-prover/src/config.rs:221-235 always selects 4-bit chunks under akita. Is explicit K=256 a supported path? If not, these could be reduced to the fixtures.

5. Low: per-column buffer copies. opening.rs:276 (folded.to_vec() per column), traversal.rs:328, commit.rs:303-310. Linear, unmeasured.

6. Test gaps. No permanent streamed N>1 prove/verify round trip with wrong/swapped-evaluation rejection (the grouped streamed fixture has N=1); OpeningFoldPlan::Subfield untested; the chunk loop filters chunks <= num_blocks, so empty-range cases are not exercised.

Notes: the FS inventory scanner does not recognise append_values, so the inventory file alone does not certify point binding (I confirmed it by reading the absorb code). I did not independently verify the ±2% performance claim. When the Akita pin moves past akita#175, the six -multi-chunk/-w2r2/-w4r2 catalogs (1,002 rows) will need regeneration.

@github-actions github-actions Bot added spec PR contains a spec implementation PR contains implementation of a spec and removed no-spec PR has no spec file labels Oct 5, 2026

@quangvdao quangvdao left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at efee957d7a. The switch to native column batching looks sound to me and I have no blocking findings. Follow-ups below.

Since my comment at eca990e4f6

  • Addressed: the 64-column limit has a single owner with a test, and the K256 grid is pruned.
  • Mostly addressed: the stale "packed" naming (some strings and specs/akita-optimal-committed-data.md:283-301 remain).
  • Partly addressed: catalog drift. gen_jolt_schedules --check exists, but nothing runs it.
  • Still open: the per-column buffer copies (opening.rs:276, traversal.rs:346, commit.rs:299), and some test gaps (below).

Soundness of the switch (traced)

  • Prover and verifier share the claim assembler (crates/jolt-verifier/src/stages/stage8/akita.rs:379); column order comes from the plan and is bound into the layout digest.
  • Every column needs exactly one leaf claim and the point arity is checked.
  • Commitment, point and all M evaluations are absorbed before Akita's challenges are derived (crates/jolt-akita/src/native_batching.rs:154-199).
  • The ! is a real proof and setup break; I found no stale fixtures, zk+akita is still a compile error, and non-akita builds are untouched.

Findings

  1. Description vs what lands. The description says packing forces cross-chunk transfers from the second fold onward and motivates the PR with that. As I read the code, and as specs/akita-native-trace-batching.md:72-76,179 says, this PR makes the first fold chunk-local; the recursive witness is still one flat polynomial halved again, so the boundary block and the tail still cross owners from the second fold on. That is fine as a step, but the title/description should say so and link the follow-up.

  2. No performance numbers in the PR. I measured on a 16-core M-series machine (ci profile, three alternating runs each, with other builds running, so treat as rough):

    Workload Base prove (s) Head prove (s) Peak RSS
    fibonacci 2^18 1.31–1.37 0.89–0.90 +8%
    fibonacci 2^20 4.53–4.67 4.59–4.97 +8%
    sha2-chain 2^20 4.37–4.43 4.38–4.48 +8%
    sha2-chain 2^22 16.34–16.71 16.14–16.22 −4%

    So prover time holds, with a 7–9% peak-memory rise up to 2^20 that is worth a line. Verifier time, proof size and multi-chunk configurations are unmeasured; the catalog shows a 3.5× larger level-3 witness for the w8r2 row at log_T=24, which I would like to see measured.

  3. Catalog regeneration is not enforced. No CI job or test runs --check, and the remaining test compares keys only. gen_jolt_schedules … k256 --check reproduces all four artifacts byte for byte; I did not finish the K16 and dense catalogs.

  4. Akita pin. Head pins 83574331d4, one commit past #52's e2c49ed. Is that intended to ride here, or should #52 carry it?

  5. crates/jolt-akita/src/schedule_registry.rs:193: the full-width rejection lost its only test.

  6. Field-inline provisioning is tested at width 51 only (19 of 266 K16 keys). Not a known failure, a coverage gap.

  7. K=256 traces are now provisionable for fixture shapes only.

  8. trace_onehot/kernels.rs:82: the single-source kernel computes all M columns and discards all but one. Dormant at the current pin.

Test gaps

  • No jolt-akita-level test that a swapped evaluation or a permuted column order is rejected.
  • No test of OpeningFoldPlan::Subfield.
  • No second-fold locality test (relevant once the follow-up lands).

Ran

  • cargo nextest run --cargo-profile ci -p jolt-akita -p jolt-claims: 303 pass.
  • -p jolt-akita --features field-inline: 92 pass.
  • -p jolt-prover --features akita,prover-fixtures: 31 pass, 2 skipped, including the Akita end-to-end prove/verify tests.

Not run: field-inline end to end, the full catalog --check.

@RadNi RadNi changed the title perf(akita)!: replace packed trace with fused native column batching perf(akita)!: batch native trace columns with first-fold cycle locality Oct 5, 2026
@RadNi
RadNi requested a review from quangvdao October 6, 2026 18:53
@RadNi

RadNi commented Oct 6, 2026

Copy link
Copy Markdown
Author

@quangvdao Following up on findings 2 and 3 in your review:

The PR description now includes the full base/head performance comparison, with verifier timings, proof sizes, and Single/W2R2/W4R2/W8R2 measurements. There are three alternating fresh-process samples per side/case; all 48 proofs passed both verification modes. The report and raw samples are checked in.

The W8R2 Fibonacci 2^24 regression is confirmed: proving 65.762 -> 71.078 s (+8.1%), peak RSS 3,959.8 -> 5,696.9 MiB (+43.9%), parallel verification 17.01 -> 25.80 ms (+51.7%), single-threaded verification 47.44 -> 82.62 ms (+74.2%), and proof size 97,657 -> 99,173 bytes (+1.6%). PCS setup is separately timed; memory figures are lifetime process peaks.

Opened Akita #191 and linked it from the description. Both schedules have six recursive folds, but native batching adds a second setup-prefix group and increases the third recursive input by 3.51x. The issue records the exact geometry and measurements and asks for per-fold profiling and valid alternative-schedule comparisons. It is related to #183, but we have not established that the current native schedule can be replaced by a cheaper valid one.

Catalog freshness enforcement was also run locally: gen_jolt_schedules crates/jolt-akita/schedules k256 --check replanned all 12 rows across the four K=256 artifacts and matched them byte for byte. A negative check against a stale temporary dense-full artifact correctly failed with stale schedule artifacts. The description now reports this scope explicitly; a complete ten-catalog replan and CI enforcement remain follow-ups.

@RadNi
RadNi force-pushed the codex/bump-akita-e2c49ed branch from 45fc2e0 to e2ba202 Compare October 6, 2026 20:15
@RadNi
RadNi force-pushed the amir/akita-batch branch from 201e9b4 to 1ef80d5 Compare October 6, 2026 20:38
@socket-security

socket-security Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgithub/​taiki-e/​install-action@​bb0282cdd6e41599bc8dfa5fc712ebe9e27cfd8c ⏵ 83ac0ad63c0167e6f06796fab0fce28db1bf3db099100100100100

View full report

@sumchecker

Copy link
Copy Markdown
Collaborator

Reopened upstream as a16z#2012 now that the Akita bump (a16z#2006) has merged there.

@sumchecker sumchecker closed this Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

implementation PR contains implementation of a spec spec PR contains a spec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants