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

Questions about benchmark codes in ceno_zkvm #778

Open
grandchildrice opened this issue Dec 20, 2024 · 2 comments
Open

Questions about benchmark codes in ceno_zkvm #778

grandchildrice opened this issue Dec 20, 2024 · 2 comments

Comments

@grandchildrice
Copy link

Hello Ceno team. I am a master student at Waseda University and a PSE grantee.

I am currently doing research on zkVM on my own, working on parallel Jolt implementation and benchmarking each zkVM method. My benchmarking repository can be found here.

https://github.com/grandchildrice/zkvm-benchmarks

So I have a few questions about the current implementation of Ceno.

Q1. Which Rust code is compiled and used in the Fibonacci benchmark?
I would like to run it with 50500000 in max_steps (which is equivalent to 1M-th fibonacci in RISC Zero). So I want to make sure that all of those max_steps are really executed.
In addition, I would like to compile the following Rust code that performs matrix operations into ELF and benchmark it as well. I want to do this because I want to compare it against a memory-intensive program. I know that generating proofs for this program in Nexus or Jolt is obviously very time consuming compared to Fibonacci.

fn matrix_ops(n: usize) -> u64 {
    let matrix_a: Vec<Vec<f32>> = (0..n)
        .map(|i| (0..n).map(|j| (i + j) as f32).collect())
        .collect();

    let matrix_b: Vec<Vec<f32>> = (0..n)
        .map(|i| (0..n).map(|j| (i * j) as f32).collect())
        .collect();

    let mut result = vec![vec![0f32; n]; n];

    for i in 0..n {
        for j in 0..n {
            for k in 0..n {
                result[i][j] += matrix_a[i][k] * matrix_b[k][j];
            }
        }
    }

    result[0][0] as u64
}

Q2. Is proof aggregation already implemented in Ceno?
As the size of opcode_proof seemed to increase with the number of cycles. I would like to include the time up to proof aggregation to make a fair comparison with other methods.

@hero78119
Copy link
Collaborator

hero78119 commented Dec 20, 2024

Hi,

Ceno team still working on build fibonacci elf via other zkVM toolchain for upcoming apple-to-apple benchmarks with other zkVM as well. So for current repo there is no fibonacci guest program yet.

But there are some existing guest program, although I haven't fully verified all the flow, just shared wish it helpful.

  • guest program
    you can try to put your guest program under examples
    and register here for it to be build
    https://github.com/scroll-tech/ceno/blob/master/examples-builder/build.rs#L11-L21

  • test generating witness on host: this flow just verify elf format, load into emulator and execute. it doesn't cover real prove
    for example,

    use rand::Rng;
    let mut hints = CenoStdin::default();
    let mut rng = rand::thread_rng();
    // Provide some random numbers to sort.
    hints.write(&(0..1000).map(|_| rng.gen::<u32>()).collect::<Vec<_>>())?;
    let all_messages = ceno_host::run(CENO_PLATFORM, ceno_examples::sorting, &hints);
    for (i, msg) in enumerate(&all_messages) {
    println!("{i}: {msg}");
    }
    Ok(())

  • e2e integration
    to load elf + run the execution e2e, you can refer to these command

    run: cargo run --package ceno_zkvm --bin e2e -- --platform=sp1 ceno_zkvm/examples/fibonacci.elf

https://github.com/scroll-tech/ceno/blob/master/ceno_zkvm/examples/fibonacci.elf it's built from SP1 toolchain. We haven't commit source and ceno toolchain still WIP

Although its unstable and not ready for benchmark yet, feel free to give it a try first!

@grandchildrice
Copy link
Author

Thank you! I'll try them!

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

No branches or pull requests

2 participants