Skip to content

Conversation

@dancarmoz
Copy link
Collaborator

@dancarmoz dancarmoz commented Sep 1, 2025

This change is Reviewable

@dancarmoz dancarmoz force-pushed the danc/improve_quotient_constants_perf branch from c38af99 to 6eef425 Compare September 1, 2025 18:43
@ilyalesokhin-starkware
Copy link
Collaborator

Can you move this to sharp7 and document?

@ilyalesokhin-starkware
Copy link
Collaborator

stwo_cairo_verifier/crates/verifier_core/src/pcs/quotients.cairo line 314 at r1 (raw file):

            let [a, b, c, d] = sample_batch.point.y.to_fixed_array();
            let re_py = CM31Trait::pack(a, b);
            let im_py_inv = CM31Trait::pack(c, d).inverse();

Was there an inverse here before?

Code quote:

 let im_py_inv = CM31Trait::pack(c, d).inverse();

@ilyalesokhin-starkware
Copy link
Collaborator

I guess we need to decide if we want it in the mvp

@ilyalesokhin-starkware
Copy link
Collaborator

stwo_cairo_verifier/crates/verifier_core/src/pcs/quotients.cairo line 216 at r1 (raw file):

        }

        let minus_quotient = minus_numerator.reduce().mul_cm31(denom_inv);

This shouldn't be included through this PR.

Code quote:

  let minus_quotient = minus_numerator.reduce().mul_cm31(denom_inv);

Copy link
Collaborator Author

@dancarmoz dancarmoz left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware)


stwo_cairo_verifier/crates/verifier_core/src/pcs/quotients.cairo line 216 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

This shouldn't be included through this PR.

I know, but without it I had to inroduce ::zero which was an unnecessary complication. The branch over sharp 7 ( #1332 ) has this previously introduced.


stwo_cairo_verifier/crates/verifier_core/src/pcs/quotients.cairo line 314 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

Was there an inverse here before?

No. Previously every iteration multiplied alpha by the constant neg_dbl_im_py, which was very wasteful.
Instead, in this version we initialize alpha to that value, so everything is inherently multiplied by it. (Theoretically this is is unnecessary, the constant can be taken out at the protocol level. But this would require a change in the prover as well.)
Because we have to return alpha, we must divided by the same term in the end. Also some of ther other terms need to be divided by it.
Possibly there is a more efficient way to do this without the divisions (depending on how much more expensive they are than a mul).
We can also probably batch these, although that would be somewhat annoying.

Copy link
Collaborator

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Choose a reason for hiding this comment

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

@ilyalesokhin-starkware reviewed 2 of 3 files at r1, all commit messages.
Reviewable status: 2 of 3 files reviewed, all discussions resolved


stwo_cairo_verifier/crates/verifier_core/src/pcs/quotients.cairo line 314 at r1 (raw file):

Previously, dancarmoz (Dan Carmon) wrote…

No. Previously every iteration multiplied alpha by the constant neg_dbl_im_py, which was very wasteful.
Instead, in this version we initialize alpha to that value, so everything is inherently multiplied by it. (Theoretically this is is unnecessary, the constant can be taken out at the protocol level. But this would require a change in the prover as well.)
Because we have to return alpha, we must divided by the same term in the end. Also some of ther other terms need to be divided by it.
Possibly there is a more efficient way to do this without the divisions (depending on how much more expensive they are than a mul).
We can also probably batch these, although that would be somewhat annoying.

I think we should make the prover change as well in that case, and do it on main

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.

3 participants