From a4afa104e9f1c26b046ef9f718124b94de04bde0 Mon Sep 17 00:00:00 2001 From: VitaliiH Date: Thu, 30 Jan 2025 12:42:18 +0100 Subject: [PATCH] passing fib --- Cargo.lock | 8 ++++---- crates/prover/Cargo.toml | 8 ++++---- .../prover/src/core/backend/icicle/accumulation.rs | 2 ++ crates/prover/src/core/backend/icicle/circle.rs | 6 ++++-- crates/prover/src/core/poly/circle/poly.rs | 2 +- crates/prover/src/examples/wide_fibonacci/mod.rs | 12 ++++++++++-- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ff948a2e..2b4056a49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -754,7 +754,7 @@ dependencies = [ [[package]] name = "icicle-core" version = "2.8.0" -source = "git+https://github.com/ingonyama-zk/icicle.git?rev=36199464e0d19ebdebd0a7c26e914f94e29afb23#36199464e0d19ebdebd0a7c26e914f94e29afb23" +source = "git+https://github.com/ingonyama-zk/icicle.git?rev=5f0eaf226c1432277421a6095fd758b03fc20510#5f0eaf226c1432277421a6095fd758b03fc20510" dependencies = [ "criterion 0.3.6", "hex", @@ -765,7 +765,7 @@ dependencies = [ [[package]] name = "icicle-cuda-runtime" version = "2.8.0" -source = "git+https://github.com/ingonyama-zk/icicle.git?rev=36199464e0d19ebdebd0a7c26e914f94e29afb23#36199464e0d19ebdebd0a7c26e914f94e29afb23" +source = "git+https://github.com/ingonyama-zk/icicle.git?rev=5f0eaf226c1432277421a6095fd758b03fc20510#5f0eaf226c1432277421a6095fd758b03fc20510" dependencies = [ "bindgen", "bitflags 1.3.2", @@ -774,7 +774,7 @@ dependencies = [ [[package]] name = "icicle-hash" version = "2.8.0" -source = "git+https://github.com/ingonyama-zk/icicle.git?rev=36199464e0d19ebdebd0a7c26e914f94e29afb23#36199464e0d19ebdebd0a7c26e914f94e29afb23" +source = "git+https://github.com/ingonyama-zk/icicle.git?rev=5f0eaf226c1432277421a6095fd758b03fc20510#5f0eaf226c1432277421a6095fd758b03fc20510" dependencies = [ "cmake", "icicle-core", @@ -784,7 +784,7 @@ dependencies = [ [[package]] name = "icicle-m31" version = "2.8.0" -source = "git+https://github.com/ingonyama-zk/icicle.git?rev=36199464e0d19ebdebd0a7c26e914f94e29afb23#36199464e0d19ebdebd0a7c26e914f94e29afb23" +source = "git+https://github.com/ingonyama-zk/icicle.git?rev=5f0eaf226c1432277421a6095fd758b03fc20510#5f0eaf226c1432277421a6095fd758b03fc20510" dependencies = [ "cmake", "criterion 0.3.6", diff --git a/crates/prover/Cargo.toml b/crates/prover/Cargo.toml index f07b30cf3..44de922f1 100644 --- a/crates/prover/Cargo.toml +++ b/crates/prover/Cargo.toml @@ -28,10 +28,10 @@ tracing.workspace = true rayon = { version = "1.10.0", optional = true } serde = { version = "1.0", features = ["derive"] } -icicle-cuda-runtime = { git = "https://github.com/ingonyama-zk/icicle.git", optional = true, rev="9511396f0685a004ada6f52791b898ccdc092a43"} -icicle-core = { git = "https://github.com/ingonyama-zk/icicle.git", optional = true, rev="9511396f0685a004ada6f52791b898ccdc092a43"} -icicle-m31 = { git = "https://github.com/ingonyama-zk/icicle.git", optional = true, rev="9511396f0685a004ada6f52791b898ccdc092a43"} -icicle-hash = { git = "https://github.com/ingonyama-zk/icicle.git", optional = true, rev="9511396f0685a004ada6f52791b898ccdc092a43"} +icicle-cuda-runtime = { git = "https://github.com/ingonyama-zk/icicle.git", optional = true, rev="5f0eaf226c1432277421a6095fd758b03fc20510"} +icicle-core = { git = "https://github.com/ingonyama-zk/icicle.git", optional = true, rev="5f0eaf226c1432277421a6095fd758b03fc20510"} +icicle-m31 = { git = "https://github.com/ingonyama-zk/icicle.git", optional = true, rev="5f0eaf226c1432277421a6095fd758b03fc20510"} +icicle-hash = { git = "https://github.com/ingonyama-zk/icicle.git", optional = true, rev="5f0eaf226c1432277421a6095fd758b03fc20510"} nvtx = { version = "*", optional = true } diff --git a/crates/prover/src/core/backend/icicle/accumulation.rs b/crates/prover/src/core/backend/icicle/accumulation.rs index d5c2e7d69..3acfd4df0 100644 --- a/crates/prover/src/core/backend/icicle/accumulation.rs +++ b/crates/prover/src/core/backend/icicle/accumulation.rs @@ -44,6 +44,8 @@ mod tests { #[cfg(feature = "icicle")] #[test] fn test_accumulate() { + use crate::core::fields::m31::BaseField; + let a_h = vec![SecureField::zero(); 8]; let mut column = SecureColumnByCoords::from_iter(a_h.clone()); let mut cpu_column = SecureColumnByCoords::from_iter(a_h); diff --git a/crates/prover/src/core/backend/icicle/circle.rs b/crates/prover/src/core/backend/icicle/circle.rs index ae418699d..60dea23be 100644 --- a/crates/prover/src/core/backend/icicle/circle.rs +++ b/crates/prover/src/core/backend/icicle/circle.rs @@ -106,8 +106,10 @@ impl PolyOps for IcicleBackend { } fn extend(poly: &CirclePoly, log_size: u32) -> CirclePoly { - todo!() - // unsafe { transmute(CpuBackend::extend(transmute(poly), log_size)) } + assert!(log_size >= poly.log_size()); + let count_zeros_to_extend = 1 << (log_size-1) - poly.coeffs.len() as u32; + let coeffs = DeviceVec::cuda_malloc_extend_with_zeros(&poly.coeffs.data, count_zeros_to_extend).unwrap(); + CirclePoly::new(DeviceColumn {data: coeffs}) } fn evaluate( diff --git a/crates/prover/src/core/poly/circle/poly.rs b/crates/prover/src/core/poly/circle/poly.rs index 6744a0c80..f8fdbdc59 100644 --- a/crates/prover/src/core/poly/circle/poly.rs +++ b/crates/prover/src/core/poly/circle/poly.rs @@ -29,7 +29,7 @@ impl CirclePoly { /// /// Panics if the number of coefficients isn't a power of two. pub fn new(coeffs: Col) -> Self { - assert!(coeffs.len().is_power_of_two()); + assert!(coeffs.len().is_power_of_two(), "coefficients length must be power of 2, got: {}", coeffs.len()); let log_size = coeffs.len().ilog2(); Self { log_size, coeffs } } diff --git a/crates/prover/src/examples/wide_fibonacci/mod.rs b/crates/prover/src/examples/wide_fibonacci/mod.rs index 491ef8c8f..498a27251 100644 --- a/crates/prover/src/examples/wide_fibonacci/mod.rs +++ b/crates/prover/src/examples/wide_fibonacci/mod.rs @@ -250,6 +250,9 @@ mod tests { #[test] #[cfg(feature = "icicle")] fn test_wide_fib_prove_with_blake_icicle() { + use icicle_cuda_runtime::memory::HostSlice; + + use crate::core::backend::icicle::column::DeviceColumn; use crate::core::backend::icicle::IcicleBackend; // use crate::core::backend::CpuBackend; use crate::core::fields::m31::M31; @@ -286,13 +289,18 @@ mod tests { tree_builder.extend_evals([]); tree_builder.commit(prover_channel); nvtx::range_pop!(); - + use icicle_cuda_runtime::memory::DeviceVec; // Trace. nvtx::range_push!("Generate trace"); + type IcicleCircleEvaluation = CircleEvaluation; let trace: Vec> = generate_test_trace(log_n_instances) .iter() - .map(|c| unsafe { std::mem::transmute(c.to_cpu()) }) + .map(|c| { + let mut values = DeviceVec::cuda_malloc(c.values.len()).unwrap(); + values.copy_from_host(HostSlice::from_slice(&c.values.to_cpu())).unwrap(); + IcicleCircleEvaluation::new(c.domain, DeviceColumn { data: values }) + }) .collect_vec(); let mut tree_builder = commitment_scheme.tree_builder();