Closed ulbqb closed 7 months ago
Yes, you can setup the seg size to 8192.
I tried it but some proving failed.
version: 88c138bb0f62334475c54e0a02f11bee527e8ce1
$ rustup show
Default host: aarch64-unknown-linux-gnu
rustup home: /root/.rustup
installed toolchains
--------------------
stable-aarch64-unknown-linux-gnu (default)
nightly-aarch64-unknown-linux-gnu
1.69.0-aarch64-unknown-linux-gnu
active toolchain
----------------
nightly-aarch64-unknown-linux-gnu (overridden by 'workspace/zkm/rust-toolchain.toml')
rustc 1.78.0-nightly (46b180ec2 2024-03-08)
$ BASEDIR=test-vectors RUST_LOG=info BLOCK_NO=13284491 SEG_FILE="/tmp/output/14" SEG_SIZE=8192 cargo run --release --example zkmips prove
Finished `release` profile [optimized] target(s) in 1.23s
Running `target/release/examples/zkmips prove`
[2024-03-15T16:35:49Z INFO mips_circuits::cpu::bootstrap_kernel] Bootstrapping took 12645 cycles
[2024-03-15T16:35:49Z INFO mips_circuits::generation] CPU halted after 20837 cycles
[2024-03-15T16:35:49Z INFO mips_circuits::generation] CPU trace padded to 32768 cycles
[2024-03-15T16:35:49Z INFO mips_circuits::generation] Trace lengths (before padding): TraceCheckpoint { arithmetic_len: 921, cpu_len: 32768, keccak_len: 72936, keccak_sponge_len: 3039, logic_len: 104099, memory_len: 539975 }
Killed
$ BASEDIR=test-vectors RUST_LOG=info BLOCK_NO=13284491 SEG_FILE="/tmp/output/21" SEG_SIZE=8192 cargo run --release --example zkmips prove
Finished `release` profile [optimized] target(s) in 0.54s
Running `target/release/examples/zkmips prove`
[2024-03-15T16:01:59Z INFO mips_circuits::cpu::bootstrap_kernel] Bootstrapping took 11742 cycles
[2024-03-15T16:01:59Z INFO mips_circuits::generation] CPU halted after 19934 cycles
[2024-03-15T16:01:59Z INFO mips_circuits::generation] CPU trace padded to 32768 cycles
[2024-03-15T16:01:59Z INFO mips_circuits::generation] Trace lengths (before padding): TraceCheckpoint { arithmetic_len: 679, cpu_len: 32768, keccak_len: 67728, keccak_sponge_len: 2822, logic_len: 96314, memory_len: 505093 }
Killed
$ BASEDIR=test-vectors RUST_LOG=info BLOCK_NO=13284491 SEG_FILE="/tmp/output/22" SEG_SIZE=8192 cargo run --release --example zkmips prove
Finished `release` profile [optimized] target(s) in 1.06s
Running `target/release/examples/zkmips prove`
[2024-03-15T16:02:15Z INFO mips_circuits::cpu::bootstrap_kernel] Bootstrapping took 11484 cycles
[2024-03-15T16:02:15Z INFO mips_circuits::generation] CPU halted after 19676 cycles
[2024-03-15T16:02:15Z INFO mips_circuits::generation] CPU trace padded to 32768 cycles
[2024-03-15T16:02:15Z INFO mips_circuits::generation] Trace lengths (before padding): TraceCheckpoint { arithmetic_len: 946, cpu_len: 32768, keccak_len: 66240, keccak_sponge_len: 2760, logic_len: 94388, memory_len: 496056 }
Killed
$ BASEDIR=test-vectors RUST_LOG=info BLOCK_NO=13284491 SEG_FILE="/tmp/output/34" SEG_SIZE=8192 cargo run --release --example zkmips prove
Finished `release` profile [optimized] target(s) in 0.62s
Running `target/release/examples/zkmips prove`
[2024-03-15T16:16:29Z INFO mips_circuits::cpu::bootstrap_kernel] Bootstrapping took 11613 cycles
[2024-03-15T16:16:29Z INFO mips_circuits::generation] CPU halted after 19805 cycles
[2024-03-15T16:16:29Z INFO mips_circuits::generation] CPU trace padded to 32768 cycles
[2024-03-15T16:16:29Z INFO mips_circuits::generation] Trace lengths (before padding): TraceCheckpoint { arithmetic_len: 826, cpu_len: 32768, keccak_len: 66984, keccak_sponge_len: 2791, logic_len: 95434, memory_len: 500296 }
Killed
$ BASEDIR=test-vectors RUST_LOG=info BLOCK_NO=13284491 SEG_FILE="/tmp/output/35" SEG_SIZE=8192 cargo run --release --example zkmips prove
Finished `release` profile [optimized] target(s) in 1.19s
Running `target/release/examples/zkmips prove`
[2024-03-15T16:16:45Z INFO mips_circuits::cpu::bootstrap_kernel] Bootstrapping took 13935 cycles
[2024-03-15T16:16:45Z INFO mips_circuits::generation] CPU halted after 22127 cycles
[2024-03-15T16:16:45Z INFO mips_circuits::generation] CPU trace padded to 32768 cycles
[2024-03-15T16:16:45Z INFO mips_circuits::generation] Trace lengths (before padding): TraceCheckpoint { arithmetic_len: 671, cpu_len: 32768, keccak_len: 80376, keccak_sponge_len: 3349, logic_len: 114399, memory_len: 592908 }
Killed
$ BASEDIR=test-vectors RUST_LOG=info BLOCK_NO=13284491 SEG_FILE="/tmp/output/36" SEG_SIZE=8192 cargo run --release --example zkmips prove
Finished `release` profile [optimized] target(s) in 1.07s
Running `target/release/examples/zkmips prove`
[2024-03-15T16:17:01Z INFO mips_circuits::cpu::bootstrap_kernel] Bootstrapping took 15612 cycles
[2024-03-15T16:17:01Z INFO mips_circuits::generation] CPU halted after 23804 cycles
[2024-03-15T16:17:01Z INFO mips_circuits::generation] CPU trace padded to 32768 cycles
[2024-03-15T16:17:01Z INFO mips_circuits::generation] Trace lengths (before padding): TraceCheckpoint { arithmetic_len: 667, cpu_len: 32768, keccak_len: 90048, keccak_sponge_len: 3752, logic_len: 128086, memory_len: 659670 }
Killed
$ BASEDIR=test-vectors RUST_LOG=info BLOCK_NO=13284491 SEG_FILE="/tmp/output/38" SEG_SIZE=8192 cargo run --release --example zkmips prove
Finished `release` profile [optimized] target(s) in 0.71s
Running `target/release/examples/zkmips prove`
[2024-03-15T16:18:24Z INFO mips_circuits::cpu::bootstrap_kernel] Bootstrapping took 14967 cycles
[2024-03-15T16:18:24Z INFO mips_circuits::generation] CPU halted after 23159 cycles
[2024-03-15T16:18:24Z INFO mips_circuits::generation] CPU trace padded to 32768 cycles
[2024-03-15T16:18:24Z INFO mips_circuits::generation] Trace lengths (before padding): TraceCheckpoint { arithmetic_len: 613, cpu_len: 32768, keccak_len: 86328, keccak_sponge_len: 3597, logic_len: 122803, memory_len: 634219 }
Killed
I think a fast way is skipping the Memory Page Hash, you can comment out the codes at lines 54-56.
We are also trying to replace the Keccak with Poseidon to save memory.
Thanks, It works! But aggregation failed.
Okay, it's still the Out Of Memory error. We have to use a larger RAM machine right now. Maybe you can join our discord server, and discuss with our admin to see if we can help you find a suitable machine.
OK, I'll ask it in discord. What channel should I use?
@ulbqb I added a memory usage profiler in branch profile_mem, Can you check out to it, set up the RUST_LOG=debug, and share the log here?
@ulbqb from the log, we can see that your RAM is 32G, and the swap is 1G. Maybe you can increase the swap mem size to 20G.
And you can run the aggregate_proof
first, aggregate_proof
will aggregate 2 proofs into one, it consumes less memory than aggregate_proof_all
.
This is my script for debugging:
rm -rf /tmp/output/
BASEDIR=test-vectors RUST_LOG=trace ELF_PATH=test-vectors/hello BLOCK_NO=13284491 \
SEG_OUTPUT=/tmp/output SEG_SIZE=$1 cargo run --release --example zkmips split
BASEDIR=test-vectors RUST_LOG=debug BLOCK_NO=13284491 SEG_FILE="/tmp/output/0" SEG_SIZE=$1 \
cargo run --release --example zkmips prove
BASEDIR=test-vectors RUST_LOG=info BLOCK_NO=13284491 SEG_FILE="/tmp/output/0" SEG_FILE2="/tmp/output/1" SEG_SIZE=$1 \
cargo run --release --example zkmips aggregate_proof
run it with bash -x run.sh 1024
.
Missing preprocessed circuits for Cpu table with size 12
I could solve out of memory error by increasing swap space. I tried your script but I got this error on aggregate_proof
.
Okay, I have adjusted the degree_bits_ranges to support SEG_SIZE=1024 in branch profile_mem, just check out the latest code, the error will be fixed.
@ulbqb Any update from your test? I have checked that I can run the proof aggregation with seg size 1024 on my MACOS with 32G RAM. plz check out latest update in branch profile_mem.
https://github.com/ulbqb/zkm/commit/49433d665de4e3b16c747ec165816a3a8d10bf3e Your script worked by fixing a bit.
https://github.com/ulbqb/zkm/commit/11f9baf18c43f94a9e1a60f969def055407d3d42#diff-353cedb35844479af10559ad4937e171f0bff7a4c12103341946e70886fed7be Moreover, generating full proof was successful using above script. Of cause, verifying proof was successful too.
BTW, I don't know the way to generate full proof using aggregate_proof (not aggregate_proof_all). Could you provide full script?
@ulbqb you can use the latest degree bit range in branch profile_mem, it saves a lot of memory.
this comment is the full script using aggregate_proof, https://github.com/zkMIPS/zkm/issues/97#issuecomment-2002478404. BTW, you should setup RUST_LOG to debug to capture all the logs.
if you finish the aggregate_proof
, can you provide me the whole log?
But this uses only segment 0 and 1. If seg size is 1024, there are 300 seg fiiles. Is it ok not to use others?
And I can't get verifier directory using aggregate_proof.
if you want to aggregate an ELF program, you have to use aggregate_proof_all, which aggregates all the segments' proof.
I am unsure if you mean the Snark proof
which can be verified on chain. If so, I think you can not get it done in this repo.
https://docs.zkm.io/guides/proof-generation-guide I've thought that I must run both prove and aggregate_proof_all to generate aggregated proof but in practice I found only aggregate_proof_all is enough.
yes, you are correct, Feel free to submit a fix for the doc. cc @psinelnikov
Does ZKMIPS work with less than 48 GB of RAM?