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

[Experiment] new zkVM design #91

Merged
merged 52 commits into from
Aug 23, 2024

Conversation

hero78119
Copy link
Collaborator

@hero78119 hero78119 commented Jul 25, 2024

Issue link:
#102

An attempt to implemenet new zkVM based on proposed design https://hackmd.io/@P4deJs5uRSyvHnXF8yyQJQ/B1DpOQDOA

Design Rationales

The concept of representing a computation DAG in main constraints is based on Expression, inspired significantly by the Halo2 expression design. While it may be less expressive than the GKR graph, it is sufficiently capable of covering the required syntax for implementing opcode constraints in zkVM.

The new codebase is initially mixed with the existing singer and singer-util frameworks to maximize reuse. Later, we can transition the new logic into a standalone package.

Tasks breakdown

  • skeleton: circuit_builder + expression framework for main constraints circuit construction
  • prover & verifier framework
    • prover: main constraint sel witness infer + sumcheck
    • prover: tower constraint read/write witness infer + sumcheck
    • prover: tower constraint lookup witness infer + sumcheck
    • prover: main constraint degree > 1 sumcheck
    • verifier: tower constraint verification
    • add benchmark

      with command RAYON_NUM_THREADS=16 cargo bench --bench riscv_add --package ceno_zkvm on 1. For 2^20 riscv add instances on b6e9ecb is 1.4s (without pcs), roughly 749k Hz

  • opcode (riscv)
    • add

Footnotes

  1. AMD EPYC 9R14 (16 phy cores) + 32GB memory

circuit witness: direct witness on mle

devirgo style on phase1_output
@hero78119 hero78119 marked this pull request as draft July 25, 2024 09:30
@hero78119 hero78119 changed the title [WIP] new zkVM design [Experiment] new zkVM design Jul 25, 2024
@hero78119 hero78119 force-pushed the feat/new_zkvm_design branch from 1f3718f to 092fd95 Compare July 29, 2024 06:30
@hero78119 hero78119 force-pushed the feat/new_zkvm_design branch from 155c8a5 to 7676067 Compare July 29, 2024 15:01
@hero78119 hero78119 force-pushed the feat/new_zkvm_design branch 3 times, most recently from 2770233 to 3577903 Compare July 31, 2024 17:02
@hero78119 hero78119 force-pushed the feat/new_zkvm_design branch from 3577903 to bd7771b Compare August 1, 2024 07:52
@hero78119 hero78119 force-pushed the feat/new_zkvm_design branch from de01819 to f3afaeb Compare August 1, 2024 15:33
@hero78119 hero78119 force-pushed the feat/new_zkvm_design branch from 7189eaf to b6e9ecb Compare August 2, 2024 02:07
@hero78119 hero78119 force-pushed the feat/new_zkvm_design branch from 7d7a38f to 61be42e Compare August 14, 2024 13:19
@hero78119
Copy link
Collaborator Author

from @dreamATD Shall we compute the combination of all polynomials multiplied by sel as a single MLE and just add one equation RHS = sel * MLE?

This is a worth direction of trying. First attempt PR to aggregate all degree=1 MLEs then times selector
#129

Based on benchmark result it cause 5% throughtput drop on 2^20 add instance benchmark. From the first glance, there are pros/cons for this change. Therefore I just raise a separate PR for future effort.

@kunxian-xia kunxian-xia mentioned this pull request Aug 15, 2024
@kunxian-xia kunxian-xia changed the title [Experiment] new zkVM design #95 [Experiment] new zkVM design Aug 16, 2024
@hero78119 hero78119 force-pushed the feat/new_zkvm_design branch from a8fb0b4 to 8fb69ab Compare August 16, 2024 13:38
Copy link
Collaborator

@kunxian-xia kunxian-xia left a comment

Choose a reason for hiding this comment

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

Finished review of verifier part. This PR looks good to me.

@dreamATD dreamATD self-requested a review August 20, 2024 02:49
@hero78119 hero78119 force-pushed the feat/optimize_witness_cloning branch from 9794631 to 8fdfd0b Compare August 20, 2024 08:50
ceno_zkvm/src/instructions/riscv/constants.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/scheme/verifier.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/scheme/prover.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/scheme/verifier.rs Outdated Show resolved Hide resolved
@dreamATD dreamATD self-requested a review August 22, 2024 06:15
@hero78119 hero78119 force-pushed the feat/new_zkvm_design branch from f506362 to 5a17c0f Compare August 23, 2024 06:43
@kunxian-xia kunxian-xia merged commit 52dd9ea into feat/optimize_witness_cloning Aug 23, 2024
3 of 4 checks passed
kunxian-xia pushed a commit that referenced this pull request Aug 23, 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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants