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

Fall back to cpu in small fft size. #827

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

alonh5
Copy link
Contributor

@alonh5 alonh5 commented Sep 9, 2024

This change is Reviewable

Copy link
Contributor Author

alonh5 commented Sep 9, 2024

@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 36.84211% with 12 lines in your changes missing coverage. Please review.

Project coverage is 91.82%. Comparing base (cdf66f3) to head (77b7cdd).
Report is 2 commits behind head on dev.

Files with missing lines Patch % Lines
crates/prover/src/core/backend/simd/circle.rs 46.66% 8 Missing ⚠️
crates/prover/src/core/poly/circle/evaluation.rs 0.00% 3 Missing ⚠️
crates/prover/src/core/backend/simd/quotients.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #827      +/-   ##
==========================================
- Coverage   91.86%   91.82%   -0.04%     
==========================================
  Files          89       89              
  Lines       12080    12102      +22     
  Branches    12080    12102      +22     
==========================================
+ Hits        11097    11113      +16     
- Misses        876      882       +6     
  Partials      107      107              
Flag Coverage Δ
91.82% <36.84%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@alonh5 alonh5 force-pushed the 09-09-fall_back_to_cpu_in_small_fft_size branch 2 times, most recently from 7c85193 to da9d4c7 Compare September 9, 2024 13:10
Copy link
Contributor

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

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

Can all relevant tests be added please

Reviewable status: 0 of 4 files reviewed, 3 unresolved discussions (waiting on @alonh5 and @shaharsamocha7)


crates/prover/src/core/backend/simd/circle.rs line 148 at r1 (raw file):

        let log_size = eval.values.length.ilog2();
        if log_size < MIN_FFT_LOG_SIZE {
            let cpu_poly = CpuBackend::interpolate(eval.to_cpu(), &twiddles.to_cpu());

twiddles.to_cpu() could be very expensive.

Suggestion:

let cpu_poly = eval.to_cpu().interpolate();

crates/prover/src/core/backend/simd/circle.rs line 241 at r1 (raw file):

                &CirclePoly::new(poly.coeffs.to_cpu()),
                domain,
                &twiddles.to_cpu(),

Same here.


crates/prover/src/core/backend/simd/circle.rs line 244 at r1 (raw file):

            );
            return CircleEvaluation::new(
                cpu_eval.domain,

Won't this be expensive if cpu_domain is large?

@alonh5 alonh5 force-pushed the 09-09-fall_back_to_cpu_in_small_fft_size branch from da9d4c7 to 9dcd61b Compare September 15, 2024 11:10
Copy link
Contributor Author

@alonh5 alonh5 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 4 files reviewed, 3 unresolved discussions (waiting on @andrewmilson and @shaharsamocha7)


crates/prover/src/core/backend/simd/circle.rs line 148 at r1 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

twiddles.to_cpu() could be very expensive.

Done.


crates/prover/src/core/backend/simd/circle.rs line 241 at r1 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Same here.

Done.


crates/prover/src/core/backend/simd/circle.rs line 244 at r1 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Won't this be expensive if cpu_domain is large?

The worst it will be is 4 + log_blowup_factor. So it shouldn't be that bad, right?

Copy link
Contributor

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

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

:lgtm: with comment

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @alonh5 and @shaharsamocha7)


crates/prover/src/core/backend/simd/circle.rs line 229 at r2 (raw file):

    ) -> CircleEvaluation<Self, BaseField, BitReversedOrder> {
        // TODO(spapini): Precompute twiddles.
        // TODO(spapini): Handle small cases.

I think these can be removed now.

Code quote:

        // TODO(spapini): Precompute twiddles.
        // TODO(spapini): Handle small cases.

crates/prover/src/core/poly/twiddles.rs line 36 at r2 (raw file):

        }
    }
}

Can this be removed?

Code quote:

impl TwiddleTree<SimdBackend> {
    pub fn to_cpu(&self) -> TwiddleTree<CpuBackend> {
        TwiddleTree {
            root_coset: self.root_coset,
            twiddles: self
                .twiddles
                .iter()
                .map(|x| BaseField::from(x >> 1))
                .collect_vec(),
            itwiddles: self
                .itwiddles
                .iter()
                .map(|x| BaseField::from(x >> 1))
                .collect_vec(),
        }
    }
}

Copy link
Contributor Author

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

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

Fixed comments. Regarding the tests, there are still places where the minimum bound needs to be removed. I'm fixing it and will add tests in the next PR.

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @andrewmilson and @shaharsamocha7)


crates/prover/src/core/backend/simd/circle.rs line 229 at r2 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

I think these can be removed now.

Done.


crates/prover/src/core/poly/twiddles.rs line 36 at r2 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Can this be removed?

Done.

@alonh5 alonh5 force-pushed the 09-09-fall_back_to_cpu_in_small_fft_size branch from 9dcd61b to cced27f Compare September 16, 2024 07:10
Copy link
Contributor

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 0 of 4 files reviewed, all discussions resolved (waiting on @shaharsamocha7)

@alonh5 alonh5 force-pushed the 09-09-fall_back_to_cpu_in_small_fft_size branch from cced27f to 77b7cdd Compare September 17, 2024 13:18
Copy link
Contributor Author

alonh5 commented Sep 24, 2024

Merge activity

  • Sep 24, 4:47 AM EDT: @alonh5 started a stack merge that includes this pull request via Graphite.
  • Sep 24, 4:47 AM EDT: @alonh5 merged this pull request with Graphite.

@alonh5 alonh5 merged commit 9085df4 into dev Sep 24, 2024
15 of 17 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