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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
@@ -295,6 +295,7 @@ global AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS: u32 = 2 + 16 * 4;
// To determine latest value, hover `COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS`
// in barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp
global AVM_PROOF_LENGTH_IN_FIELDS: u32 = 3817;
global AVM_PUBLIC_COLUMN_MAX_SIZE_LOG = 8;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhhh this LOG is from Logarithm, right? I was confused for a while thinking about (unencrypted) logs. Maybe use LOG2 or LOGARITHM?

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

@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.

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