Repository navigation
Separate Bit Transpose from Bittable #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xrvdg
wants to merge
23
commits into
main
Choose a base branch
from
xr/bittable
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f869b88
common: back BitTable with a machine-sized Word instead of F128
xrvdg e6a2e4c
common: rename ColumnBits to BitsIter
xrvdg dd89f3f
common: generalise BitsIter into StepIter yielding S-bit chunks
xrvdg 448fe41
common: transpose BitTable via word-level 64x64 bit block transpose
xrvdg 0abcaf0
common: add a test-only transpose_reference and drop F128 packing con…
xrvdg d626b3d
common: let bit_block_transpose handle dim1-row tiles and test d = 4
xrvdg e5543a0
common: support any power-of-two dim1 in bit_transpose
xrvdg b8418a6
common: reduce bit_transpose_blocks to a single butterfly sweep
xrvdg 5b37d62
common: compute butterfly masks inline instead of precomputing them
xrvdg f891e96
common: add divan benchmark of bit_transpose against the reference
xrvdg 2d7fe1e
fixup! common: add divan benchmark of bit_transpose against the refer…
xrvdg b0340d2
common: make BitTable generic over its storage and replace Transposed…
xrvdg 403e34a
fixup! common: add divan benchmark of bit_transpose against the refer…
xrvdg 8f8c5e5
common: switch Word to u128 and rotate bit indices ahead of coarse-to…
xrvdg 435d745
common: run in-lane bit index rotation swaps on u64 lanes so they vec…
xrvdg c56514d
common: replace bit_transpose's derivation comment with a short doc c…
xrvdg 783a529
common: move the t >= 7 gate from Shape to BitZParams behind a WordCo…
xrvdg f8405bc
fixup! common: move the t >= 7 gate from Shape to BitZParams behind a…
xrvdg 706a2ae
gkr: move leaf construction into GrandProductCircuit::new, taking row…
xrvdg 336e809
common: split BitTable into a shaped BitTable view and a geometry-onl…
xrvdg e1505fa
common: limit bit_transpose to whole 128x128 blocks and gate s < 7 in…
xrvdg 202028a
Merge remote-tracking branch 'origin/main' into xr/bittable
xrvdg f801684
common: replace BitTable::transpose with a borrowed as_matrix view an…
xrvdg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| //! Compare the blocked `bit_transpose` with the bit-at-a-time reference. | ||
| //! | ||
| //! Run with `cargo bench -p common --features bench --bench matrix`. | ||
| //! Both transpose a `128 x DIM2`-bit matrix (`dim2` contiguous), including | ||
| //! output allocation. Input generation runs outside the measured loop. | ||
|
|
||
| use common::matrix::bench::{bit_transpose, transpose_reference}; | ||
| use divan::counter::BytesCount; | ||
| use divan::{Bencher, black_box}; | ||
| use rand::rngs::StdRng; | ||
| use rand::{RngExt, SeedableRng}; | ||
|
|
||
| const DIM1: usize = 128; | ||
| /// `2^20` bits per row: a 16 MiB matrix, well past the last-level cache. | ||
| const DIM2: usize = 1 << 20; | ||
|
|
||
| fn main() { | ||
| let xs = input(); | ||
| assert_eq!( | ||
| bit_transpose(&xs, DIM1, DIM2), | ||
| transpose_reference::<DIM1>(&xs), | ||
| "bit_transpose disagrees with the reference" | ||
| ); | ||
| divan::main(); | ||
| } | ||
|
|
||
| /// Seeded so every run transposes the same matrix. | ||
| fn input() -> Vec<u128> { | ||
| let mut rng = StdRng::seed_from_u64(0); | ||
| (0..DIM1 * DIM2 / u128::BITS as usize) | ||
| .map(|_| rng.random()) | ||
| .collect() | ||
| } | ||
|
|
||
| #[divan::bench] | ||
| fn blocked(bencher: Bencher) { | ||
| let xs = input(); | ||
| bencher | ||
| .counter(BytesCount::of_slice(&xs)) | ||
| .bench(|| bit_transpose(black_box(&xs), DIM1, DIM2)); | ||
| } | ||
|
|
||
| #[divan::bench] | ||
| fn reference(bencher: Bencher) { | ||
| let xs = input(); | ||
| bencher | ||
| .counter(BytesCount::of_slice(&xs)) | ||
| .bench(|| transpose_reference::<DIM1>(black_box(&xs))); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI uses 128 for rows, and 1 << 20 columns, and I understand
DIM1here is the columns, in that case, this benchmark should haveDIM1 = 1 << 20andDIM2 = 128to represent realistic witnesses