Skip to content
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

Merged
merged 2 commits into from
Sep 23, 2024
Merged

Conversation

jeanmon
Copy link
Contributor

@jeanmon jeanmon commented Sep 20, 2024

Resolves #8651

@jeanmon jeanmon marked this pull request as ready for review September 20, 2024 13:21
const size_t n = evaluation_points.size();
ASSERT(dim <= n);

std::span<const Fr, std::dynamic_extent> truncated_points = evaluation_points.first(dim);
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Contributor

@ledwards2225 ledwards2225 left a 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);
Copy link
Contributor

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.

@jeanmon jeanmon merged commit aa85f2a into master Sep 23, 2024
47 checks passed
@jeanmon jeanmon deleted the jm/8651-native-bounded-mle branch September 23, 2024 13:24
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.

Native bounded MLE
3 participants