-
Notifications
You must be signed in to change notification settings - Fork 178
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(avm): bounded mle implementation #8668
Conversation
noir-projects/noir-protocol-circuits/crates/types/src/constants.nr
Outdated
Show resolved
Hide resolved
const size_t n = evaluation_points.size(); | ||
ASSERT(dim <= n); | ||
|
||
std::span<const Fr, std::dynamic_extent> truncated_points = evaluation_points.first(dim); |
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.
Do you need to be explicit about dynamic extent? From https://en.cppreference.com/w/cpp/container/span it looks like it's the default, that'd mean you could do std::span<const Fr> truncated_points = evaluation_points.first(dim);
Also I wonder, do you need this function?
Cant you use the existing partial_evaluate_mle
or evaluate_mle
and create a span in the caller doing exactly std::span<const Fr> truncated_points = evaluation_points.first(dim);
and passing that?
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.
Sort of along the lines of what @fcarreiro is saying, I wonder if this should just become the default behavior of evaluate_mle. Instead of explicitly providing a dim
the function could just compute something like dim = msb(poly.start_offset() + size()) + 1
then perform the logic you've laid out here. This would in theory lead to even better efficiency unless your polys always have dim = AVM_PUBLIC_COLUMN_MAX_SIZE_LOG
. In this case your tests could compare two equivalent polys, one of which takes advantage of Adams new structured poly and one of which doesn't.
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.
@fcarreiro You are right, I will the remove the explicit std::dynamic_extent
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.
@ledwards2225 @fcarreiro I think it makes complete sense to adapt the standard evaluate_mle . It seems that this algorithm was ported from LegacyPolynomials which did not have the concept of virtual_size(). So, Polynomials class could not only leverage the memory gain (collapsing all tail zeros) but algorithmically whenever we can.
This way any caller would benefit from a "bounded" MLE. Using the constructor of Polynomials in a natural way, a caller would not oversize size() more than necessary.
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.
LGTM. Made a suggestion to simply make this the default behavior of evaluate_mle
with an auto computed dim
const size_t n = evaluation_points.size(); | ||
ASSERT(dim <= n); | ||
|
||
std::span<const Fr, std::dynamic_extent> truncated_points = evaluation_points.first(dim); |
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.
Sort of along the lines of what @fcarreiro is saying, I wonder if this should just become the default behavior of evaluate_mle. Instead of explicitly providing a dim
the function could just compute something like dim = msb(poly.start_offset() + size()) + 1
then perform the logic you've laid out here. This would in theory lead to even better efficiency unless your polys always have dim = AVM_PUBLIC_COLUMN_MAX_SIZE_LOG
. In this case your tests could compare two equivalent polys, one of which takes advantage of Adams new structured poly and one of which doesn't.
3d9893a
to
f7a37e8
Compare
f7a37e8
to
1651b2a
Compare
1651b2a
to
21b09fc
Compare
Resolves #8651