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

WideFib test with AVX Backend #492

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

spapinistarkware
Copy link
Contributor

@spapinistarkware spapinistarkware commented Mar 16, 2024

This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Mar 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.04%. Comparing base (90e675a) to head (4b151b8).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #492      +/-   ##
==========================================
+ Coverage   93.34%   94.04%   +0.70%     
==========================================
  Files          65       65              
  Lines        8299     8302       +3     
  Branches     8299     8302       +3     
==========================================
+ Hits         7747     7808      +61     
+ Misses        490      432      -58     
  Partials       62       62              

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

@spapinistarkware spapinistarkware force-pushed the spapini/03-16-implement_backend_for_avx512backend branch from f21e77e to 12ade2f Compare March 18, 2024 11:11
@spapinistarkware spapinistarkware force-pushed the spapini/03-16-widefib_test_with_avx_backend branch from 9949fe2 to 74caa3e Compare March 18, 2024 11:11
@spapinistarkware spapinistarkware force-pushed the spapini/03-16-implement_backend_for_avx512backend branch from 12ade2f to a8014d1 Compare March 18, 2024 11:23
@spapinistarkware spapinistarkware force-pushed the spapini/03-16-widefib_test_with_avx_backend branch from 74caa3e to 79bac64 Compare March 18, 2024 11:23
@spapinistarkware spapinistarkware force-pushed the spapini/03-16-widefib_test_with_avx_backend branch from 34a5a50 to 28f7685 Compare April 3, 2024 06:22
@spapinistarkware spapinistarkware mentioned this pull request Apr 3, 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 1 of 13 files at r2.
Reviewable status: 1 of 13 files reviewed, 1 unresolved discussion (waiting on @spapinistarkware)


src/core/air/accumulation.rs line 169 at r2 (raw file):

pub struct ColumnAccumulator<'a, B: Backend> {
    pub random_coeff_pow: SecureField,
    pub col: &'a mut SecureColumn<B>,

