Integrate buffer abstraction to Zook - #270
Conversation
…irect random buffer in tests
Merging this PR will not alter performance
Comparing Footnotes
|
33fbecf to
e0aec15
Compare
# Conflicts: # src/algebra/ntt/mod.rs # src/buffer/cpu.rs # src/buffer/mod.rs
Key changes include: - Introduction of a `Messages` struct to encapsulate interleaved Reed-Solomon messages, improving clarity and usability. - Refactoring of encoding functions to utilize the new `Messages` struct, allowing for better handling of message and mask buffers. - Updates to the `BufferMath` trait to include new methods for geometric accumulation and mixed matrix-vector products. - Removal of redundant code and improved type safety by leveraging the buffer abstraction in various protocols, including Zook and Sumcheck.
|
@shreyas-londhe ready for review |
|
@shreyas-londhe bumping this |
shreyas-londhe
left a comment
There was a problem hiding this comment.
Thanks for the PR! Overall looks correct, left some minor nits.
| fn interleaved_encode( | ||
| &self, | ||
| messages: Messages<'_, F>, | ||
| masks: &Buffer<F>, | ||
| codeword_length: usize, | ||
| ) -> Buffer<F>; |
There was a problem hiding this comment.
Pairing rules belong on the trait, not in irs_commit. This method now owns the message ‖ mask pairing that irs_commit::commit used to do, but the two orderings that make it well-defined aren't stated here, logical polynomial index is vector_index * interleaving_depth + chunk_index, and masks[i * mask_length + c] belongs to polynomial i. Both are currently documented only at irs_commit.rs:379-382, i.e. in one caller.
For a trait meant to be reimplemented by a GPU backend, that leaves a backend author guessing between vector-major and chunk-major flattening, with nothing asserting which they picked. Worth stating both on interleaved_encode (or on Messages).
b3187d8 to
8804e80
Compare
|
@BornPsych I addressed/resolved comments. The NTT interface changes are the bulk of the new diff. I originally planned the ntt interface refinement as a follow-up PR as mentioned in the description, but since we had comments here, I made the changes but we might want to iterate on the design. Next I'll update the provekit side changes |
Summary
This PR integrates the composable buffer abstraction from #266 into the current Zook, IRS, sumcheck, and code-switch protocol flow.
Once a witness is supplied as a
Buffer, witness-sized prover state remains resident through:commit → IRS/NTT → sumcheck → code-switch → subsequent rounds → basecaseThis removes the two main protocol-level host bounces:
message || maskpolynomials before the NTT.BufferandVecon every round.Transcript-, query-, and security-parameter-sized values intentionally remain host-side.
What changed
Buffer-native IRS/NTT boundary
poly_buf.message || maskordering and row-major(evaluation, polynomial)output are preserved.BufferandDefaultRsare selected together through one active backend module.Resident Zook state
Buffer.ProtocolConfig::commitconsumes an already-resident witness buffer.mixed_liftwithout host materialization.Buffer-native code-switch arithmetic
x⁰ = 1; OOD coefficients begin atx¹, and the in-domain run continues from there.Buffer capabilities
This PR adds or generalizes the operations required by the resident lane:
resize_zeroedmixed_liftmixed_mat_vecaccumulate_geometric(points, scalars, prefix_len)BufferOpsThe evaluator-object batching path and
UnivariateEvaluation::accumulate_manywere removed in favor of direct geometric accumulation.Transfer regression
A scoped regression checks that the resident IRS, Zook round, and code-switch paths do not reintroduce:
to_slice()into_vec()poly_bufconstructionCPU backend internals may still use slices.
Validation
cargo test— 257 passed, 30 ignoredcargo test --features rs_in_order— 267 passed, 30 ignoredcargo clippy --all-targets -- -D warningscargo clippy --all-targets --features rs_in_order -- -D warningsgit diff --checkReviewer focus
The most important invariants to review are:
message_chunk || mask_row.(evaluation_index, polynomial_index).[1, x, x², …].source.masked_message_length().Follow-ups
Replace the transitional IRS-specific
Messages + masksinterface with one validated segmented polynomial batch. Each ordered coefficient segment should describe its resident buffers, rows per buffer, and row width. This restores the abstraction that NTT sees logical polynomials rather than message/mask semantics without physically concatenating them.Replace the source-text transfer regression with an instrumented
AuditBackendthat counts uploads, downloads, synchronizations, and full-buffer transfers.