Skip to content

docs(book): explain the basic relations in an Akita fold - #340

Open
f7ed wants to merge 18 commits into
mainfrom
freya/akita-book-relation-in-fold
Open

docs(book): explain the basic relations in an Akita fold#340
f7ed wants to merge 18 commits into
mainfrom
freya/akita-book-relation-in-fold

Conversation

@f7ed

@f7ed f7ed commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a self-contained derivation of the four basic physical ring-relation families proved by a non-terminal Akita fold: fold-evaluation consistency, inner-commitment consistency, outer-commitment consistency, and opening-commitment consistency
  • present the basic setting with one polynomial group, one opening claim, one witness chunk, and one common ring dimension
  • derive the canonical consistency | A | B | D row layout, its public right-hand side, the quotient extension, and the ring-switched Stage-2 relation
  • distinguish the physical opening-commitment relation from the field-valued EvaluationTrace virtual row
  • connect the basic mathematical objects to the current prover and verifier entry points

Scope

This PR documents only the basic Akita-fold relation. Multi-group batching, multiple witness chunks, and mixed ring dimensions are intentionally deferred to a stacked follow-up PR for advanced relation layouts.

Testing

  • git diff --check
  • ./scripts/check-doc-guardrails.sh

Dependency

This PR is stacked on #313 and therefore targets freya/akita-book. Once #313 merges, this PR can be retargeted to main.

f7ed and others added 3 commits July 29, 2026 22:02
Adds the field-to-ring evaluation reduction chapter, rewrites the Stage-1
sumcheck-stages page (Stage 1 digit range check, Stage 2 fused relation,
Stage 3 setup product), and links the new page from SUMMARY.md.

Review fixes: hand terminal-fold anatomy to proving.md, repoint the opening-
consistency link to field-ring-reduction.md, and pin all code references to a
single snapshot.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 31, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Documentation-only changes to the book; no runtime or cryptographic logic is modified.

Overview
Adds akita-fold.md, a new book chapter that derives the four physical ring-relation families in a basic (single-group) non-terminal fold: fold-evaluation, inner-commitment, outer-commitment, and opening-commitment consistency. It documents witness assembly (ẑ ‖ ê ‖ t̂ ‖ r̂), the consistency | A | B | D row layout and RHS, quotient extension before sumcheck, ring switching at α, and how the scalar opening claim is an EvaluationTrace virtual row (not a physical matrix row), with prover/verifier code pointers.

SUMMARY.md links the new page under proving. field-ring-reduction.md and sumcheck-stages.md cross-link to it instead of a vague section reference; Stage 2 now defers row-family derivation to this page. Several book code links are pinned to commit b104dae with line anchors.

Reviewed by Cursor Bugbot for commit f80c759. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown

Warning

This PR has more than 500 changed lines and does not include a spec.

Large features and architectural changes benefit from a short spec before implementation review.
See CONTRIBUTING.md for the spec workflow.

If this PR is a bug fix, small cleanup, or otherwise does not warrant a spec, feel free to ignore this message.

@github-actions github-actions Bot added the no-spec PR has no spec file label Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

Documentation blast radius (advisory)

These regions may need doc/spec/book updates based on changed paths.
This is not a merge gate. See docs/documentation.md.

Changed files in this PR: 4

book-tooling

Book structure and guardrails

Code paths touched:

  • book/src/SUMMARY.md
  • book/src/how/proving/akita-fold.md
  • book/src/how/proving/field-ring-reduction.md
  • book/src/how/proving/sumcheck-stages.md

Consider updating:

  • book/README.md
  • docs/documentation.md
  • specs/PRUNING.md

Per-PR checklist: spec Status / acceptance criteria; book owning page; AGENTS.md if contracts changed; archive spec after fold.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

Benchmark Report

  • Latest run: f80c759
  • Message: Merge remote-tracking branch 'origin/main' into freya/akita-book-relation-in-fold
  • Ref: freya/akita-book-relation-in-fold
  • Workflow run: run 31113527322 attempt 1
  • Report generated: 2026-08-06T15:14:37Z.
  • Main baseline: c9ca8e9 from the merge-base benchmarked on this runner.
  • Previous run: 4061afe from the previous PR update with a benchmark artifact.
  • Binary: target/release/examples/profile.
  • Memory: maximum resident set size from /usr/bin/time on the benchmark process.
