Skip to content

Commit 8c2d257

Browse files
darth-cyRay Gao
andauthored
Native Sumcheck Layer Evaluation (#8)
* Add native sumcheck chip * Complete sumcheck layer execution logic * Remove debug flags * Add variation * Cherry pick column reduction commits * Add record assignments * Adjust unit test * Correct header row register reads * Correct header row register reads * Correct header row register read * Correct rw records for prod rows * Debug constraints * Debug constraints * Debug constraints * Debug constraints * Debug constraints * Debug constraints * Debug constraints * Degree reduction * Reduce degree * Reduce degree * Disable debug flag * Debug constraints * Recover constraints * Debug constraints * Debug constraints * Debug constraints * Debug constraints * Debug constraints: * Debug constraints * Debug constraints * Debug constraints * Debug constraints * Debug constraints * Add debug flag * Remove debug flags * Debug constraint * Correct constraints * Remove debug flags * Prover field access * Remove debug flag * Add documentation * Adjust documentation * Add documentation --------- Co-authored-by: Ray Gao <[email protected]>
1 parent 9b7591d commit 8c2d257

File tree

20 files changed

+1721
-21
lines changed

20 files changed

+1721
-21
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Cargo.lock
99
**/.env
1010
.DS_Store
1111

12+
# Log outputs
13+
*.log
14+
1215
.cache/
1316
rustc-*
1417

crates/sdk/src/prover/agg.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ use crate::{
2323
};
2424

2525
pub struct AggStarkProver<E: StarkFriEngine<SC>> {
26-
leaf_prover: VmLocalProver<SC, NativeConfig, E>,
27-
leaf_controller: LeafProvingController,
26+
pub leaf_prover: VmLocalProver<SC, NativeConfig, E>,
27+
pub leaf_controller: LeafProvingController,
2828

29-
internal_prover: VmLocalProver<SC, NativeConfig, E>,
30-
root_prover: RootVerifierLocalProver,
29+
pub internal_prover: VmLocalProver<SC, NativeConfig, E>,
30+
pub root_prover: RootVerifierLocalProver,
3131

3232
pub num_children_internal: usize,
3333
pub max_internal_wrapper_layers: usize,

extensions/native/circuit/src/extension.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ use openvm_circuit_derive::{AnyEnum, InstructionExecutor, VmConfig};
1515
use openvm_circuit_primitives_derive::{Chip, ChipUsageGetter};
1616
use openvm_instructions::{program::DEFAULT_PC_STEP, LocalOpcode, PhantomDiscriminant};
1717
use openvm_native_compiler::{
18-
CastfOpcode, FieldArithmeticOpcode, FieldExtensionOpcode, FriOpcode, NativeBranchEqualOpcode,
19-
NativeJalOpcode, NativeLoadStore4Opcode, NativeLoadStoreOpcode, NativePhantom,
20-
NativeRangeCheckOpcode, Poseidon2Opcode, VerifyBatchOpcode, BLOCK_LOAD_STORE_SIZE,
18+
CastfOpcode, FieldArithmeticOpcode, FieldExtensionOpcode, FriOpcode, NativeBranchEqualOpcode, NativeJalOpcode, NativeLoadStore4Opcode, NativeLoadStoreOpcode, NativePhantom, NativeRangeCheckOpcode, Poseidon2Opcode, SumcheckOpcode, VerifyBatchOpcode, BLOCK_LOAD_STORE_SIZE
2119
};
2220
use openvm_poseidon2_air::Poseidon2Config;
2321
use openvm_rv32im_circuit::{
@@ -29,10 +27,7 @@ use serde::{Deserialize, Serialize};
2927
use strum::IntoEnumIterator;
3028

3129
use crate::{
32-
adapters::{convert_adapter::ConvertAdapterChip, *},
33-
poseidon2::chip::NativePoseidon2Chip,
34-
phantom::*,
35-
*,
30+
adapters::{convert_adapter::ConvertAdapterChip, *}, phantom::*, poseidon2::chip::NativePoseidon2Chip, sumcheck::chip::NativeSumcheckChip, *
3631
};
3732

3833
#[derive(Clone, Debug, Serialize, Deserialize, VmConfig, derive_new::new)]
@@ -76,6 +71,7 @@ pub enum NativeExecutor<F: PrimeField32> {
7671
FieldExtension(FieldExtensionChip<F>),
7772
FriReducedOpening(FriReducedOpeningChip<F>),
7873
VerifyBatch(NativePoseidon2Chip<F, 1>),
74+
SumcheckLayerEval(NativeSumcheckChip<F>),
7975
}
8076

8177
#[derive(From, ChipUsageGetter, Chip, AnyEnum)]
@@ -207,6 +203,17 @@ impl<F: PrimeField32> VmExtension<F> for Native {
207203
],
208204
)?;
209205

206+
let sumcheck_chip = NativeSumcheckChip::new(
207+
builder.system_port(),
208+
offline_memory.clone(),
209+
);
210+
inventory.add_executor(
211+
sumcheck_chip,
212+
[
213+
SumcheckOpcode::SUMCHECK_LAYER_EVAL.global_opcode(),
214+
]
215+
)?;
216+
210217
builder.add_phantom_sub_executor(
211218
NativeHintInputSubEx,
212219
PhantomDiscriminant(NativePhantom::HintInput as u16),

extensions/native/circuit/src/field_extension/core.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,10 @@ impl FieldExtension {
245245

246246
pub(crate) fn add<V, E>(x: [V; EXT_DEG], y: [V; EXT_DEG]) -> [E; EXT_DEG]
247247
where
248-
V: Copy,
248+
V: Clone,
249249
V: Add<V, Output = E>,
250250
{
251-
array::from_fn(|i| x[i] + y[i])
251+
array::from_fn(|i| x[i].clone() + y[i].clone())
252252
}
253253

254254
pub(crate) fn subtract<V, E>(x: [V; EXT_DEG], y: [V; EXT_DEG]) -> [E; EXT_DEG]

extensions/native/circuit/src/fri/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ fn assert_array_eq<AB: AirBuilder, I1: Into<AB::Expr>, I2: Into<AB::Expr>, const
538538
}
539539
}
540540

541-
fn elem_to_ext<F: Field>(elem: F) -> [F; EXT_DEG] {
541+
pub fn elem_to_ext<F: Field>(elem: F) -> [F; EXT_DEG] {
542542
let mut ret = [F::ZERO; EXT_DEG];
543543
ret[0] = elem;
544544
ret

extensions/native/circuit/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod fri;
88
mod jal;
99
mod loadstore;
1010
mod poseidon2;
11+
mod sumcheck;
1112

1213
pub use branch_eq::*;
1314
pub use castf::*;
@@ -17,6 +18,7 @@ pub use fri::*;
1718
pub use jal::*;
1819
pub use loadstore::*;
1920
pub use poseidon2::*;
21+
pub use sumcheck::*;
2022

2123
mod extension;
2224
pub use extension::*;

extensions/native/circuit/src/poseidon2/trace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use openvm_stark_backend::{
1515
};
1616

1717
use crate::{
18-
chip::TranscriptObservationRecord, poseidon2::{
18+
poseidon2::{
1919
chip::{
20-
CellRecord, IncorporateRowRecord, IncorporateSiblingRecord, InsideRowRecord, NativePoseidon2Chip, SimplePoseidonRecord, VerifyBatchRecord, NUM_INITIAL_READS
20+
TranscriptObservationRecord, CellRecord, IncorporateRowRecord, IncorporateSiblingRecord, InsideRowRecord, NativePoseidon2Chip, SimplePoseidonRecord, VerifyBatchRecord, NUM_INITIAL_READS
2121
},
2222
columns::{
2323
InsideRowSpecificCols, MultiObserveCols, NativePoseidon2Cols, SimplePoseidonSpecificCols, TopLevelSpecificCols

0 commit comments

Comments
 (0)