Skip to content

fix: stream verifier setup-prefix preprocessing - #59

Closed
RadNi wants to merge 7 commits into
taghi/akita-verifier-preprocessingfrom
codex/stream-verifier-setup-prefixes
Closed

RadNi wants to merge 7 commits into
taghi/akita-verifier-preprocessingfrom
codex/stream-verifier-setup-prefixes

Conversation

@RadNi

@RadNi RadNi commented Oct 25, 2026

Copy link
Copy Markdown

Generate missing setup-prefix commitments directly from Akita's public seed, then expand only the matrix retained by the verifier. This removes the large temporary generation matrix and truncation copy while preserving cached-prefix reuse.

Update Akita to codex/share-setup-prefix-storage, locked to e7771934, and adapt coefficient-packing callers and fixtures to its table API.

Validation:

  • All 107 jolt-akita tests passed.
  • Formatting, style invariants, and Clippy with warnings denied passed.
  • Measured peak RSS through AkitaVerifierResources::prepare: approximately 0.97 GiB for the 2^30 trace input and 1.07 GiB for the full GPU coverage set of 362 prefix slots.

mtbadakhshan and others added 3 commits October 23, 2026 16:40
…head of proofs

A deserialized verifier setup filled its serde-skipped cache on first use by
running Akita's full prover setup, per setup value, with nothing shared.
Derive verifier state from the public seed at verifier size instead and share
it: unprepared setups attach to a process-wide state that grows on a miss, and
hosts can build it before any proof with AkitaVerifierResources::prepare.
GroupedCatalog classifies grouped requests and plans missing rows once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…resource tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

📏 PR diff

Note

Actual code changed: 77 lines

🟢 +30 added    🔴 −47 removed

Tests, docs, fixtures, and helper scripts excluded.

Category 🟢 Added 🔴 Removed
⌨️ Actual code +30 −47
🧪 Tests +7 −4
📚 Docs +2 −2
📦 Fixtures +28 −16
🔧 Helper scripts 0 0
Total diff +67 −69

Every changed line is classified once.

@github-actions github-actions Bot added the no-spec PR has no spec file label Oct 25, 2026
@mtbadakhshan
mtbadakhshan force-pushed the taghi/akita-verifier-preprocessing branch 3 times, most recently from 6518253 to 8d6b8f8 Compare October 27, 2026 19:01
mtbadakhshan and others added 4 commits October 27, 2026 13:39
…#2136)

* feat(jolt-akita): share verifier state across setups and prepare it ahead of proofs

A deserialized verifier setup filled its serde-skipped cache on first use by
running Akita's full prover setup, per setup value, with nothing shared.
Derive verifier state from the public seed at verifier size instead and share
it: unprepared setups attach to a process-wide state that grows on a miss, and
hosts can build it before any proof with AkitaVerifierResources::prepare.
GroupedCatalog classifies grouped requests and plans missing rows once.

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

* style(jolt-akita): import the commitment and proof types in verifier resource tests

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

* refactor(jolt-akita): share verifier state only through prepared states

- Remove lazy growth, the growth lock and state merging. `prepare` builds a
  state once; a setup attaches to the smallest live state that covers it, or
  builds unpublished verifier-sized state of its own with no lock held.
- Reject a group wider than the batch before building anything.
- Size every catalog in a state at the state's capacity, so each verifier holds
  the prefix slots of every row it admits; take the slots from Akita's
  `SetupRequirements::from_catalog`.
- Restate why binding the setup dimensions and catalog digest suffices.
- Drop `GroupedCatalog` and grouped admission; `schedule_registry` and
  `one_hot_family` are unchanged from main.

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

* fix(jolt-akita): tie prepared-state lifetime to its handle and coverage to its capacity

- Drop the backend cache's owner reference: a state is attachable only while
  an `AkitaVerifierResources` handle holds it, and ties go to the newest
  state. Mark the handle `#[must_use]`.
- A state covers a setup with identical catalog bytes that fits the state's
  capacity, the capacity every catalog in it is provisioned at. Capacity is
  computed once, over all setups, and a state keeps one setup per catalog.
- Snapshot live states under the registry lock and compare catalogs after
  releasing it, dimensions before bytes.
