Skip to content

Use NativeSumcheck for calculating initial_sum#1249

Open
darth-cy wants to merge 59 commits intomasterfrom
feat/sum_replace
Open

Use NativeSumcheck for calculating initial_sum#1249
darth-cy wants to merge 59 commits intomasterfrom
feat/sum_replace

Conversation

@darth-cy
Copy link
Collaborator

@darth-cy darth-cy commented Jan 29, 2026

Optimization for Calculating Initial Sum in tower verify.

  • Remove dot product logic for calculating initial_sum. Use NativeSumcheck instead.
  • Flatten out evaluation arrays.
  • Remove arithmetic utilities no longer required.

Optimization for NativeSumcheck

  • Use the additional mode on NativeSumcheck chip that allows passing in hint space IDs for evaluation inputs instead of loading concrete witness arrays. This significantly reduces cycles involved in loading witnesses.

@kunxian-xia
Copy link
Collaborator

Please check scroll-tech/openvm#30 for new semantic of builder.sumcheck_layer_eval().

@hero78119
Copy link
Collaborator

hero78119 commented Feb 25, 2026

Confirmed total trace cell dropped to previous level after latest change

INFO     │  │  │  ┝━ i [info]: instructions_executed=5393514
┝━ i [info]: total_trace_cells = 1_311_247_850 (excluding preprocessed)

@kunxian-xia kunxian-xia added this pull request to the merge queue Feb 26, 2026
@kunxian-xia kunxian-xia removed this pull request from the merge queue due to a manual request Feb 26, 2026
Copy link
Collaborator

@hero78119 hero78119 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Collaborator

@hero78119 hero78119 left a comment

Choose a reason for hiding this comment

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

by latest benchmark, e2e will be degraded if we move initial sum calculation to native sumcheck. Here is result

https://github.com/scroll-tech/ceno-reth-benchmark/actions/runs/22661172708

As recursion will degraded for ~2s

I think probably we just make this PR scope smaller with only fix the soundness: second sumcheck_eval_layers read from array.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes the tower verification step in the recursive ZKVM verifier by replacing custom dot-product logic for calculating initial_sum with the NativeSumcheck chip, and flattening evaluation arrays to use HintSlice for more efficient witness loading. Additionally, it extracts the aggregate_internal_proofs method from generate_root_proof for reuse, adds a corresponding test, and updates the OpenVM dependency branch.

Changes:

  • Replace manual initial sum dot-product computation in tower verify with NativeSumcheck native opcode, using hint space IDs for evaluation inputs instead of loading concrete witness arrays
  • Flatten r_out_evals, w_out_evals, and lk_out_evals from Vec<Vec<E>> to Vec<E> and use HintSlice for serialization/deserialization, removing now-unused evaluate_at_point_degree_1 and nested_product utilities
  • Extract aggregate_internal_proofs as a standalone public method and add corresponding test infrastructure

Reviewed changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ceno_recursion/src/tower_verifier/program.rs Core change: replace manual initial_sum computation with NativeSumcheck via sumcheck_layer_eval, add hint ID mode support, flatten out eval array handling
ceno_recursion/src/zkvm_verifier/verifier.rs Adapt to new verify_tower_proof signature, compute chip_logup_sum after tower proof verification using flattened arrays, update prod_r/prod_w accumulation
ceno_recursion/src/zkvm_verifier/binding.rs Change eval arrays from nested Vec<Vec<E>> / Array<C, Array<C, ...>> to flat Vec<E> / HintSlice<C>, merge r/w evals into rw_out_evals
ceno_recursion/src/arithmetics/mod.rs Remove unused evaluate_at_point_degree_1 and nested_product functions
ceno_recursion/src/aggregation/mod.rs Extract aggregate_internal_proofs, add test, update VM_MAX_TRACE_HEIGHTS
ceno_recursion/src/aggregation/internal.rs Minor whitespace cleanup
ceno_zkvm/src/scheme/verifier.rs Cosmetic blank line addition
Cargo.toml Update OpenVM dependency branch to feat/hint_bridge
Cargo.lock Lockfile update for OpenVM branch change
.gitignore Add .srs file extension to gitignore

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

builder.set(&input_ctx, 5, Usize::from(1));
builder.set(&input_ctx, 6, Usize::from(4));
builder.set(&input_ctx, 7, Usize::from(0));
builder.set(&input_ctx, 8, Usize::from(999));
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The value 999 is used as a magic sentinel for input_ctx[8] (num_variables). While this likely works because input_ctx[7] (in_round flag) is 0 so this value may not be consumed, using an unexplained magic number is fragile. If the sumcheck_layer_eval implementation changes or the value is unexpectedly read, this could cause subtle bugs. Consider using a named constant or adding a comment explaining why this placeholder is safe to use.

Copilot uses AI. Check for mistakes.
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.

4 participants