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

Witgen: Pass range constraints separately #2451

Merged
merged 8 commits into from
Feb 6, 2025
Merged

Conversation

georgwiese
Copy link
Collaborator

@georgwiese georgwiese commented Feb 6, 2025

this PR changes the signature of Machine::process_plookup from

    fn process_plookup<'b, Q: QueryCallback<T>>(
        &mut self,
        mutable_state: &'b MutableState<'a, T, Q>,
        identity_id: u64,
        caller_rows: &'b RowPair<'b, 'a, T>,
    ) -> EvalResult<'a, T>;

To

    fn process_plookup<'b, Q: QueryCallback<T>>(
        &mut self,
        mutable_state: &'b MutableState<'a, T, Q>,
        identity_id: u64,
        parameters: &[AffineExpression<AlgebraicVariable<'a>, T>],
        range_constraints: &dyn RangeConstraintSet<AlgebraicVariable<'a>, T>,
    ) -> EvalResult<'a, T>;

Previously, each machine evaluated the parameters themselves, using the caller_rows and the calling bus send, stored in the connection. But in the future, the calling bus send will not be static, so I moved this to the caller.

This will enable #2447 and eventually the dynamic bus.

@georgwiese georgwiese marked this pull request as ready for review February 6, 2025 13:17
for (r, l) in identity.right.expressions.iter().zip(&outer_query.left) {
for (r, l) in identity
.right
.expressions
Copy link
Member

Choose a reason for hiding this comment

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

These are the parameters, I would say.

rows,
outer_query.left.first().unwrap(),
outer_query.range_constraints,
outer_query.parameters.first().unwrap(),
AlgebraicVariable::Column(column_reference),
);
}
Copy link
Member

Choose a reason for hiding this comment

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

Should we respect the range constraints in the rest of the code or is it just a hint? Please document in the trait function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what you mean. Document in Machine::process_plookup (when are we going to rename this haha)?

I think it would be nice to respect them and could even lead to a unique result when it's not unique just from the known values. But seems like it's not needed in practice. Seems a out of the scope of this PR to fix this.

Copy link
Member

Choose a reason for hiding this comment

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

ah true, because we get a single result anyway. ok!

connection: Connection<'a, T>,
) -> Result<Self, IncompleteCause<AlgebraicVariable<'a>>> {
// Evaluate once, for performance reasons.
Copy link
Member

Choose a reason for hiding this comment

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

What was this comment about?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That we don't want to evaluate to an affine expression many times. Now, this happens even earlier in the caller.

@chriseth chriseth added this pull request to the merge queue Feb 6, 2025
Merged via the queue into main with commit 53ad9c4 Feb 6, 2025
16 checks passed
@chriseth chriseth deleted the pass-range-constraints branch February 6, 2025 17:53
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.

2 participants