-
Notifications
You must be signed in to change notification settings - Fork 82
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
Filter later-stage witnesses and identities #2129
base: main
Are you sure you want to change the base?
Conversation
refs_in_parsed_expression(pf).unique().all(|n| { | ||
let def = self.fixed.analyzed.definitions.get(n); | ||
def.and_then(|(s, _)| s.stage).unwrap_or_default() <= stage as u32 |
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 think this was actually wrong, it wouldn't resolve array elements.
@@ -225,7 +233,7 @@ impl<'a, 'b, T: FieldElement> WitnessGenerator<'a, 'b, T> { | |||
mut machines, | |||
base_parts, | |||
} = if self.stage == 0 { | |||
MachineExtractor::new(&fixed).split_out_machines(retained_identities, self.stage) | |||
MachineExtractor::new(&fixed).split_out_machines(retained_identities) |
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.
So we don't pass the stage because we already only pass the identities up to this stage
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, and also the machine extractor can use functions like FixedData::current_stage_witnesses
.
fn current_stage_witnesses(&self) -> impl Iterator<Item = PolyID> + '_ { | ||
self.witness_cols | ||
.iter() | ||
.filter(|(_, col)| col.stage <= self.stage as u32) |
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.
Doesn't this filtering already happen in the constructor?
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.
And shouldn't it be == self.stage
?
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.
Doesn't this filtering already happen in the constructor?
No
And shouldn't it be
== self.stage
?
I mean it's only currently used by the MachineExtractor
, which is only run in stage 0, so it doesn't matter in practice. But I think it makes more sense to have a function that returns all witnesses relevant in the current stage, which would include previous-stage witnesses. Maybe I should rename it to witnesses_for_current_stage()
?
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.
witnesses_until_current_stage
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.
Done!
fn polynomial_references( | ||
&self, | ||
expr: &impl AllChildren<AlgebraicExpression<T>>, | ||
) -> HashSet<PolyID> { |
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.
Is it fine for this to be non-deterministic? Maybe BTreeSet
is safer?
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.
It shouldn't matter, but I can change it!
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.
Hmm, it is used by the machine extractor, which uses hash sets everywhere. It would propagate quite far, so unless you feel strongly about it, I'd leave it as is. As long as its only used as a set, it should be fine.
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.
Not strongly, all good.
@@ -375,6 +383,7 @@ pub struct FixedData<'a, T: FieldElement> { | |||
challenges: BTreeMap<u64, T>, | |||
global_range_constraints: GlobalConstraints<T>, | |||
intermediate_definitions: BTreeMap<PolyID, &'a AlgebraicExpression<T>>, | |||
stage: u8, |
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.
Now it's only fixed for one stage of witness generation.
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.
Although we already had challenges
right?
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, it's fixed for the duration of the call to WitnessGenerator::generate
!
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.
Can you mention that in the docstring? ("Fixed for witness generation for a certain proof stage")
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.
Done!
Co-authored-by: Thibaut Schaeffer <[email protected]>
581cc49
to
9aec364
Compare
Prepares #2129
With this PR, later-stage witness columns & identities referencing them (or later-stage challenges) are completely ignored. The columns are not assigned to any machine. Previously, they would end up in the main machine and never receive any updates. That doesn't work if machines have different sized though.