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

Opt const eval #17

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

Opt const eval #17

wants to merge 11 commits into from

Conversation

Al-Kindi-0
Copy link
Owner

For some reason the previous PR says that it has been merged. I am creating this new PR which implements the improvements suggested in the old one.
Sorry for the mess.

air/src/air/context.rs Outdated Show resolved Hide resolved
Comment on lines 104 to 117
let mut b = self;

if power == 0 {
return Self::ONE;
} else if b == Self::ZERO {
return Self::ZERO;
}

let mut r = if power & 1 == 1 { b } else { Self::ONE };
for i in 1..64 - power.leading_zeros() {
b = b.square();
if (power >> i) & 1 == 1 {
r *= b;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is fine to have for testing purposes - but it probably shouldn't be a part of this PR.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Sure, I will remove it before making the PR against Novi/Winterfell main.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Actually, I will just change it back so that I don't forget it.

@@ -271,15 +278,12 @@ impl<E: FieldElement> TransitionConstraintGroup<E> {
/// them by the divisor later on. The degree of the divisor for transition constraints is
/// always $n - 1$. Thus, once we divide out the divisor, the evaluations will represent a
/// polynomial of degree $D$.
pub fn merge_evaluations<B, F>(&self, evaluations: &[F], x: B) -> E
pub fn merge_evaluations<B, F>(&self, evaluations: &[F], xp: B) -> E
Copy link
Collaborator

Choose a reason for hiding this comment

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

The comment above probably should be updated.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done, let me know what you think.

@@ -81,6 +100,19 @@ impl<B: StarkField> StarkDomain<B> {
self.ce_to_lde_blowup
}

/// Returns (offset * g^(step))^degree_adjustment.
pub fn get_ce_x_power_at<A: Air<BaseField = B>>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could try adding #[inline(always)] attribute to this function (and maybe some other functions). Sometimes, this improves performance.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Sure, I did here and in the helper function on the same file.

Comment on lines 110 to 111
let index = index % (self.ce_domain_size());
let xp = self.ce_domain()[index] * *self.degree_adj_map().get(&degree_adjustment).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if instead of % we could use a shift here somehow (because we know that ce_domain_size is a power of 2).

Also, we should change unwrap to expect (we shouldn't use unwrap's in non-test code).

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