Skip to content

Buffer Abstraction#263

Open
zkfriendly wants to merge 28 commits into
mainfrom
zkfr/buffer-abstraction
Open

Buffer Abstraction#263
zkfriendly wants to merge 28 commits into
mainfrom
zkfr/buffer-abstraction

Conversation

@zkfriendly

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces the buffer abstraction layer. All buffer abstraction traits are defined in the buffer crate (src/buffer/mod.rs), with a CPU implementation that essentially wraps the existing in-memory code paths.

At this moment, the buffer crate still depends on existing algebra and protocol crates. Future work can consolidate the relevant logic directly into the buffer crate as the abstraction settles.

Since the original review, the abstraction has been simplified substantially: the slice/view layer (BufferRead/BufferWrite, CpuSlice/CpuSliceMut) is removed in favor of two traits (BufferOps, Buffer) over owned buffers only. Host readbacks (as_slice) now occur only at transcript boundaries where the data must reach the host anyway.

Notes

There is also an experimental Metal implementation, but it is not included in this PR.

zk_whir is not fully ported to the buffer abstraction yet. It uses .as_slice() in places to keep the code working, so behavior is essentially unchanged compared to directly using CPU buffers. Since WHIR v3 is coming and is expected to replace zk_whir, that path is intentionally not fully ported for now.


Supersedes #260 (same branch, previously from my fork — GitHub cannot retarget a PR head, so reopened from the in-repo branch). Review history and comment threads are on #260.

@zkfriendly zkfriendly mentioned this pull request Jul 2, 2026
@zkfriendly zkfriendly requested a review from recmo July 2, 2026 06:34
@zkfriendly zkfriendly requested a review from Bisht13 July 2, 2026 06:34
@codspeed-hq

codspeed-hq Bot commented Jul 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 10 untouched benchmarks
⏩ 22 skipped benchmarks1


Comparing zkfr/buffer-abstraction (4840519) with main (655783c)

Open in CodSpeed

Footnotes

  1. 22 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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