Open ed255 opened 8 months ago
One important thing aside of https://github.com/privacy-scaling-explorations/halo2/pull/274 would be to check in Halo2 if we can drop polynomials earlier than fn scope ends and drop gets triggered.
On this way we might be able (if the compiler is not already doing so) to reduce it a bit.
Recently @han0110 did an analysis of peak memory estimation for halo2 proving, with a script implementation that takes a
ConstraintSystem
and estimates the peak memory of the prover. I ported that script to the zkevm-circuits and it can be seen here: https://github.com/privacy-scaling-explorations/zkevm-circuits/blob/3bbc757a20d9d9f7759db47c096d5395361bee74/zkevm-circuits/src/bin/stats/halo2_stats.rs#L232Recently I ran some benchmarks with this test circuit in https://github.com/privacy-scaling-explorations/halo2/blob/1650a0b07fbbfeebab71f5650ccb62ccd20de0ff/halo2_proofs/tests/frontend_backend_split.rs to measure the peak memory and verify how accurate the estimation is, and I'm happy to report that the estimation is very accurate!
These are the characteristics of the circuit (where
wf
is theWIDTH_FACTOR
and can be parametrized):These are the results for
k = 10,12,14,16,18
andwf = 1,2,3,4,5,6
(memory values in MiB):The estimation is ~98% of the measured peak memory. You can reproduce these tests from this branch https://github.com/privacy-scaling-explorations/halo2/tree/test/bench-mem-peak using this script https://github.com/privacy-scaling-explorations/halo2/blob/test/bench-mem-peak/halo2_proofs/bench.sh
Discussion
I think it would be nice to add this estimation into the code. Maybe it can be a
halo2_backend
function that receives aConstraintSystemMid
and returns the estimated memory? This way different backends can report different memory estimations.Another point of discussion is that it would be great to figure out the new memory estimation formula from https://github.com/privacy-scaling-explorations/halo2/pull/274