-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add boundary constraints to the constraint graph #126
Conversation
enf a.first = stack_inputs[0] | ||
enf a.first = 0 |
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.
I changed this to keep the public inputs usage in the public inputs test. Once we add variables for the boundary constraints, we can test them here as well
cd7e777
to
8828c54
Compare
d2f0406
to
49f2fd8
Compare
c915ba6
to
cd08bd7
Compare
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.
Looks great to me, thanks @grjte !
Just some minor nits from my side.
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.
Thank you @grjte, looks good to me. I left a few minor nits inline.
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.
Looks great to me, thank you @grjte!
d48dce5
to
f2c43ea
Compare
f2c43ea
to
cb45670
Compare
Thanks for your reviews @Al-Kindi-0 @Overcastan and @tohrnii! I made the suggested changes, except for one point of discussion raised by @tohrnii (which it would be great to get your thoughts on). Since this is a very significant change, let's wait for the review from @bobbinth before we merge. |
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.
Looks great! Thank you! I reviewed everything except for tests.
I think the structure is much cleaner than before. My comments are mostly for the future except fro the split_boundary_constraint
comment. But even that one is non-blocking.
ElemType::Felt => format!("({lhs}).exp(Felt::new({r_idx}))"), | ||
ElemType::E => format!("({lhs}).exp(E::PositiveInteger::from({r_idx}_u64))"), |
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.
We should remember that using exp
could be quite expensive as it uses constant-time exponentiation. In the future, we might want o "unroll" this into a sequence of multiplications.
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.
Agreed. I was trying to minimize changes in this PR. I've opened #130 to track this.
Are you thinking this unrolling should be done in the IR or in the winterfell codegen? (It seems to make sense as a future optimization that could be done in the IR)
/// Variable roots for the variables used in integrity constraints. For each element in a | ||
/// vector or a matrix, a new root is added with a key equal to the [VariableValue] of the | ||
/// element. | ||
variable_roots: VariableRoots, |
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.
As far as I can tell, this is a helper map which is used only during the construction of the graph and is not really needed after the graph is constructed. If so, it may be good to find a better way to handle it in the future so that once constructed Constraints
does not need to retain any extra info.
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.
Yes, this is true. I think there are still a few refactors that could be done, but I wanted to keep this PR as minimal as possible. Once the remaining issues related to this work are addressed this is worth revisiting (or possibly while addressing those)
cb45670
to
3f44c8c
Compare
This PR addresses part of #106, by moving boundary constraints into the
AlgebraicGraph
alongside the integrity constraints, and updating the codegen and tests accordingly.It includes the following changes:
There are several things that yet to be completed, but I'd like to tackle these in a subsequent PR since this is already quite large: