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 inference. #2219

Merged
merged 54 commits into from
Dec 12, 2024
Merged

Witgen inference. #2219

merged 54 commits into from
Dec 12, 2024

Conversation

chriseth
Copy link
Member

@chriseth chriseth commented Dec 10, 2024

This PR adds a component that can derive assignments and other code on identities and multiple rows. It keeps track of which cells in the trace are already known and which not. The way to access fixed rows is abstracted because it does not have a concept of an absolute row. While this might work for block machines with cyclic fixed columns, it does not work in the general case.

What it does not do:

  • have a sequence of which identities to consider on which rows
  • a mechanism that determines when it is finished

@chriseth chriseth changed the base branch from main to jit_solving December 10, 2024 16:09
Copy link
Collaborator

@georgwiese georgwiese left a comment

Choose a reason for hiding this comment

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

Cool!

executor/src/witgen/jit/witgen_inference.rs Show resolved Hide resolved
executor/src/witgen/jit/affine_symbolic_expression.rs Outdated Show resolved Hide resolved
executor/src/witgen/jit/witgen_inference.rs Outdated Show resolved Hide resolved
executor/src/witgen/jit/witgen_inference.rs Outdated Show resolved Hide resolved
executor/src/witgen/jit/witgen_inference.rs Outdated Show resolved Hide resolved
executor/src/witgen/jit/witgen_inference.rs Show resolved Hide resolved
Base automatically changed from jit_solving to main December 11, 2024 17:36
Copy link
Collaborator

@georgwiese georgwiese left a comment

Choose a reason for hiding this comment

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

Cool! I just got some small comments, otherwise LGTM.

executor/src/witgen/jit/affine_symbolic_expression.rs Outdated Show resolved Hide resolved
Comment on lines +457 to +459
// We cannot solve it, but we can also not learn anything new from it.
let result = constr.solve().unwrap();
assert!(result.complete && result.effects.is_empty());
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems confusing, if we cannot solve it, why is it complete?

I think the answer is that there are no unknown symbols, right? But in that case, it is already solved, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean it says it in the comment "we cannot learn anything new from it"

executor/src/witgen/jit/affine_symbolic_expression.rs Outdated Show resolved Hide resolved
executor/src/witgen/jit/witgen_inference.rs Outdated Show resolved Hide resolved
executor/src/witgen/jit/witgen_inference.rs Outdated Show resolved Hide resolved
executor/src/witgen/jit/witgen_inference.rs Show resolved Hide resolved
Comment on lines 287 to 297
pub trait ReferenceEvaluator<T: FieldElement> {
fn evaluate_fixed(&self, _var: &AlgebraicReference, _row_offset: i32) -> Option<T> {
None
}
fn evaluate_challenge(&self, _challenge: &Challenge) -> Option<T> {
None
}
fn evaluate_public(&self, _public: &String) -> Option<T> {
None
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Few comments:

  • Should we call this FixedEvaluator? Because it doesn't evaluate all reference, just those to "fixed data"?
  • If so, should we remove publics? In my mind, they are closer to witness cells, basically variables that we want to solve for. Public references are anyway only half-supported, so I think I'd remove it here and just put a todo!() inside evaluate() for now.
  • If the idea is that this trait allows to access fixed data, it should return a Result<T, ()>, because we'd expect the data to always be available, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just meant as a first version, I didn't think so much about it. In the end, we need to change the variable type from Cell to some enum that contains Cell, Public, Challenge and maybe even a reference to T (we would maybe use that for runtime conditionals).

But yeah, maybe you are right: Challenges will always be "known but arbitrary", so there is no point in asking the caller for a concrete value. For publics we might want to know if they are known or not, but that needs a different interface.

executor/src/witgen/jit/witgen_inference.rs Show resolved Hide resolved
Xor::C[5] = (Xor::C[6] & 65535);
assert Xor::C[6] == (Xor::C[6] | 16777215);
lookup(0, [Known(Xor::A_byte[6]), Unknown(Xor::B_byte[6]), Known(Xor::C_byte[6])]);
Xor::A_byte[4] = (65280 // 256);
Copy link
Member Author

Choose a reason for hiding this comment

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

This all looks good until here, we it goes south.

@chriseth chriseth changed the title witgen inference. Witgen inference. Dec 12, 2024
Copy link
Collaborator

@georgwiese georgwiese left a comment

Choose a reason for hiding this comment

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

Vámanos

@georgwiese georgwiese enabled auto-merge December 12, 2024 16:10
@georgwiese georgwiese added this pull request to the merge queue Dec 12, 2024
Merged via the queue into main with commit e3c4c85 Dec 12, 2024
16 checks passed
@georgwiese georgwiese deleted the witgen_inference branch December 12, 2024 16:44
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