-
Notifications
You must be signed in to change notification settings - Fork 234
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
feat(bb): towards reduced polynomial memory usage #7990
Merged
Merged
Changes from all commits
Commits
Show all changes
165 commits
Select commit
Hold shift + click to select a range
88cb0b4
feat(bb): debug log
ludamad0 3714e2e
Debug log
ludamad0 3ddc166
Merge remote-tracking branch 'origin/master' into ad/feat/bb-debug-log
ludamad0 67de114
Update debug_log.cpp
ludamad 9421093
Update debug_log.cpp
ludamad b2cb0d8
format
ludamad0 ac72179
debugs
ludamad0 e3b8713
empty polys
ludamad0 f9ce86b
fix(ci): correctly run bb tests with asserts
ludamad d528cc0
Merge branch 'master' into ad/bb/enable/asserts
ludamad 428f0de
remove unneeded assert
ludamad 30c8e5c
pass on polynomial memory representation
ludamad 496fdae
Merge branch 'master' into ad/mem-offsets
ludamad f9c7931
passing tests
ludamad 1552197
Merge remote-tracking branch 'origin/ad/mem-offsets' into ad/mem-offsets
ludamad 4f1e519
more refactoring
ludamad eaa6a34
start of actually using new polynomial structure
ludamad 50f59fe
progress
ludamad d79914e
poly iter class
ludamad d83219e
more polynomial related boilerplate...
ludamad cdeedc6
polynomial span checkpoint
ludamad 24b35f3
poly arith fix
ludamad a3d18fb
checkpoint
ludamad 23ff433
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad 45ee50d
progress
ludamad b3868e2
Merge branch 'master' into ad/bb/enable/asserts
ludamad b6f6968
Merge remote-tracking branch 'origin/master' into ad/bb/enable/asserts
ludamad f3a7f60
assert-friendly tests: AztecIVC
ludamad 8e4ece7
ensure converted points are on curve
ludamad 35fa784
poly test fix
ludamad 5f347ca
fix the last of the asserts hopefully
ludamad da1baa9
Merge remote-tracking branch 'origin/ad/bb/enable/asserts' into ad/bb…
ludamad d0b3918
Merge remote-tracking branch 'origin/master' into ad/bb/enable/asserts
ludamad 99d672a
constify pippenger
ludamad ebf2a90
Merge branch 'ad/bb/enable/asserts' into ad/mem-offsets
ludamad 6a6795e
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad 5561f67
Try to get ultrahonk tests working
ludamad 109146b
push to see tests
ludamad bbc3b84
Merge branch 'master' into ad/mem-offsets
ludamad 55ded5b
debug
ludamad 549edb2
asan fixes for big woops's
ludamad 98bc35c
Merge remote-tracking branch 'origin/ad/feat/bb-debug-log' into ad/me…
ludamad abff423
Progress
ludamad 7fba8bd
Progress
ludamad a8023b0
more logs
ludamad 0869084
ultra honk tests working
ludamad 70d194e
wires
ludamad 6932aac
Merge remote-tracking branch 'origin/ad/mem-offsets' into ad/mem-offsets
ludamad 195d845
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad 8698df4
cleanup
ludamad 15d9184
eliminate .set()
ludamad 44bd924
all compiling
ludamad e682488
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad 88c0c28
refactor
ludamad ede7f41
eccvm fix
ludamad 44c7f78
zero initialization
ludamad fdd2b29
tedious test updates
ludamad e0e0153
finall translator working again
ludamad 95022c2
Merge branch 'master' into ad/mem-offsets
ludamad 81503b3
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad 9623ecf
building again
ludamad 5e99416
building
ludamad 2770bcc
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad 65f76b0
avm building
ludamad 6ce46c4
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad d3a4498
revert
ludamad d63fea1
remove unshifted and pray
ludamad 73fa590
comment on shfits
ludamad 5616be3
remove redundant pippenger param
ludamad bce13aa
Merge remote-tracking branch 'origin/ad/pippenger-edge-case-smoothing…
ludamad 57d4d81
speed up non powers of 2 in pippenger
ludamad 956a794
Merge remote-tracking branch 'origin/ad/pippenger-edge-case-smoothing…
ludamad cac72b1
rounding up to power of 2
ludamad bb6b7cc
fix commitmentkey: rounding up to power of 2
ludamad d6d08d0
comment
ludamad 4a871b2
comment and use new pippenger
ludamad cf62795
comment and use new pippenger
ludamad 01efa1f
working
ludamad 5c8418a
revert
ludamad cb8f5e6
revert
ludamad 536ebbe
std span
ludamad 528142a
revert
ludamad c371e37
Update scalar_multiplication.cpp
ludamad 069c007
Merge remote-tracking branch 'origin/ad/pippenger-edge-case-smoothing…
ludamad b1d4b79
merge
ludamad 84d7b74
random poly compile issue
ludamad 94e6df3
Update scalar_multiplication.cpp
ludamad 7dc942b
Update scalar_multiplication.cpp
ludamad 25f64be
Update scalar_multiplication.cpp
ludamad bf21caf
Update scalar_multiplication.hpp
ludamad 1b16007
compile fix
ludamad 55758d0
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad 485d627
Merge branch 'master' into ad/pippenger-edge-case-smoothing
ludamad 39a9525
fix scalar mul edge cases. woops, tried to be too clever
ludamad 47c7736
Merge remote-tracking branch 'origin/ad/pippenger-edge-case-smoothing…
ludamad 84cb602
Merge remote-tracking branch 'origin/ad/pippenger-edge-case-smoothing…
ludamad 00981cb
remote lock improvement
ludamad 686c4a5
Merge branch 'master' into ad/pippenger-edge-case-smoothing
ludamad c3e37c5
speculative fix
ludamad ac15f5b
Merge remote-tracking branch 'origin/ad/pippenger-edge-case-smoothing…
ludamad 7dae750
better error
ludamad a9c2617
fix edge case causing srs size too big
ludamad 49fa0ad
Merge remote-tracking branch 'origin/ad/pippenger-edge-case-smoothing…
ludamad e791c97
revert
ludamad 2be10cd
revert
ludamad 6386e95
format
ludamad 34425ea
Merge branch 'master' into ad/mem-offsets
ludamad 70f03c5
format
ludamad 7e518f8
Merge branch 'ad/pippenger-edge-case-smoothing' into ad/mem-offsets
ludamad 80d568b
Merge remote-tracking branch 'origin/ad/mem-offsets' into ad/mem-offsets
ludamad 06c61cd
adjustment
ludamad dd7e461
fix gcc complain
ludamad d720c55
fix size compare
ludamad e55bb85
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad 1d306e8
merge and notes
ludamad 52027b3
Merge branch 'ad/mem-offsets-structure-spike' into ad/mem-offsets
ludamad 782f472
use format
ludamad 971a388
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad 7dbd1d9
format
ludamad f5514c3
compile fix
ludamad 41c01c6
Merge remote-tracking branch 'origin/ad/mem-offsets' into ad/mem-offsets
ludamad 7f4ea77
[skip ci]
ludamad e5bcec1
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad d1c7702
updates
ludamad 1457a3c
Merge local stash
ludamad e307d13
work on structured polys
ludamad 5bbff94
reverts
ludamad c70ef6f
niceness
ludamad 0f0b86f
Basic index_values() test
ludamad c81ec3b
remove merge markers
ludamad 4192629
fix zip view
ludamad 0e6c1b6
ultra honk test fixes
ludamad 200a243
Merge branch 'master' into ad/mem-offsets
ludamad 9573c93
Merge
ludamad 2c6a6c6
Merge branch 'ad/fake-base-mem-offsets' into ad/mem-offsets
ludamad 4a2e3a8
Merge remote-tracking branch 'origin/ad/mem-offsets' into ad/mem-offsets
ludamad f5b430e
revert
ludamad 27f1d36
revert
ludamad 2646dbc
revert
ludamad f51042a
Merge branch 'ad/fake-base-mem-offsets' into ad/mem-offsets
ludamad 44dd297
revert
ludamad e72cdbd
repair
ludamad 95e1c5e
repair
ludamad 60d111d
built
ludamad 8bb094d
more test fixes
ludamad 4e9e400
avm fix
ludamad 6047855
better verbosity
ludamad e16f609
avm changes, get_row investigation
ludamad 7befd6d
at() usage in get_row
ludamad f0e9ecd
test
ludamad 964384c
fix
ludamad b2a5423
remove unneeded leftover BB_UNUSED
ludamad bd0b6dc
remove copypasta test
ludamad a4f34cb
commitment_schemes_tests working
ludamad e1d8f4d
commitment recursion tests
ludamad 8f5af24
remove const_at, vm tests green
ludamad 0b69ca6
last fixes(?)
ludamad 5efcd7e
Merge remote-tracking branch 'origin/master' into ad/mem-offsets
ludamad be4a79e
avm redo
ludamad 8adb0b6
fix relation tests
ludamad 213cc28
fix plonk_honk_shared_tests
ludamad a45ab52
try fix
ludamad 72d286c
format [skip ci]
ludamad 92926cf
revert
ludamad 0ffcee2
Crs fix
ludamad 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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -7,10 +7,12 @@ | |
* simplify the codebase. | ||
*/ | ||
|
||
#include "barretenberg/common/debug_log.hpp" | ||
#include "barretenberg/common/op_count.hpp" | ||
#include "barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp" | ||
#include "barretenberg/numeric/bitop/get_msb.hpp" | ||
#include "barretenberg/numeric/bitop/pow.hpp" | ||
#include "barretenberg/polynomials/polynomial.hpp" | ||
#include "barretenberg/polynomials/polynomial_arithmetic.hpp" | ||
#include "barretenberg/srs/factories/crs_factory.hpp" | ||
#include "barretenberg/srs/factories/file_crs_factory.hpp" | ||
|
@@ -79,20 +81,29 @@ template <class Curve> class CommitmentKey { | |
* @param polynomial a univariate polynomial p(X) = ∑ᵢ aᵢ⋅Xⁱ | ||
* @return Commitment computed as C = [p(x)] = ∑ᵢ aᵢ⋅Gᵢ | ||
*/ | ||
Commitment commit(std::span<const Fr> polynomial) | ||
Commitment commit(PolynomialSpan<const Fr> polynomial) | ||
{ | ||
BB_OP_COUNT_TIME(); | ||
// See constructor, we must round up the number of used srs points to a power of 2. | ||
const size_t consumed_srs = numeric::round_up_power_2(polynomial.size()); | ||
// We must have a power-of-2 SRS points *after* subtracting by start_index. | ||
const size_t consumed_srs = numeric::round_up_power_2(polynomial.size()) + polynomial.start_index; | ||
auto srs = srs::get_crs_factory<Curve>()->get_prover_crs(consumed_srs); | ||
// We only need the | ||
if (consumed_srs > srs->get_monomial_size()) { | ||
info("Attempting to commit to a polynomial that needs ", | ||
consumed_srs, | ||
" points with an SRS of size ", | ||
srs->get_monomial_size()); | ||
ASSERT(false); | ||
throw_or_abort(format("Attempting to commit to a polynomial that needs ", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the utility of continuing on after realizing this size is not enough. Actually, there is security risk whenever we knowingly read past allocated memory. |
||
consumed_srs, | ||
" points with an SRS of size ", | ||
srs->get_monomial_size())); | ||
} | ||
return scalar_multiplication::pippenger_unsafe_optimized_for_non_dyadic_polys<Curve>( | ||
polynomial, srs->get_monomial_points(), pippenger_runtime_state); | ||
|
||
// Extract the precomputed point table (contains raw SRS points at even indices and the corresponding | ||
// endomorphism point (\beta*x, -y) at odd indices). We offset by polynomial.start_index * 2 to align | ||
// with our polynomial span. | ||
std::span<G1> point_table = srs->get_monomial_points().subspan(polynomial.start_index * 2); | ||
DEBUG_LOG_ALL(polynomial.span); | ||
Commitment point = scalar_multiplication::pippenger_unsafe_optimized_for_non_dyadic_polys<Curve>( | ||
polynomial.span, point_table, pippenger_runtime_state); | ||
DEBUG_LOG(point); | ||
return point; | ||
}; | ||
|
||
/** | ||
|
@@ -105,19 +116,20 @@ template <class Curve> class CommitmentKey { | |
* @param polynomial | ||
* @return Commitment | ||
*/ | ||
Commitment commit_sparse(std::span<const Fr> polynomial) | ||
Commitment commit_sparse(PolynomialSpan<const Fr> polynomial) | ||
{ | ||
BB_OP_COUNT_TIME(); | ||
const size_t degree = polynomial.size(); | ||
ASSERT(degree <= srs->get_monomial_size()); | ||
const size_t poly_size = polynomial.size(); | ||
ASSERT(polynomial.end_index() <= srs->get_monomial_size()); | ||
|
||
// Extract the precomputed point table (contains raw SRS points at even indices and the corresponding | ||
// endomorphism point (\beta*x, -y) at odd indices). | ||
std::span<G1> point_table = srs->get_monomial_points(); | ||
// endomorphism point (\beta*x, -y) at odd indices). We offset by polynomial.start_index * 2 to align | ||
// with our polynomial spann. | ||
std::span<G1> point_table = srs->get_monomial_points().subspan(polynomial.start_index * 2); | ||
|
||
// Define structures needed to multithread the extraction of non-zero inputs | ||
const size_t num_threads = degree >= get_num_cpus_pow2() ? get_num_cpus_pow2() : 1; | ||
const size_t block_size = degree / num_threads; | ||
const size_t num_threads = poly_size >= get_num_cpus_pow2() ? get_num_cpus_pow2() : 1; | ||
const size_t block_size = poly_size / num_threads; | ||
std::vector<std::vector<Fr>> thread_scalars(num_threads); | ||
std::vector<std::vector<G1>> thread_points(num_threads); | ||
|
||
|
@@ -128,7 +140,7 @@ template <class Curve> class CommitmentKey { | |
|
||
for (size_t idx = start; idx < end; ++idx) { | ||
|
||
const Fr& scalar = polynomial[idx]; | ||
const Fr& scalar = polynomial.span[idx]; | ||
|
||
if (!scalar.is_zero()) { | ||
thread_scalars[thread_idx].emplace_back(scalar); | ||
|
This file contains 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 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.
snuck in this, some waiting logic so you can start multiple benchmarks and walk away