Status Workload Setup contribution Setup and preparation Setup vector size Prepared NTT cache size Verifier NTT cache size Commit Prove Verify Peak process RSS Proof size
ok Fp32 - nv28Onehot256 - D=128 direct 0.044 s
+1.59% vs main
36.0 MiB
+0.00% vs main
144.0 MiB
+0.00% vs main
1.2 MiB
+0.00% vs main
0.093 s
-0.29% vs main
1.602 s
+0.00% vs main
33.8 ms
-1.13% vs main
461.1 MiB
-0.09% vs main
77,834 bytes
+0.00% vs main
ok Fp64 - nv28Onehot256 - D=128 direct 0.037 s
-0.93% vs main
40.0 MiB
+0.00% vs main
120.0 MiB
+0.00% vs main
0.9 MiB
+0.00% vs main
0.074 s
+1.84% vs main
1.202 s
-0.67% vs main
33.0 ms
-0.67% vs main
558.0 MiB
+0.42% vs main
83,596 bytes
+0.00% vs main
ok Fp128 - nv24Dense - D=64 direct 0.144 s
-1.45% vs main
215.0 MiB
+0.00% vs main
537.5 MiB
+0.00% vs main
1.4 MiB
+0.00% vs main
1.690 s
+0.91% vs main
1.249 s
-4.22% vs main
17.3 ms
+4.06% vs main
1557.6 MiB
+0.58% vs main
83,562 bytes
+0.00% vs main
ok Fp128 - nv26Onehot256 - D=64 - Tensor direct 0.698 s
-0.17% vs main
1024.0 MiB
+0.00% vs main
2560.0 MiB
+0.00% vs main
1.4 MiB
+0.00% vs main
0.143 s
+1.49% vs main
1.324 s
-0.49% vs main
37.8 ms
+1.09% vs main
4136.1 MiB
-0.13% vs main
85,080 bytes
+0.00% vs main
ok Fp128 - nv32Onehot256 - D=64 direct 0.223 s
+0.19% vs main
320.0 MiB
+0.00% vs main
800.0 MiB
+0.00% vs main
1.4 MiB
+0.00% vs main
1.369 s
-0.05% vs main
1.271 s
+0.30% vs main
25.3 ms
-0.20% vs main
1704.2 MiB
+0.34% vs main
84,972 bytes
+0.00% vs main
ok Fp128 - nv32Onehot256 - D_a=256D_b=128D_d=128 - MixedD256ToD64 direct 0.147 s
-0.01% vs main
128.0 MiB
+0.00% vs main
608.5 MiB
+0.00% vs main
1.4 MiB
+0.00% vs main
1.019 s
+0.18% vs main
1.339 s
-0.51% vs main
21.2 ms
+0.87% vs main
1411.4 MiB
+0.24% vs main
85,080 bytes
+0.00% vs main
ok Fp128 - nv30Onehot256 - Batched4 - D=64 direct 0.224 s
-0.15% vs main
320.0 MiB
+0.00% vs main
800.0 MiB
+0.00% vs main
1.4 MiB
+0.00% vs main
1.286 s
+0.62% vs main
1.270 s
-0.46% vs main
26.0 ms
+1.54% vs main
1693.8 MiB
-0.53% vs main
84,970 bytes
+0.00% vs main
ok Fp128 - nv32Onehot256 - Batched4 - D=64 - MultiGroup direct 0.457 s
+3.13% vs main
1032.0 MiB
+0.00% vs main
1075.0 MiB
+0.00% vs main
1.4 MiB
+0.00% vs main
3.302 s
+1.65% vs main
1.678 s
+0.70% vs main
31.0 ms
-1.58% vs main
3012.7 MiB
-0.58% vs main
85,093 bytes
+0.00% vs main
ok Fp128 - nv32Onehot256 - Batched4 - D=64 - MultiGroup recursive 3.947 s
-0.19% vs main
1032.0 MiB
+0.00% vs main
1075.0 MiB
+0.00% vs main
1.4 MiB
+0.00% vs main
3.156 s
-0.27% vs main
3.459 s
+0.42% vs main
26.5 ms
+0.27% vs main
3777.0 MiB
-0.32% vs main
89,873 bytes
+0.00% vs main
ok Fp128 - nv32Onehot256 - Batched4 - D=64 - MultiGroupW8R2 recursive 1.736 s
-0.01% vs main
430.0 MiB
+0.00% vs main
1075.0 MiB
+0.00% vs main
1.4 MiB
+0.00% vs main
3.157 s
+0.34% vs main
10.268 s
+0.19% vs main
37.4 ms
+0.78% vs main
3569.6 MiB
-0.26% vs main
95,904 bytes
+0.00% vs main
ok Fp128 - nv32Onehot256 - D=64 - MultiChunkW2R2 direct 0.223 s
-0.72% vs main
320.0 MiB
+0.00% vs main
800.0 MiB
+0.00% vs main
1.4 MiB
+0.00% vs main
1.372 s
+0.06% vs main
1.624 s
+0.37% vs main
27.9 ms
+1.38% vs main
1845.0 MiB
-0.21% vs main
85,331 bytes
+0.00% vs main
ok Fp128 - nv32Onehot256 - D=64 - MultiChunkW4R2 direct 0.240 s
+0.13% vs main
344.0 MiB
+0.00% vs main
860.0 MiB
+0.00% vs main
1.4 MiB
+0.00% vs main
0.410 s
-0.53% vs main
1.938 s
+0.72% vs main
31.3 ms
-0.24% vs main
2025.6 MiB
+0.42% vs main
85,946 bytes
+0.00% vs main
ok Fp128 - nv32Onehot256 - D=64 - MultiChunkW8R2 direct 0.239 s
-0.08% vs main
344.0 MiB
+0.00% vs main
860.0 MiB
+0.00% vs main
1.4 MiB
+0.00% vs main
0.408 s
+0.27% vs main
2.701 s
-0.71% vs main
33.9 ms
-0.14% vs main
2273.0 MiB
+0.83% vs main
86,215 bytes
+0.00% vs main