I changed this code. you probably have some conflicts :(

Code quote:

pub struct ColumnAccumulator<'a, B: Backend> {
    pub random_coeff_pow: SecureField,
    pub col: &'a mut SecureColumn<B>,

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 2 of 13 files at r2.
Reviewable status: 3 of 13 files reviewed, 6 unresolved discussions (waiting on @spapinistarkware)


src/core/backend/avx512/blake2s.rs line 28 at r2 (raw file):

    ) -> Vec<Blake2sHash> {
        // Pad prev_layer if too small.
        if log_size < 4 {

Suggestion:

VECS_LOG_SIZE

src/examples/wide_fibonacci/avx.rs line 95 at r2 (raw file):

            let mut b = trace_eval[1].data[vec_row];
            #[allow(clippy::needless_range_loop)]
            for i in 0..(N_COLS - 2) {

Can you add the boundary constraint?

Code quote:

            #[allow(clippy::needless_range_loop)]
            for i in 0..(N_COLS - 2) {

src/examples/wide_fibonacci/avx.rs line 104 at r2 (raw file):

            // Denominator.
            // TODO(spapini): Optimized this, for the small number of columns case.

Is this the coset_vanishing function?
Don't we already have one?

Suggestion:

// TODO(spapini): Move to PolyOps? and optimized for the small number of columns case.

src/examples/wide_fibonacci/avx.rs line 118 at r2 (raw file):

            accum.col.set_packed(
                vec_row,
                accum.col.packed_at(vec_row) * PackedQM31::broadcast(accum.random_coeff_pow)

Where the denomenator is used?


src/examples/wide_fibonacci/avx.rs line 158 at r2 (raw file):

    #[test]
    fn test_avx_wide_fib_prove() {
        // TODO(spapini): Increase to 20, to get 1GB of trace.

You can do these now, no?

Code quote:

 // TODO(spapini): Increase to 20, to get 1GB of trace.

@spapinistarkware spapinistarkware force-pushed the spapini/03-16-widefib_test_with_avx_backend branch from 28f7685 to bc6f0e4 Compare April 3, 2024 12:47
@spapinistarkware spapinistarkware changed the base branch from spapini/03-16-implement_backend_for_avx512backend to spapini/03-16-make_prove_generic_in_backend April 3, 2024 12:47
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 13 files reviewed, 5 unresolved discussions (waiting on @shaharsamocha7)


src/core/air/accumulation.rs line 169 at r2 (raw file):

Previously, shaharsamocha7 wrote…

I changed this code. you probably have some conflicts :(

Done.


src/examples/wide_fibonacci/avx.rs line 95 at r2 (raw file):

Previously, shaharsamocha7 wrote…

Can you add the boundary constraint?

Done.


src/examples/wide_fibonacci/avx.rs line 104 at r2 (raw file):

Previously, shaharsamocha7 wrote…

Is this the coset_vanishing function?
Don't we already have one?

Sorry, leftovers.


src/examples/wide_fibonacci/avx.rs line 118 at r2 (raw file):

Previously, shaharsamocha7 wrote…

Where the denomenator is used?

Done.


src/examples/wide_fibonacci/avx.rs line 158 at r2 (raw file):

Previously, shaharsamocha7 wrote…

You can do these now, no?

When I test with AVX flags not on release, it's slow. I use it for my tests, so I'd rather only do this when I benchmark.

@spapinistarkware spapinistarkware force-pushed the spapini/03-16-make_prove_generic_in_backend branch from 2a6c1c1 to 2247dbf Compare April 3, 2024 12:55
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 2 of 13 files at r2, 7 of 10 files at r3, all commit messages.
Reviewable status: 10 of 13 files reviewed, 4 unresolved discussions (waiting on @spapinistarkware)


src/core/air/accumulation.rs line 65 at r3 (raw file):

        Self {
            random_coeff_powers: generate_secure_powers(random_coeff, total_columns),
            sub_accumulations: (0..(max_log_size + 1)).map(|_| None).collect(),

For efficiency?

Code quote:

(0..(max_log_size + 1)).map(|_| None).collect(),

src/examples/wide_fibonacci/constraint_eval.rs line 436 at r3 (raw file):

        evaluation_accumulator: &mut PointEvaluationAccumulator,
    ) {
        let constraint_zero_domain = Coset::subgroup(self.log_size);

Why it is not a CanonicCoset?

Code quote:

Coset::subgroup(self.log_size);

src/examples/wide_fibonacci/mod.rs line 50 at r3 (raw file):

            QM31::from_u32_unchecked(1, 2, 3, 4),
            wide_fib.log_size + 1,
            Component::<CPUBackend>::n_constraints(&wide_fib),

A question:
Why this change is good?

Code quote:

Component::<CPUBackend>::n_constraints(&wide_fib)

src/examples/wide_fibonacci/avx.rs line 158 at r2 (raw file):

Previously, spapinistarkware (Shahar Papini) wrote…

When I test with AVX flags not on release, it's slow. I use it for my tests, so I'd rather only do this when I benchmark.

so this TODO is to add benchmark? can you change that?

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


src/core/air/accumulation.rs line 65 at r3 (raw file):

Previously, shaharsamocha7 wrote…

For efficiency?

Because small sizes are not supported in AVX backend.


src/examples/wide_fibonacci/constraint_eval.rs line 436 at r3 (raw file):

Previously, shaharsamocha7 wrote…

Why it is not a CanonicCoset?

Good point. I wonder why the test didnt catch it. We should inverstigate this.


src/examples/wide_fibonacci/mod.rs line 50 at r3 (raw file):

Previously, shaharsamocha7 wrote…

A question:
Why this change is good?

Not good. Necessary.
We should separate Component to a backedn dependenc one and a non backend dependent one.
Currently, when we do .n_constraints(), it doesnt know which impl to use (for which of the backends)

@spapinistarkware spapinistarkware force-pushed the spapini/03-16-make_prove_generic_in_backend branch from 2247dbf to 701e435 Compare April 3, 2024 13:09
@spapinistarkware spapinistarkware force-pushed the spapini/03-16-widefib_test_with_avx_backend branch 2 times, most recently from afae560 to 22acef4 Compare April 3, 2024 13:19
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: 8 of 13 files reviewed, 2 unresolved discussions (waiting on @spapinistarkware)


src/core/air/accumulation.rs line 65 at r3 (raw file):

Previously, spapinistarkware (Shahar Papini) wrote…

Because small sizes are not supported in AVX backend.

I don't see the connection.
It seems that you don't initialize unused accumulations, no?


src/examples/wide_fibonacci/constraint_eval.rs line 436 at r3 (raw file):

Previously, spapinistarkware (Shahar Papini) wrote…

Good point. I wonder why the test didnt catch it. We should inverstigate this.

It works for both CanonicCoset and subgroup?
That's really strange.

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


src/core/air/accumulation.rs line 65 at r3 (raw file):

Previously, shaharsamocha7 wrote…

I don't see the connection.
It seems that you don't initialize unused accumulations, no?

The issue was that I interpolate each of these sub accumulations. And I am not allowed to do it on small ones right now

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


src/examples/wide_fibonacci/constraint_eval.rs line 436 at r3 (raw file):

Previously, shaharsamocha7 wrote…

It works for both CanonicCoset and subgroup?
That's really strange.

I agree. We should inverstigate this.

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 3 of 10 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @spapinistarkware)


src/examples/wide_fibonacci/constraint_eval.rs line 436 at r3 (raw file):

Previously, spapinistarkware (Shahar Papini) wrote…

I agree. We should inverstigate this.

Solution here is now clear, it worked since the poly was constant?


src/examples/wide_fibonacci/avx.rs line 161 at r4 (raw file):

    #[test]
    fn test_avx_wide_fib_prove() {

Need to fix this test before

Code quote:

fn test_avx_wide_fib_prove()

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


src/examples/wide_fibonacci/constraint_eval.rs line 436 at r3 (raw file):

Previously, shaharsamocha7 wrote…

Solution here is now clear, it worked since the poly was constant?

Yep


src/examples/wide_fibonacci/avx.rs line 161 at r4 (raw file):

Previously, shaharsamocha7 wrote…

Need to fix this test before

Waiting on you now (mask points change)

@spapinistarkware spapinistarkware force-pushed the spapini/03-16-make_prove_generic_in_backend branch from 701e435 to 42c6621 Compare April 4, 2024 09:47
@spapinistarkware spapinistarkware force-pushed the spapini/03-16-widefib_test_with_avx_backend branch from 22acef4 to b9036b8 Compare April 4, 2024 09:47
@spapinistarkware spapinistarkware force-pushed the spapini/03-16-make_prove_generic_in_backend branch from 42c6621 to 2053114 Compare April 4, 2024 09:52
@spapinistarkware spapinistarkware force-pushed the spapini/03-16-widefib_test_with_avx_backend branch from b9036b8 to 19ded1d Compare April 4, 2024 09:52
@spapinistarkware spapinistarkware force-pushed the spapini/03-16-make_prove_generic_in_backend branch from 2053114 to e3218cf Compare April 4, 2024 11:06
@spapinistarkware spapinistarkware changed the base branch from spapini/03-16-make_prove_generic_in_backend to dev April 4, 2024 12:20
@spapinistarkware spapinistarkware force-pushed the spapini/03-16-widefib_test_with_avx_backend branch from 19ded1d to bcc3f59 Compare April 4, 2024 12:20
@spapinistarkware spapinistarkware force-pushed the spapini/03-16-widefib_test_with_avx_backend branch from bcc3f59 to 4b151b8 Compare April 4, 2024 12:26
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: 10 of 13 files reviewed, 1 unresolved discussion (waiting on @shaharsamocha7)


src/examples/wide_fibonacci/avx.rs line 161 at r4 (raw file):

Previously, spapinistarkware (Shahar Papini) wrote…

Waiting on you now (mask points change)

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 2 files at r5, 2 of 2 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @spapinistarkware)

@spapinistarkware spapinistarkware merged commit 58a3452 into dev Apr 4, 2024
22 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