Skip to content

perf(algebra): optional no-carry tensor contraction for dense residual equality weights - #272

Closed
Acentelles wants to merge 2 commits into
LayerZero-Labs:markos/recursion-integrationfrom
Acentelles:perf/tensor-no-carry-contraction
Closed

Acentelles wants to merge 2 commits into
LayerZero-Labs:markos/recursion-integrationfrom
Acentelles:perf/tensor-no-carry-contraction

Conversation

@Acentelles

@Acentelles Acentelles commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

What changes

A new feature tensor-no-carry in akita-algebra, off by default.

With the feature on, materialize (offset_eq/tensor_pair/materialize.rs) separates the dense residual equality weights into a high-part sum and a low span through the new materialize/separate.rs (prepare and evaluate). The low span is contracted without carry propagation. Shapes that do not fit (carry-mixed residues, possible overflow) are declined and take the existing path. Without the feature, the code path is unchanged.

The branch also carries the lockfile-only ctutils 0.4.6 bump for RUSTSEC-2026-0385.

Why

When the verifier runs inside a zkVM guest, every executed instruction is a trace row of the outer proof. Separating the high-part sum lets the low span be contracted without carry propagation, which costs fewer guest instructions and gives the same field values.

Benefit

Total trace rows (real plus virtual) of Jolt's recursion example (a16z/jolt#2143), whose guest verifies one Akita proof of an inner Jolt proof, without and with this feature:

Jolt and Akita build Inner $2^{12}$ Inner $2^{20}$ Host
An earlier recursion build 58,017,137 to 57,993,655 (-23,482) 148,001,366 to 147,863,178 (-138,188) AMD Ryzen 9 5900XT; confirmed on an AMD Ryzen 9 5950X
With size-oriented spill splitting in the guest build 57,927,886 to 57,904,348 (-23,538) 147,794,518 to 147,656,265 (-138,253) AMD EPYC 7773X
Adding the guest build's register cost-per-use setting 57,813,926 to 57,804,752 (-9,174) 147,659,422 to 147,597,159 (-62,263) AMD EPYC 9124

The gain is smaller on the last build because it interacts with that register-allocation setting. The Akita proof is unchanged (72,672 bytes at $2^{12}$, 75,817 at $2^{20}$). The effect on this branch alone, without the other recursion changes, was not separately measured, and no published-build figure isolates this change.

How it was tested

  • New unit tests in separate.rs compare the separated residual with boolean equality at zero and one challenges, and check that carry-mixed residues and overflow are declined.
  • In the Jolt recursion example, honest proofs are accepted and tampered proofs are rejected, with the feature on.
  • A fresh clone of this branch was not measured on its own; the published Jolt branch that enables it (perf(recursion): cut the recursion verifier guest to 45.4M trace rows at inner 2^12 (42.5% below #1911) a16z/jolt#2143) was measured from a fresh clone with Akita fetched from this repository.
  • CI on this branch: Format, Clippy and both Test shards pass.

Risks and limits

  • Same field values by construction; any shape the no-carry path cannot handle falls back to the existing path.
  • The gain is small on the current recursion build (-9,174 rows at inner $2^{12}$), larger at $2^{20}$.
  • CI's "Transcript semantics" job is cancelled at its 40-minute limit (timeout-minutes: 40 in .github/workflows/ci.yml on the base branch) on this branch, as on every PR in this series against markos/recursion-integration, including those that do not touch the code it runs. It is a CI time budget, not a test failure; Format, Clippy and the Test shards pass.

How to turn it off

The feature is off by default. A consumer enables tensor-no-carry on akita-algebra.

Evidence

Commits: this head 3c10baf5; the change 9371be51.

@Acentelles

Copy link
Copy Markdown
Collaborator Author

Folded into #277.

@Acentelles Acentelles closed this Oct 27, 2026
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