Negative deltas are improvements for time, memory, and proof size.

Terminal response component breakdown

Workload Folded response (z) Opening values (e) Inner-commitment values (t) Total terminal response
Fp32 - nv28Onehot256 - D=128 21,406 bytes 3,072 bytes 24,576 bytes 49,054 bytes
Fp64 - nv28Onehot256 - D=128 21,460 bytes 7,168 bytes 28,672 bytes 57,300 bytes
Fp128 - nv24Dense - D=64 21,854 bytes 7,168 bytes 28,672 bytes 57,694 bytes
Fp128 - nv26Onehot256 - D=64 - Tensor 21,848 bytes 7,168 bytes 28,672 bytes 57,688 bytes
Fp128 - nv32Onehot256 - D=64 21,852 bytes 7,168 bytes 28,672 bytes 57,692 bytes
Fp128 - nv32Onehot256 - D_a=256D_b=128D_d=128 - MixedD256ToD64 21,848 bytes 7,168 bytes 28,672 bytes 57,688 bytes
Fp128 - nv30Onehot256 - Batched4 - D=64 21,850 bytes 7,168 bytes 28,672 bytes 57,690 bytes
Fp128 - nv32Onehot256 - Batched4 - D=64 - MultiGroup 21,861 bytes 7,168 bytes 28,672 bytes 57,701 bytes
Fp128 - nv32Onehot256 - Batched4 - D=64 - MultiGroup 21,825 bytes 7,168 bytes 28,672 bytes 57,665 bytes
Fp128 - nv32Onehot256 - Batched4 - D=64 - MultiGroupW8R2 21,868 bytes 7,168 bytes 28,672 bytes 57,708 bytes
Fp128 - nv32Onehot256 - D=64 - MultiChunkW2R2 21,875 bytes 7,168 bytes 28,672 bytes 57,715 bytes
Fp128 - nv32Onehot256 - D=64 - MultiChunkW4R2 21,850 bytes 7,168 bytes 28,672 bytes 57,690 bytes
Fp128 - nv32Onehot256 - D=64 - MultiChunkW8R2 21,831 bytes 7,168 bytes 28,672 bytes 57,671 bytes

The z column includes its per-segment length prefixes and Golomb payload; e and t are raw field bytes. These three columns sum exactly to the serialized terminal response.

Detailed schedule and proof-size breakdowns by fold level are available in the uploaded report.md benchmark artifact.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

CI test timing

  • Report generated: 2026-08-06T15:12:41Z.
  • Source: 11da342 on freya/akita-book-relation-in-fold.
  • Workflow run: 31113527258.
  • Main baseline: c9ca8e9.
  • Previous run: 7ac56db.

Run summary

