Skip to content

perf: parallelize trace compaction and bytecode cycle tables - #54

Open
sumchecker wants to merge 4 commits into
codex/akita-shared-a-commitfrom
sumchecker/parallel-trace-compaction
Open

sumchecker wants to merge 4 commits into
codex/akita-shared-a-commitfrom
sumchecker/parallel-trace-compaction

Conversation

@sumchecker

@sumchecker sumchecker commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation
Two prover phases leave most cores idle on large CPU machines. At 2^30 cycles on a 192-vCPU C4D runner, trace compaction ran on one thread for about a minute (a fifth of the proof). The Stage 6b bytecode cycle prepare took 23 s and was slower than on 96 vCPUs. Several full-trace tables were collected through rayon's Result collect, which concatenates the per-thread segments on one thread.

Key Changes

  • jolt-witness: TraceBackend::try_new compacts rows with rayon under parallel, then truncates the trailing padding rows. Rows before the last real cycle are kept, as before.
  • jolt-kernels: new support::weighted_eq_sum computes Σ_k w_k·eq(p_k, ·) in one parallel pass from each point's TensorEqTable factors. The bytecode read-RAF cycle phase uses it for its combined and fused tables instead of materializing and adding one full eq table per stage. The tables hold the same field values.
  • jolt-witness and jolt-kernels: the compact trace rows, the instruction claim-reduction operand table and the register increment bind collect through jolt_utils::par_collect_windows. It writes in place and keeps the lowest-index error. Collects over per-chunk folds are unchanged.

Based on #53. Neither commit touches a file changed by #51–#53.

Breaking Changes
None.

Testing

  • jolt-witness tests under no features, parallel, field-inline and parallel,field-inline, including a new test for padding before the last cycle; jolt-kernels tests, including the bytecode reference-parity tests, under parallel, parallel,akita and parallel,akita,field-inline; clippy -D warnings for those feature sets; cargo fmt --check.
  • Akita e2e proofs (modular prover, CPU), sha2-chain 2^15 to 2^30, proofs verified, proof sizes unchanged.
  • 2^28 on 32 threads: bytecode cycle prepare 7.6 s → 1.9 s. 2^26 on 16 threads: pre-proving gap 4.6 s → 1.6 s. 2^28 on 32 threads: instruction claim-reduction prepare 1.27 s → 0.51 s, end to end 195.6 s → 189.2 s.

End-to-end proofs on GCP C4D (AMD EPYC 9B45) machines, one per size, before → after this PR: sha2-chain proving time in seconds, every proof verified, peak RSS unchanged:

Trace c4d-standard-96 c4d-standard-192 c4d-standard-384
2^27 57.1 → 42.5 45.2 → 35.6 50.0 → 38.7
2^28 112.0 → 82.8 83.4 → 65.1 84.5 → 63.6
2^29 217.8 → 158.8 159.8 → 120.1 151.5 → 111.3
2^30 428.1 → 312.5 313.9 → 232.9 281.4 → 203.2

🤖 Generated with Claude Code

sumchecker and others added 2 commits October 5, 2026 04:23
TraceBackend::try_new converted every raw trace row on one thread. At 2^30
cycles that took about a minute on a 192-vCPU host, a fifth of the whole
proof, with the rest of the machine idle. Convert the rows with rayon under
the `parallel` feature, then drop the trailing padding rows. The compact trace
is unchanged: rows before the last real cycle are kept even when they compact
to the default row.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The Stage 6b bytecode read-RAF cycle phase built one full 2^log_T eq table
per stage cycle point and added each into its combined table: eight dense
tables and a read-modify-write pass apiece. At 2^30 cycles that was 16 GiB
per table, and the prepare step took over 20 s without speeding up as
vCPUs were added.

Accumulate every weighted term into the combined table in one parallel pass
from each point's ~sqrt(T) TensorEqTable factors. The tables hold the same
field values. At 2^28 on 32 threads, prepare drops from 7.6 s to 1.9 s.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

📏 PR diff

Note

Actual code changed: 170 lines

🟢 +90 added    🔴 −80 removed

Tests, docs, fixtures, and helper scripts excluded.

Category 🟢 Added 🔴 Removed
⌨️ Actual code +90 −80
🧪 Tests +19 0
📚 Docs +4 0
📦 Fixtures 0 0
🔧 Helper scripts 0 0
Total diff +113 −80

Every changed line is classified once.

@github-actions github-actions Bot added the no-spec PR has no spec file label Oct 5, 2026
sumchecker and others added 2 commits October 5, 2026 05:17
Rayon's `Result` collect loses indexedness, so it stages every thread's
segment and concatenates them on one thread. For full-trace tables that is a
serial copy of the whole table: 64 GiB of compact trace rows and 16 GiB of
instruction operands at 2^30 cycles.

Use `jolt_utils::par_collect_windows`, which writes each index in place and
keeps the lowest-index error, for the compact trace rows, the instruction
claim-reduction operand table and the register increment bind. At 2^28 on
32 threads the claim-reduction prepare drops from 1.27 s to 0.51 s.

Collects over per-chunk folds keep the rayon collect: they have too few
items for the fixed collect chunk to spread across threads.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The bytecode reference-parity tests cover weighted_eq_sum through the
production kernel, so the test that re-added the deleted per-stage loop as
its oracle goes. The interior-padding test now builds each cycle row, since
TraceRow is not Copy under field-inline.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sumchecker
sumchecker marked this pull request as ready for review October 6, 2026 16:08
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.

1 participant