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

optimize witness cloning #89

Merged
merged 5 commits into from
Aug 23, 2024
Merged

Conversation

hero78119
Copy link
Collaborator

This PR applied a widely refactor, and the goals is to avoid wire_in/wire_out clone between GKR nodes during proving. The core ideas are to

  • use DenseMultilinearExtension directly as input wire_in, avoiding extra overhead of LayerWitness conversion
  • introduce new RangedMultilinearExtension which wraps a reference of mle, plus a start/offset to specify which range belong to it. This can avoid layer poly creation per multi-threading.
  • In GKR-graph, wire-in/wire-out are cloning on Arc type without re-creation, and internally it's a shared reference for same vector. This achieve max extent reuse and improve prover memory usage.

This PR tried to prepare for the foundation for potiential widely refactor required from

A preliminary test shows 1.5x throughtput improvement on evm_add benchmark under instance size 2^11 - 14

@hero78119 hero78119 marked this pull request as draft July 11, 2024 10:19
@hero78119 hero78119 force-pushed the feat/optimize_witness_cloning branch from 18abe90 to 824a251 Compare July 11, 2024 13:04
@hero78119 hero78119 marked this pull request as ready for review July 15, 2024 02:54
@hero78119 hero78119 force-pushed the feat/optimize_witness_cloning branch 2 times, most recently from 9492c41 to 4226a3e Compare July 15, 2024 07:44
@hero78119 hero78119 force-pushed the ming/rewrite_phase1 branch from ad4a6d8 to e843bf1 Compare July 15, 2024 12:41
@hero78119 hero78119 force-pushed the feat/optimize_witness_cloning branch from 4226a3e to 9794631 Compare July 24, 2024 07:50
@hero78119 hero78119 changed the base branch from ming/rewrite_phase1 to master July 24, 2024 07:51
circuit witness: direct witness on mle

devirgo style on phase1_output
@hero78119 hero78119 force-pushed the feat/optimize_witness_cloning branch from 9794631 to 8fdfd0b Compare August 20, 2024 08:50
@hero78119 hero78119 force-pushed the feat/optimize_witness_cloning branch from 3843194 to 5ec37ec Compare August 21, 2024 03:46
@hero78119 hero78119 force-pushed the feat/optimize_witness_cloning branch from 8500503 to 392c770 Compare August 23, 2024 04:19
@hero78119 hero78119 changed the title [WIP] optimize witness cloning optimize witness cloning Aug 23, 2024
* optimize sumcheck algo

circuit witness: direct witness on mle

devirgo style on phase1_output

* initial version for new zkVM design

* riscv add prototype implementation

* add new zkVM prover

* new package ceno_zkvm

* record witness generation

* add transcript

* add verifier

* code cleanup

* rename expression

* prover record_r/record_w sumcheck

* main sel sumcheck proof/verify

* tower product witness inference

* tower product sumcheck prove/verify

* chores: fix tower sumcheck witness length error and clean up

* verify record and zero expression

* tower sumcheck prove/verify pass

* WIP test main sel prove/verify

* add benchmark

* chores: interleaving with default value

* main constraint sumcheck prove/verify pass

* chores: mock witness

* main constraint sumcheck verify final claim assertion pass

* restructure ceno_zkvm package

* refine expression format

* wip lookup

* lookup in logup implemetation with integration test pass

* chores: code cosmetics

* optimize with 2-stage sumcheck #103

* chores: refine virtual polys naming

* fix proper ts and pc counting

* try sumcheck bench

* refine global state in riscv

* degree > 1 main constraint sumcheck implementation #107 (#108)

* monomial expression to virtual poly

* degree > 1 sumcheck batched with main constraint

* succint selector evaluation

* refine succint selector evaluation formula and documentation

* wip fix interleaving edge case

* deal with interleaving_mles instance = 1 case

* chores: code cosmetics and address review comments

* fix logup padding with chip record challenge

* riscv opcode type & combine add/sub opcode & dependency trim

* ci whitelist ceno_zkvm lint/clippy

* address review comments and naming cosmetics

* remove unnessesary to_vec operation

* tower verifier logup p(x) constant check

* cleanup and hide thread-based logic

* soundness fix: derive new sumcheck batched challenge for each round

* fix sel evaluation point and add TODO check

* fix sumcheck batched challenge deriving order

* chore: rename pc step size & fine tune project structure

* fix lint error
@kunxian-xia kunxian-xia merged commit 0a40721 into master Aug 23, 2024
3 of 4 checks passed
@kunxian-xia kunxian-xia deleted the feat/optimize_witness_cloning branch September 24, 2024 16:17
hero78119 added a commit that referenced this pull request Sep 30, 2024
* optimize sumcheck algo

circuit witness: direct witness on mle

devirgo style on phase1_output

* temporarily exclude singer-pro from default workspace members

* fux build error in mpcs

* [Experiment] new zkVM design (#91)

* optimize sumcheck algo

circuit witness: direct witness on mle

devirgo style on phase1_output

* initial version for new zkVM design

* riscv add prototype implementation

* add new zkVM prover

* new package ceno_zkvm

* record witness generation

* add transcript

* add verifier

* code cleanup

* rename expression

* prover record_r/record_w sumcheck

* main sel sumcheck proof/verify

* tower product witness inference

* tower product sumcheck prove/verify

* chores: fix tower sumcheck witness length error and clean up

* verify record and zero expression

* tower sumcheck prove/verify pass

* WIP test main sel prove/verify

* add benchmark

* chores: interleaving with default value

* main constraint sumcheck prove/verify pass

* chores: mock witness

* main constraint sumcheck verify final claim assertion pass

* restructure ceno_zkvm package

* refine expression format

* wip lookup

* lookup in logup implemetation with integration test pass

* chores: code cosmetics

* optimize with 2-stage sumcheck #103

* chores: refine virtual polys naming

* fix proper ts and pc counting

* try sumcheck bench

* refine global state in riscv

* degree > 1 main constraint sumcheck implementation #107 (#108)

* monomial expression to virtual poly

* degree > 1 sumcheck batched with main constraint

* succint selector evaluation

* refine succint selector evaluation formula and documentation

* wip fix interleaving edge case

* deal with interleaving_mles instance = 1 case

* chores: code cosmetics and address review comments

* fix logup padding with chip record challenge

* riscv opcode type & combine add/sub opcode & dependency trim

* ci whitelist ceno_zkvm lint/clippy

* address review comments and naming cosmetics

* remove unnessesary to_vec operation

* tower verifier logup p(x) constant check

* cleanup and hide thread-based logic

* soundness fix: derive new sumcheck batched challenge for each round

* fix sel evaluation point and add TODO check

* fix sumcheck batched challenge deriving order

* chore: rename pc step size & fine tune project structure

* fix lint error
@matthiasgoergens
Copy link
Collaborator

This broke singer-pro.

hero78119 pushed a commit that referenced this pull request Oct 14, 2024
Fixes #313

Commit 0a40721 from
#89 broke `singer-pro`. At least
judging by whether `cargo check` succeeds. It even has a commit about
that [temporarily exclude singer-pro from default workspace
members](5ec37ec).

Please restore `singer-pro` from the git history, if/when you need it
again.

Also remove `singer/examples/add-v2-old-sc-bak.rs` which was broken by
the same commit. The filename suggests it was kept around as a 'backup'?
(Please, have some more faith in git's ability to keep history!)
}

const VALUE_BIT_WIDTH: usize = 16;
pub type WitnessId = u16;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did we go with u16 here?

@hero78119 @bgillesp

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