Wall s Main wall s Main Δ Ratio Tests Skipped Failed Status
316.0 302.0 +4.6% 1.05x 1278 0 0 ok

Wall time spans 2 parallel nextest slice shards.

Slowest tests

Rank Duration s Test
1 12.5 akita-planner::schedule_params::tests::pruned_mixed_search_matches_unpruned_traversal_and_is_canonical
2 9.2 akita-pcs::akita_e2e::dense_d64_snap_regen_prove_verify_nv24
3 6.8 akita-planner::schedule_params::tests::mixed_nv36_benchmark_policy_selects_minimum_setup_schedule
4 6.2 akita-sis-estimator::search_mode_parity::parallel_exhaustive_matches_serial_exhaustive_smoke
5 5.8 akita-planner::schedule_params::tests::uniform_suffix_dp_matches_unpruned_exact_cutover_search
6 5.1 akita-prover::kernels::linear::tests::chunking::q128_many_blocks_digits_chunk_instead_of_unsafe_block_parallel
7 4.8 akita-pcs::single_poly_e2e::single_dense_nv18
8 4.6 akita-sis-estimator::search_mode_parity::exhaustive_search_is_at_least_as_good_as_local_minimum_smoke
9 3.8 akita-pcs::setup::d64_dense::same_size_passes
10 3.7 akita-pcs::scheme::tests::onehot::multi_group_root_allows_precommitted_arity_above_final_group
11 3.6 akita-pcs::batched_aggregated_e2e::non_zk_aggregated_cases::aggregated_dense_nv17_batch4
12 3.6 akita-pcs::setup::d64_dense::large_setup_nv_passes
13 3.4 akita-prover::protocol::sumcheck::relation_range_image::tests::stage2_large_odd_dense_prefix_matches_padded_reference
14 3.3 akita-pcs::heterogeneous_prove_e2e::heterogeneous_delegating_clusters_batched_prove_and_verify
15 3.2 akita-pcs::setup::d64_dense::large_setup_batch_passes
16 3.2 akita-pcs::batched_aggregated_e2e::aggregated_mixed_dense_and_onehot_under_dense_cfg
17 3.1 akita-pcs::setup::d128_dense::large_setup_batch_passes
18 3.0 akita-prover::protocol::sumcheck::relation_range_image::tests::stage2_large_odd_sparse_boolean_prefix_matches_padded_reference
19 2.9 akita-pcs::setup::d128_dense::small_setup_nv_panics
20 2.9 akita-planner::schedule_params::tests::recursive_exact_cutover_proof_size_is_documented

Regressions vs main

No per-test regressions above the threshold.

New slow tests

No new tests ≥30s vs main baseline.

@f7ed f7ed changed the title docs(book): explain ring relations in an Akita fold docs(book): explain the basic relations in an Akita fold Aug 4, 2026
Base automatically changed from freya/akita-book to main August 6, 2026 14:51
…tion-in-fold

# Conflicts:
#	book/src/SUMMARY.md
#	book/src/how/proving/field-ring-reduction.md
#	book/src/how/proving/sumcheck-stages.md
@sumchecker

Copy link
Copy Markdown

P1 — The documented four-row relation is no longer the production relation.

The chapter says the current implementation has the four consistency | A | B | D families and presents B t̂ = u, D ê = v_D as direct public anchors (lines 11–19, lines 485–573).
Current main defaults to compressed payload mode. RelationRhsLayout::row_families appends CompressionF and CompressionH rows, while assemble_compressed_relation_rhs makes the ordinary B/D rows zero and exposes only terminal compression payloads. The verifier selects that compressed RHS path.
The four equations remain useful semantic source relations, but they are not the complete production matrix or public RHS. The chapter must either:
explicitly scope every direct-commitment claim to CommitmentPayloadMode::Uncompressed; or
document the compression-chain rows, witnesses, quotients, terminal payloads, and resulting RHS.

P1 — The canonical book contradicts an active security-sensitive spec.

The chapter says EvaluationTrace is weighted by the shared τ₁ row challenge (lines 667–682), matching current code.
However, specs/y-ring-trace-internalization.md remains “in review,” has unchecked acceptance criteria, and specifies γ² batching instead. These are mutually exclusive soundness descriptions.
Resolve the design record before merging: record the implemented deviation, update status/PR/criteria, add Book-chapter:, and archive or explicitly supersede the spec per repository policy.

