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

LinePoly backend #350

Merged
merged 1 commit into from
Feb 25, 2024
Merged

LinePoly backend #350

merged 1 commit into from
Feb 25, 2024

Conversation

spapinistarkware
Copy link
Contributor

@spapinistarkware spapinistarkware commented Feb 15, 2024

This change is Reviewable

@spapinistarkware
Copy link
Contributor Author

spapinistarkware commented Feb 15, 2024

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@spapinistarkware spapinistarkware mentioned this pull request Feb 15, 2024
This was referenced Feb 16, 2024
Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

Reviewed 7 of 8 files at r1, all commit messages.
Reviewable status: 7 of 8 files reviewed, 5 unresolved discussions (waiting on @spapinistarkware)


src/core/fri.rs line 195 at r1 (raw file):

        let last_layer_poly = LinePoly::from_ordered_coefficients(coeffs);
        let x: &Column<B, SecureField> = &last_layer_poly.coeffs;

Rename

Code quote:

x

src/core/backend/cpu/mod.rs line 28 at r1 (raw file):

    }
    fn to_vec(&self) -> Vec<F> {
        self.clone()

Do we have to use clone here? It could be very costly.

Code quote:

self.clone()

src/core/poly/line.rs line 107 at r1 (raw file):

    ///
    /// The coefficients are stored in bit-reversed order.
    pub coeffs: Column<B, F>,

Why public? Andrew won't like it :)

Code quote:

pub 

src/core/poly/line.rs line 164 at r1 (raw file):

pub struct LineEvaluation<B: LinePolyOps<F>, F: Field, EvalOrder = NaturalOrder> {
    /// Evaluations of a univariate polynomial on `domain`.
    pub values: Column<B, F>,

Did you change that to match the CircleEvaluation?
Can we make this change together with changing the evals arg in new()?

Code quote:

pub values: Column<B, F>,

src/core/poly/line.rs line 176 at r1 (raw file):

    fn deref(&self) -> &[F] {
        &self.coeffs
    }

Why did you remove that?
Can we do it in a different pr? It requires a lot of unrelated changes.

Code quote:

    fn deref(&self) -> &[F] {
        &self.coeffs
    }

@spapinistarkware spapinistarkware force-pushed the spapini/02-14-Backend branch 3 times, most recently from bc72807 to d9e5379 Compare February 21, 2024 10:55
@spapinistarkware spapinistarkware force-pushed the spapini/02-15-LinePoly_backend branch from a6e6f51 to 9ba5e1c Compare February 21, 2024 12:23
Copy link
Contributor Author

@spapinistarkware spapinistarkware 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: 1 of 8 files reviewed, 5 unresolved discussions (waiting on @shaharsamocha7)


src/core/fri.rs line 195 at r1 (raw file):

Previously, shaharsamocha7 wrote…

Rename

Done.


src/core/backend/cpu/mod.rs line 28 at r1 (raw file):

Previously, shaharsamocha7 wrote…

Do we have to use clone here? It could be very costly.

If you are using to_vec(), you are going to pay. It should be used only for very small stuff or tests.
Most backends will have to copy anyway.


src/core/poly/line.rs line 107 at r1 (raw file):

Previously, shaharsamocha7 wrote…

Why public? Andrew won't like it :)

Will go away next PR.


src/core/poly/line.rs line 164 at r1 (raw file):

Previously, shaharsamocha7 wrote…

Did you change that to match the CircleEvaluation?
Can we make this change together with changing the evals arg in new()?

evals sounds like multiple LineEvalaution. I thougth value is better.


src/core/poly/line.rs line 176 at r1 (raw file):

Previously, shaharsamocha7 wrote…

Why did you remove that?
Can we do it in a different pr? It requires a lot of unrelated changes.

We can't, unfortunately. What will this return? We can't return &Column, since it's &Vec, not &[]. We could add ColumnRef object, but it's a lot more unecessary code.

@spapinistarkware spapinistarkware force-pushed the spapini/02-15-LinePoly_backend branch from 9ba5e1c to b75d52a Compare February 21, 2024 12:24
Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 7 of 7 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @spapinistarkware)


src/core/fri.rs line 877 at r2 (raw file):

/// Panics if there are less than two evaluations.
pub fn fold_line<F: ExtensionOf<BaseField>>(
    evals: &LineEvaluation<B, F, BitReversedOrder>,

Why is it called evals?
Can you fix it? also in documentation

Code quote:

evals

This was referenced Feb 22, 2024
@spapinistarkware spapinistarkware force-pushed the spapini/02-15-LinePoly_backend branch 2 times, most recently from 028e9f4 to 7e61823 Compare February 22, 2024 07:13
Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 8 files at r1, 6 of 7 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @spapinistarkware)


src/core/fri.rs line 764 at r4 (raw file):

    fn new(evaluation: LineEvaluation<B, SecureField, BitReversedOrder>) -> Self {
        // TODO: Commit on slice.
        let merkle_tree = MerkleTree::commit(vec![evaluation.values.clone()]);

Suggestion:

to_vec()

src/core/backend/mod.rs line 27 at r4 (raw file):

    type Column: Column<F>;
    fn bit_reverse_column(column: Self::Column) -> Self::Column;
}

Is this trait belongs to this file?

Code quote:

pub trait FieldOps<F: Field> {
    type Column: Column<F>;
    fn bit_reverse_column(column: Self::Column) -> Self::Column;
}

@spapinistarkware spapinistarkware force-pushed the spapini/02-15-LinePoly_backend branch from 7e61823 to 5fcff8d Compare February 22, 2024 12:30
@spapinistarkware spapinistarkware changed the base branch from spapini/02-14-Backend to dev February 22, 2024 12:30
This was referenced Feb 22, 2024
Copy link
Contributor Author

@spapinistarkware spapinistarkware 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: 7 of 8 files reviewed, 2 unresolved discussions (waiting on @shaharsamocha7)


src/core/fri.rs line 764 at r4 (raw file):

    fn new(evaluation: LineEvaluation<B, SecureField, BitReversedOrder>) -> Self {
        // TODO: Commit on slice.
        let merkle_tree = MerkleTree::commit(vec![evaluation.values.clone()]);

Done.


src/core/backend/mod.rs line 27 at r4 (raw file):

Previously, shaharsamocha7 wrote…

Is this trait belongs to this file?

I thought it is. Do you have another suggestion?

Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 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: 7 of 8 files reviewed, 1 unresolved discussion (waiting on @spapinistarkware)


src/core/backend/mod.rs line 27 at r4 (raw file):

Previously, spapinistarkware (Shahar Papini) wrote…

I thought it is. Do you have another suggestion?

Maybe near the field trait?
The FriOps, PolyOps are sitting near the relevant code.

Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 4 files at r6, 8 of 9 files at r7, all commit messages.
Reviewable status: 9 of 10 files reviewed, 2 unresolved discussions (waiting on @spapinistarkware)


src/core/backend/cpu/mod.rs line 40 at r7 (raw file):

pub type CPUCircleEvaluation<F, EvalOrder = NaturalOrder> =
    CircleEvaluation<CPUBackend, F, EvalOrder>;
pub type CPULineEvaluation<F, EvalOrder = NaturalOrder> = LineEvaluation<CPUBackend, F, EvalOrder>;

Add a TODO to remove the EvalOrder here?

Code quote:

valOrder = NaturalOrder

src/core/fields/mod.rs line 16 at r7 (raw file):

    fn bit_reverse_column(column: Self::Column) -> Self::Column;
}
pub type Col<B, F> = <B as FieldOps<F>>::Column;

Maybe FieldColumn?

Code quote:

Col

@spapinistarkware spapinistarkware force-pushed the spapini/02-15-LinePoly_backend branch from 42ef8ff to c3627c8 Compare February 25, 2024 09:51
Copy link
Contributor Author

@spapinistarkware spapinistarkware 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: 9 of 10 files reviewed, 2 unresolved discussions (waiting on @shaharsamocha7)


src/core/backend/cpu/mod.rs line 40 at r7 (raw file):

Previously, shaharsamocha7 wrote…

Add a TODO to remove the EvalOrder here?

Done.


src/core/fields/mod.rs line 16 at r7 (raw file):

Previously, shaharsamocha7 wrote…

Maybe FieldColumn?

Done.

Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 9 files at r7, 1 of 1 files at r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @spapinistarkware)

@spapinistarkware spapinistarkware merged commit ff47970 into dev Feb 25, 2024
11 checks passed
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