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

Add Bitwise Xor to Preprocessed Column Enum #380

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

Gali-StarkWare
Copy link
Contributor

@Gali-StarkWare Gali-StarkWare commented Jan 21, 2025

This change is Reviewable

Copy link
Contributor Author

Gali-StarkWare commented Jan 21, 2025

@Gali-StarkWare Gali-StarkWare marked this pull request as ready for review January 21, 2025 09:46
@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch 2 times, most recently from 3371f4d to 5a55c1a Compare January 23, 2025 09:04
@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch 2 times, most recently from 956615f to fdf98c9 Compare January 27, 2025 10:29
@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch from fdf98c9 to 4993f46 Compare January 27, 2025 17:20
@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch from 4993f46 to 224e469 Compare January 28, 2025 09:17
This was referenced Jan 28, 2025
@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch 2 times, most recently from 6e87c7c to e5e2a1d Compare January 28, 2025 11:23
Copy link
Contributor

@ohad-starkware ohad-starkware left a comment

Choose a reason for hiding this comment

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

I dont think the enum was correct here, if all you do is trivially expose the structs' methods, this is what a dyn trait is for.

Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @alon-f, @andrewmilson, @Gali-StarkWare, and @shaharsamocha7)


stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs line 55 at r2 (raw file):

    }

    /// Generates a column according to the preprocessed column chosen.

not sure this adds information

Code quote:

    /// Generates a column according to the preprocessed column chosen.

stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs line 70 at r2 (raw file):

    }

    /// Returns the values of the column at the given row.

this is less correct than the function's name

Code quote:

/// Returns the values of the column at the given row.

@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch from e5e2a1d to 457af27 Compare January 29, 2025 13:17
@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch from 457af27 to dae840e Compare January 30, 2025 09:11
@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch from bc5a93f to e800704 Compare January 30, 2025 14:11
@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch from e800704 to f9def60 Compare January 30, 2025 14:17
@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch 2 times, most recently from 8f27867 to 25cf96b Compare January 30, 2025 14:34
Copy link
Contributor

@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 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @alon-f, @andrewmilson, @Gali-StarkWare, and @ohad-starkware)


stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs line 35 at r5 (raw file):

}

pub enum PreProcessedColumn {

@Gali-StarkWare can you add a TODO to change the enum to a trait?

Code quote:

pub enum PreProcessedColumn {

Copy link
Contributor Author

@Gali-StarkWare Gali-StarkWare 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: all files reviewed, 2 unresolved discussions (waiting on @alon-f, @andrewmilson, @ohad-starkware, and @shaharsamocha7)


stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs line 35 at r5 (raw file):

Previously, shaharsamocha7 wrote…

@Gali-StarkWare can you add a TODO to change the enum to a trait?

Already done

@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch from 25cf96b to 21b338f Compare January 30, 2025 14:43
Copy link
Contributor

@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: all files reviewed, 1 unresolved discussion (waiting on @alon-f, @andrewmilson, and @ohad-starkware)

Copy link
Contributor

@ohad-starkware ohad-starkware 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 1 files reviewed, 2 unresolved discussions (waiting on @alon-f, @andrewmilson, @Gali-StarkWare, and @shaharsamocha7)


stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs line 65 at r3 (raw file):

Previously, Gali-StarkWare wrote…

I wanted to have it as a default implementation as a step before removing the rest of the gen_column_simd from the structs. That might be a reason why we would keep packed_at inside the trait when we switch to it. For now, done.

I agree, exposing packed_at so you can have a generic collect function (same as in pack_values)
albeit, it would be in a different trait.


stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs line 162 at r6 (raw file):

        let col: Col<SimdBackend, BaseField> = (0..((1 << self.log_size()) / N_LANES))
            .flat_map(|i| self.packed_at(i).to_array())
            .collect();

why do you need that to_array, try collecting the packed elements in to a vector?

Code quote:

        let col: Col<SimdBackend, BaseField> = (0..((1 << self.log_size()) / N_LANES))
            .flat_map(|i| self.packed_at(i).to_array())
            .collect();

@Gali-StarkWare Gali-StarkWare changed the base branch from gali/xor_preprocessed to graphite-base/380 January 30, 2025 15:03
@Gali-StarkWare Gali-StarkWare deleted the branch main January 30, 2025 15:03
Copy link
Contributor Author

@Gali-StarkWare Gali-StarkWare 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 1 files reviewed, 2 unresolved discussions (waiting on @alon-f, @andrewmilson, @ohad-starkware, and @shaharsamocha7)


stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs line 65 at r3 (raw file):

Previously, ohad-starkware (Ohad) wrote…

I agree, exposing packed_at so you can have a generic collect function (same as in pack_values)
albeit, it would be in a different trait.

OK


stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs line 162 at r6 (raw file):

Previously, ohad-starkware (Ohad) wrote…

why do you need that to_array, try collecting the packed elements in to a vector?

I couldn't without errors, you can suggest if you find a way

@Gali-StarkWare Gali-StarkWare force-pushed the gali/add_xor_to_preprocessed branch from 21b338f to cb12a09 Compare January 30, 2025 15:13
@Gali-StarkWare Gali-StarkWare changed the base branch from graphite-base/380 to main January 30, 2025 15:13
Copy link
Contributor

@ohad-starkware ohad-starkware 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 1 files reviewed, 2 unresolved discussions (waiting on @alon-f, @andrewmilson, @Gali-StarkWare, and @shaharsamocha7)


stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs line 155 at r7 (raw file):

            .collect();
        CircleEvaluation::new(CanonicCoset::new(self.log_size()).circle_domain(), col)
    }

Suggestion:

    pub fn gen_column_simd(&self) -> CircleEvaluation<SimdBackend, BaseField, BitReversedOrder> {
        CircleEvaluation::new(
            CanonicCoset::new(self.log_size()).circle_domain(),
            BaseColumn::from_simd(
                (0..(1 << (self.log_size() - LOG_N_LANES)))
                    .map(|i| self.packed_at(i))
                    .collect(),
            ),
        )
    }

Copy link
Contributor Author

@Gali-StarkWare Gali-StarkWare 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 1 files reviewed, 2 unresolved discussions (waiting on @alon-f, @andrewmilson, @ohad-starkware, and @shaharsamocha7)


stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs line 155 at r7 (raw file):

            .collect();
        CircleEvaluation::new(CanonicCoset::new(self.log_size()).circle_domain(), col)
    }

You got it

Copy link
Contributor

@ohad-starkware ohad-starkware 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 1 files at r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @alon-f, @andrewmilson, and @shaharsamocha7)

@Gali-StarkWare Gali-StarkWare merged commit 466480e into main Jan 30, 2025
7 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.

3 participants