- Test a proof whose selected row has a setup-prefix fold, through an
  unprepared transported setup and one attached to a wider prepared state;
  drop the transported/in-process key-equality assertion.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…sable memory, Tier 1) (a16z#2132)

* fix(tracer): record sub-doubleword MMU accesses against the containing doubleword

trace_load recorded the 4-byte floor of the effective address with an
8-byte value read from it, so a load in the upper half of a doubleword
recorded bytes of the next one. The byte and halfword store records merged
32-bit masks into the 8-byte pre-value, zeroing its upper half, and
store_word recorded the raw value as the whole post-value. Every access now
records its containing doubleword, the unit the RAM argument tracks, with
only the stored lane changed.

These records come only from the source-level reference execution, since
sub-word sources always expand before tracing, so proofs are unaffected.
This closes the masked MMU defects listed in a16z#2013's acceptance criteria.

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

* feat(memory)!: floor-addressed sub-word loads and stores (byte-addressable memory, Tier 1)

Implements Tier 1 of specs/byte-addressable-memory.md (a16z#2013). The memory
row's otherwise idle lookup slot carries the intra-doubleword offset, so no
sub-word access or word AMO materializes an aligned address or spends rows
on alignment asserts.

Protocol
- R1CS constraint 0 becomes (Load + Store)·(RamAddress − Rs1Value − Imm +
  LookupOutput) = 0 (RamAddrEqRs1PlusImmMinusLookupIfLoadStore), and the
  optimized Spartan outer kernel's hand-copied row gains the same term. LD
  and SD look up no table, so their RamAddress is unchanged; a
  floor-addressed row's RamAddress is the doubleword it accesses. RAF
  evaluation, BlindFold, Akita and the opening set are untouched: the
  offset enters this row instead of the spec's OffsetOrZero product wire.
- New AddressOffset{B,H,W} tables output ea & 7, ea & 6 and ea & 4. A
  misaligned access leaves a low bit in RamAddress, which RAF evaluation
  rejects because every 8k + lowest_address is a multiple of 8; the
  verifier now rejects a memory layout whose lowest_address is not
  8-aligned. Unlike the spec's +2^32 marker, this needs no bound on guest
  addresses.
- AlignAddr, HalfwordAlignment and WordAlignment lose their last users and
  are deleted, which renumbers the later LookupTableKind indices. The table
  count (55) and the committed bytecode width (462 of 512 lanes) end where
  main has them.

Instructions and sequences
- VirtualLoad{B,H,W} / VirtualStore{B,H,W} (tags 0x00a2-0x00a7) access the
  doubleword containing rs1 + imm, keeping the signed immediate that
  constraint 0 reads.
- LB/LBU 4 -> 3 rows, LH/LHU/LW/LWU 5 -> 3, SB 8 -> 6, SH/SW 9 -> 6.
  VirtualShiftData{B,H,W} read their effective address as rs2 + imm (both
  right-operand flags), which drops the store's address ADDI.
- Word AMOs use the same lane rows: AMOADD/AND/OR/XOR.W 19 -> 9 rows,
  AMOSWAP.W 18 -> 8, AMOMIN[U]/AMOMAX[U].W 24 -> 13.
- VirtualAlignAddr, VirtualAssertHalfwordAlignment and
  VirtualAssertWordAlignment have no callers left; tags 0x009a, 0x0065 and
  0x0066 are retired.
- The tracer, x86 AOT backend, z3 model and Lean generator support the new
  rows and drop VirtualAssertWordAlignment with its FormatAssert format; the
  expansion builder's address-form template and the public
  InlineExpansionBuilder::emit_align, which had no callers, go too. A
  misaligned halfword or word access, word AMOs included, still aborts the
  trace.

Measured at scale-20 inputs: btreemap -4.99% trace rows, sha2-chain -2.84%,
sha3-chain -0.13%, fibonacci -0.01%; prover time is at parity within the
unchanged 2^20 padded size.

Tests: the memory-ops guest covers every width at every aligned offset with
negative and non-negative immediates against a host byte-array model;
misaligned_memory.rs traces each misaligned LH/LHU/LW/LWU/SH/SW through a
test-utils tracer hook and checks that the witness satisfies R1CS but the
stage-2 batch rejects it. z3 proves every word AMO sequence correct and
consistent against a lane-level model of the A extension. Registry tests pin which tables memory
rows may use and each floor row's table to RISC-V natural alignment. The
expansion golden fixture (bless with JOLT_UPDATE_EXPANSION_FIXTURES=1) moved
exactly the 129 sub-word, LR.W/SC.W and word-AMO cases; the verifier fuzz
bundles are regenerated and FIXTURE_MAGIC is bumped.

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

* fix(jolt-program): reject inline load and store offsets outside 12 bits

R1CS constraint 0 forms RamAddress from the unwrapped Rs1Value + Imm,
while the tracer wraps the effective address mod 2^64. Decoded loads
and stores carry signed 12-bit offsets, so an access whose sum carries
lands within 2 KiB of 0 or 2^64, outside the memory layout. The public
inline builder takes i64 offsets, though, so an inline could wrap into
mapped memory and leave an access the tracer runs unprovable: LBU with
rs1 = u64::MAX and offset 0x8000_1001 reads 0x8000_1000. On main the
narrow widths formed the address with wrapping lookups (AlignAddr for
loads, ADDI for stores), while carrying inline LD/SD were already
unprovable.

materialize_inline now rejects any Load- or Store-flagged row whose
offset is outside [-2048, 2047], with
ExpansionError::InlineMemoryOffsetOutOfRange. The bound is static, so
it also rejects wider offsets that do not carry, which main proved. No
shipped inline uses one; the largest in-tree offset is 192. An inline
that needs a farther address computes it into an inline register.

The constraint-0 NOTE records the completeness argument and its one
exception: a load that carries into the no-access zero doubleword runs,
since the tracer reads it as 0, but cannot be proven. The builder docs,
the spec and the book's inline guide state the limit.

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

* test(jolt-verifier): re-golden the muldiv BlindFold shape after main's guest memcpy

main's a16z#2142 links an accelerated memcpy/memmove into every riscv64 guest.
Together with Tier 1's shorter sub-word load and store sequences, it takes
the muldiv guest below 512 cycles, so the ZK fixture's trace length halves
to 512 and each of the six sumchecks over the cycle variables loses one
round: 227 BlindFold coefficient rows become 221. ram_K and the other row
counts are unchanged.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@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 27, 2026
@RadNi RadNi closed this Oct 31, 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