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

o1vm/mips: fix failing constraints #2729

Merged
merged 4 commits into from
Oct 24, 2024
Merged

Conversation

marcbeunardeau88
Copy link
Contributor

fixe the remaining failing Mips instr
see : #2075
Closes #2075

@dannywillems
Copy link
Member

Can you rebase on top of #2700 for the CI please?

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 59.57447% with 19 lines in your changes missing coverage. Please review.

Project coverage is 72.51%. Comparing base (a339d26) to head (7d650a4).

Files with missing lines Patch % Lines
o1vm/src/interpreters/mips/witness.rs 40.62% 19 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           test/o1vm-e2e    #2729   +/-   ##
==============================================
  Coverage          72.51%   72.51%           
==============================================
  Files                247      247           
  Lines              57705    57745   +40     
==============================================
+ Hits               41845    41875   +30     
- Misses             15860    15870   +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

let inv_or_zero = if to_zero_test == Fp::zero() {
Fp::zero()
} else {
Fp::inverse(&to_zero_test).unwrap()
Copy link
Member

Choose a reason for hiding this comment

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

See a direct optimisation available here

Copy link
Member

Choose a reason for hiding this comment

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

And here, built on top of that one

@dannywillems dannywillems changed the title Marc/fix vm o1vm/mips: fix failing constraints Oct 24, 2024
Copy link
Member

@querolita querolita left a comment

Choose a reason for hiding this comment

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

I left a few suggestions to help keep the different interpreters separated in scope, I hope it can be useful. Other than that, I will happily approve the PR, as it does not change all of the Self::Variables to field, but it keeps it as native type. Either way, I believe that addressing Danny's optimization can be a smart move after the constraints fix is merged. But I would first focus on this PR and work on #2040 / and #2047 afterwards, because it is a different issue being targeted there.

};
let _to_zero_test_inv_or_zero = {
let pos = self.alloc_scratch();
let inv_or_zero = if to_zero_test == Fp::zero() {
Copy link
Member

Choose a reason for hiding this comment

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

You can probably call inverse_or_zero in these lines, no? I guess the bug comes from the res block, there's no need to unroll the inv_or_zero to solve the bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought so at first as well, but Inverse_or_zero is forced to return a Variable by the signature, so we can't get the resulting field_inversion we desire here.

} else {
self.is_zero(&(*y - *x))
}
// We replicate is_zero(x-y), but working on field elt,
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it's less error prone if you move the is_zero() in interpreter.rs into constraint.rs and define a variant of is_zero() in witness.rs containing precisely your replication here in equal(). Otherwise, one could call the is_zero() from interpreter.rs for the witness and incur in the same problem being fixed in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed it is more clean

@dannywillems
Copy link
Member

@marcbeunardeau88 can you change the target branch to match @shimkiv one please?

}
// We replicate is_zero(x-y), but working on field elt,
// to avoid subtraction overflow in the witness interpreter for u32
let to_zero_test = Fp::from(*x) - Fp::from(*y);
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to convert as early as here in Fp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, but I believe this to be more clear, and the performance is negligibly impacted

@marcbeunardeau88 marcbeunardeau88 changed the base branch from master to test/o1vm-e2e October 24, 2024 13:19
Copy link
Member

@querolita querolita left a comment

Choose a reason for hiding this comment

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

Awesome 😄

@marcbeunardeau88 marcbeunardeau88 merged commit 3e42796 into test/o1vm-e2e Oct 24, 2024
7 of 8 checks passed
@marcbeunardeau88 marcbeunardeau88 deleted the marc/fix-vm branch October 24, 2024 16:54
@dannywillems dannywillems restored the marc/fix-vm branch October 25, 2024 08:33
@dannywillems
Copy link
Member

Please reopen the PR targetting master, @marcbeunardeau88

@dannywillems dannywillems deleted the marc/fix-vm branch October 30, 2024 19:11
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.

Fix MIPS failing constraints
3 participants