P2 — Code references mix divergent, obsolete snapshots.

field-ring-reduction.md and sumcheck-stages.md pin references to b104dae, while the new chapter pins eea8443. Both predate the current compressed implementation, and they are divergent snapshots—not one coherent protocol state.
This already causes a concrete contradiction: hint is described as containing t̂, but current AkitaCommitmentHint stores recomposed semantic A rows plus outer-compression stages and quotients; t̂ is derived later.
Pin all references to one post-compression snapshot and revalidate every field/function mapping.

P3 — Documentation duplicates an existing canonical concept.

The long balanced-digit/gadget derivation duplicates foundations/gadget-decomposition.md. This conflicts with the repository’s “one durable fact in one place” policy. Make the foundations page authoritative and keep only the fold-specific substitutions here.

Additional gaps and cleanup

The extension-field evaluation section remains only a Status: stub, despite production support for extension-valued openings.
No advanced-layout/compression follow-up is linked, even though compression is now the default rather than an optional future extension.
The 802-line chapter includes a manually maintained contents list that duplicates mdBook navigation and increases drift risk.

@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.

Freya, thank you for putting this together. This is a substantial and genuinely useful addition to the book. The four-equation derivation is clear, the distinction between the physical opening relation and EvaluationTrace is especially helpful, and the prose gives us a strong foundation to build on.

I am requesting changes because the chapter currently presents the raw B/D payload layout as the current physical protocol, while the shipped root and early recursive folds use commitment compression. The core derivation does not need to be discarded: I think the clean revision is to call the four equations the semantic source relations, then document the raw and compressed physical realizations separately.

Before merge, please:

  1. Add the production compressed layout: F/H row families, zero ordinary B/D right-hand sides, terminal p_F/p_H payloads, compression digits and quotients in WitnessLayout, and the planner-selected monotone compressed-to-raw cutover.
  2. Update the Stage 2 implementation map to distinguish ordinary relation weights from the separate compact compression and negative-binary evaluators. EvaluationTrace remains correct as the tau1-weighted virtual row after every physical row.
  3. Refresh the code map against the current implementation. In compressed mode the verifier reconstructs the RHS with assemble_compressed_relation_rhs, RingRelationInstance::v() is empty, and AkitaCommitmentHint stores semantic inner rows plus compression material rather than a stored t_hat.
  4. Bring the related documentation lifecycle into this foundational PR. Please fold the shipped content from commitment-compression-cutover.md and relation-range-image-sumcheck.md into the book and mark/archive those specs according to docs/documentation.md. y-ring-trace-internalization.md should be marked historical and archived, not treated as an implementation requirement: its gamma-squared design is stale, while the current tau1 EvaluationTrace implementation is authoritative.
  5. Update opening-points-layout.md so its witness-tail description includes compressed layers, alignment, and compression quotient rows.

A few precise locations to revise:

  • akita-fold.md around the physical row table and equations 17–21: the stated count, RHS, and witness are the raw realization only.
  • sumcheck-stages.md in the Stage 2 implementation map: compressed F/H rows precede EvaluationTrace and use the separate compression evaluator.
  • akita-fold.md in the code-reference section: assemble_relation_rhs is the raw path; add assemble_compressed_relation_rhs and the terminal p_F/p_H flow.

This is a request to align a strong chapter with the shipped code, not a request to change the protocol. Once these points are addressed, I expect this to be a valuable and mergeable chapter.

@f7ed

f7ed commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

Thank you for the detailed review. I'll revise this chapter accordingly.

I want to confirm one organizational point about the commitment compression so that we are aligned. I have a follow-up PR 349 (#349) planned for the advanced relation layouts, covering multiple groups, multiple chunks, and mixed ring dimensions, and commitment compression, as extensions of the basic semantic relations introduced here.

Given the commitment compression has been the production protocol rather than just a feature, I will reframe the four equations as semantic relations and document both of their physical realizations: raw and compressed. I'll then keep PR 349 focused on multiple groups, multiple chunks, and mixed ring dimensions extended these semantic relations.

@quangvdao

Copy link
Copy Markdown

Sounds good, thanks! Where do you describe the evaluation trace relation btw?

@f7ed

f7ed commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

I finished it in PR 313 (#313), which had been merged. You can read it on page 2.5.1. sorry it's mixed with the sumcheck-stage page in the same PR.

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.

3 participants