-
Notifications
You must be signed in to change notification settings - Fork 598
feat: conventional lookups using log-deriv #7020
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
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
60f2b1b
some initial comments and cleanup
ledwards2225 760a9fb
some naming updates and comments
ledwards2225 5005403
more comments
ledwards2225 2ce44bd
another comment
ledwards2225 205a1e4
table read counts seems to be working
ledwards2225 5d2237d
update and add read tags to method
ledwards2225 856fbfb
add counts and tags to flavor and oink, tests pass
ledwards2225 f8cdcb9
construct counts at bottom of trace to match tables
ledwards2225 bcdc1a7
relation code in place, not tested yet
ledwards2225 e00d618
add (fake) lookup inverses to proof system, tests pass
ledwards2225 8d76a3c
compute genuine inverses; relation correctness fails though
ledwards2225 1a12f9d
relation correctness passes for ultra and Mega
ledwards2225 a66e0c6
use inheritance for getters
ledwards2225 76743f4
Merge branch 'master' into lde/log_deriv_lookups
ledwards2225 ed7cdbe
fix build
ledwards2225 b90989c
fix bad template alias
ledwards2225 6da8c4d
use ultra in ultra recursive
ledwards2225 bd8903a
update transcript tests
ledwards2225 50b53b9
update pg and ultra rec verifiers
ledwards2225 97ecc40
add lookup polys to verifier commitments for ultra
ledwards2225 6d95dbe
fix ultra rec flavor
ledwards2225 a84bb75
use ultra sizes in rec ultra flav
ledwards2225 3aa43c6
turn on log deriv lookups in the flavors
ledwards2225 e728e8a
remove pi folding and add a test
ledwards2225 cf8e0a0
remove pi folding from verifier as well
ledwards2225 46b70ba
test cleanup
ledwards2225 4dfd415
remove lookup relation and all its paraphernalia
ledwards2225 5886ee9
Merge branch 'master' into lde/log_deriv_lookups
ledwards2225 7f93c26
use etas instead of betas, add subrel additional offsets
ledwards2225 f79aedb
Merge branch 'master' into lde/log_deriv_lookups
ledwards2225 019c268
fix sumcheck test
ledwards2225 a37fa4f
move sorted poly method to plonk only lib
ledwards2225 32ecdd3
add skip condition
ledwards2225 1f3fc15
update honk proof data for acir recursion
ledwards2225 40191a7
comments and cleanup
ledwards2225 f706150
clean up test and add todo
ledwards2225 3a5c42e
failure tests
ledwards2225 cd2da7a
more failure tests and some cleanup
ledwards2225 c36266c
fix build and cleanup
ledwards2225 f74ceff
min circuit size due to lookups is only based on tables now
ledwards2225 dc883bb
lots of cleanup
ledwards2225 1940724
Merge branch 'master' into lde/log_deriv_lookups
ledwards2225 0b83848
add op count timer to new lookup relation
ledwards2225 407b664
Merge branch 'master' into lde/log_deriv_lookups
ledwards2225 810a110
revert lookups size change
ledwards2225 67f76cc
Merge branch 'lde/log_deriv_lookups' of github.com:AztecProtocol/azte…
ledwards2225 65ba681
Merge branch 'master' into lde/log_deriv_lookups
ledwards2225 8c5fe0c
circuit checker failure test
ledwards2225 0d4032d
comments and cleanup based on review
ledwards2225 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
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
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
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
2 changes: 1 addition & 1 deletion
2
barretenberg/cpp/src/barretenberg/plonk_honk_shared/CMakeLists.txt
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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| barretenberg_module(plonk_honk_shared polynomials) | ||
| barretenberg_module(plonk_honk_shared polynomials ultra_honk) |
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
75 changes: 66 additions & 9 deletions
75
barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/composer_lib.test.cpp
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 |
|---|---|---|
| @@ -1,21 +1,78 @@ | ||
| #include "barretenberg/plonk_honk_shared/composer/composer_lib.hpp" | ||
| #include "barretenberg/common/slab_allocator.hpp" | ||
| #include "barretenberg/plonk_honk_shared/types/circuit_type.hpp" | ||
| #include "barretenberg/srs/factories/crs_factory.hpp" | ||
| #include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" | ||
| #include "barretenberg/stdlib_circuit_builders/ultra_flavor.hpp" | ||
|
|
||
| #include <array> | ||
| #include <gtest/gtest.h> | ||
|
|
||
| using namespace bb; | ||
|
|
||
| class ComposerLibTests : public ::testing::Test { | ||
| public: | ||
| using Flavor = UltraFlavor; | ||
| using FF = typename Flavor::FF; | ||
|
|
||
| protected: | ||
| static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } | ||
| }; | ||
|
|
||
| /** | ||
| * @brief A test to demonstrate that lookup read counts/tags are computed correctly for a simple 'hand-computable' case | ||
| * using the uint32 XOR table | ||
| * | ||
| */ | ||
| TEST_F(ComposerLibTests, LookupReadCounts) | ||
| { | ||
| using Builder = UltraCircuitBuilder; | ||
| using Flavor = UltraFlavor; | ||
| using FF = typename Flavor::FF; | ||
| Flavor::CircuitBuilder circuit_constructor; | ||
| Flavor::ProvingKey proving_key = []() { | ||
| auto crs_factory = srs::factories::CrsFactory<bb::curve::BN254>(); | ||
| auto crs = crs_factory.get_prover_crs(4); | ||
| return Flavor::ProvingKey(/*circuit_size=*/8, /*num_public_inputs=*/0); | ||
| }(); | ||
| }; | ||
| using Polynomial = typename Flavor::Polynomial; | ||
| auto UINT32_XOR = plookup::MultiTableId::UINT32_XOR; | ||
|
|
||
| Builder builder; | ||
|
|
||
| // define some very simply inputs to XOR | ||
| FF left{ 1 }; | ||
| FF right{ 5 }; | ||
|
|
||
| auto left_idx = builder.add_variable(left); | ||
| auto right_idx = builder.add_variable(right); | ||
|
|
||
| // create a single lookup from the uint32 XOR table | ||
| auto accumulators = plookup::get_lookup_accumulators(UINT32_XOR, left, right, /*is_2_to_1_lookup*/ true); | ||
| builder.create_gates_from_plookup_accumulators(UINT32_XOR, accumulators, left_idx, right_idx); | ||
|
|
||
| EXPECT_EQ(builder.lookup_tables.size(), 1); // we only used a single table | ||
| EXPECT_EQ(builder.lookup_tables[0].size(), 4096); // table has size 64*64 (6 bit operands) | ||
|
|
||
| size_t circuit_size = 8192; | ||
|
|
||
| Polynomial read_counts{ circuit_size }; | ||
| Polynomial read_tags{ circuit_size }; | ||
|
|
||
| construct_lookup_read_counts<Flavor>(read_counts, read_tags, builder, circuit_size); | ||
|
|
||
| // The table polys are constructed at the bottom of the trace, thus so to are the counts/tags | ||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/1033): construct tables and counts at top of trace | ||
| size_t offset = circuit_size - builder.get_tables_size(); | ||
|
|
||
| // The uint32 XOR lookup table is constructed for 6 bit operands via double for loop that iterates through the left | ||
| // operand externally (0 to 63) then the right operand internally (0 to 63). Computing (1 XOR 5) will thus result in | ||
| // 1 lookup from the (1*64 + 5)th index in the table and 5 lookups from the (0*64 + 0)th index (for the remaining 5 | ||
| // limbs that are all 0). The counts and tags at all other indices should be zero. | ||
| size_t idx = 0; | ||
| for (auto [count, tag] : zip_view(read_counts, read_tags)) { | ||
| if (idx == (0 + offset)) { | ||
| EXPECT_EQ(count, 5); | ||
| EXPECT_EQ(tag, 1); | ||
| } else if (idx == (69 + offset)) { | ||
| EXPECT_EQ(count, 1); | ||
| EXPECT_EQ(tag, 1); | ||
| } else { | ||
| EXPECT_EQ(count, 0); | ||
| EXPECT_EQ(tag, 0); | ||
| } | ||
| idx++; | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.