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

Fallback to CPU in small size. #824

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion crates/prover/src/core/backend/simd/quotients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::m31::{PackedBaseField, LOG_N_LANES, N_LANES};
use super::qm31::PackedSecureField;
use super::SimdBackend;
use crate::core::backend::cpu::quotients::{batch_random_coeffs, column_line_coeffs};
use crate::core::backend::Column;
use crate::core::backend::{Column, CpuBackend};
use crate::core::fields::m31::BaseField;
use crate::core::fields::qm31::SecureField;
use crate::core::fields::secure_column::{SecureColumnByCoords, SECURE_EXTENSION_DEGREE};
Expand All @@ -36,6 +36,30 @@ impl QuotientOps for SimdBackend {
// Split the domain into a subdomain and a shift coset.
// TODO(spapini): Move to the caller when Columns support slices.
let (subdomain, mut subdomain_shifts) = domain.split(log_blowup_factor);
if subdomain.log_size() < LOG_N_LANES + 2 {
// Fall back to the CPU backend for small domains.
let columns = columns
.iter()
.map(|circle_eval| {
CircleEvaluation::<CpuBackend, _, BitReversedOrder>::new(
circle_eval.domain,
circle_eval.values.to_cpu(),
)
})
.collect_vec();
let eval = CpuBackend::accumulate_quotients(
domain,
&columns.iter().collect_vec(),
random_coeff,
sample_batches,
log_blowup_factor,
);

return SecureEvaluation::new(
domain,
SecureColumnByCoords::from_iter(eval.values.to_vec()),
);
}

// Bit reverse the shifts.
// Since we traverse the domain in bit-reversed order, we need bit-reverse the shifts.
Expand Down
Loading