Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(avm): support aliases in bb-pilcom (#7904)
Supports generating cpp variables for `pol x = sth` PIL aliases. * Cuts down 10k+ lines from poseidon2 and others * Improves `check_circuit` 62%! (a bit unexpected!) * I think what we see here is how much faster poseidon2 gets with this change. We see it in check_circuit and not in sumcheck because poseidon2 is skippable, which is enabled in sumcheck, but not in check circuit (and the test was on the token transfer). I'm pretty sure that if I prepare a 100% poseidon trace we'll see great improvements. * Improves sumcheck (~20%) * bugfix: Reduces the degree of some relations by 1 (max goes from 7 to 6) BEFORE (16 cores) ``` prove/all_ms: 24789 prove/check_circuit_ms: 16416 prove/create_composer_ms: 0 prove/create_prover_ms: 2580 prove/create_verifier_ms: 0 prove/execute_log_derivative_inverse_commitments_round_ms: 824 prove/execute_log_derivative_inverse_round_ms: 583 prove/execute_pcs_rounds_ms: 232 prove/execute_relation_check_rounds_ms: 2181 prove/execute_wire_commitments_round_ms: 240 prove/gen_trace_ms: 1592 ``` AFTER (16 cores) ``` prove/all_ms: 13272 prove/check_circuit_ms: 6278 prove/create_composer_ms: 0 prove/create_prover_ms: 1937 prove/create_verifier_ms: 0 prove/execute_log_derivative_inverse_commitments_round_ms: 776 prove/execute_log_derivative_inverse_round_ms: 584 prove/execute_pcs_rounds_ms: 202 prove/execute_relation_check_rounds_ms: 1742 prove/execute_wire_commitments_round_ms: 169 prove/gen_trace_ms: 1471 ``` On 1 cpu, the change is not as big but it still shaves 10s from check_circuit. BEFORE (1 cpu) ``` prove/all_ms: 86497 prove/check_circuit_ms: 38114 prove/create_composer_ms: 0 prove/create_prover_ms: 2045 prove/create_verifier_ms: 0 prove/execute_log_derivative_inverse_commitments_round_ms: 8561 prove/execute_log_derivative_inverse_round_ms: 7069 prove/execute_pcs_rounds_ms: 1899 prove/execute_relation_check_rounds_ms: 26534 prove/execute_wire_commitments_round_ms: 542 prove/gen_trace_ms: 1593 ``` AFTER (1 cpu) ``` prove/all_ms: 74197 prove/check_circuit_ms: 27675 prove/create_composer_ms: 0 prove/create_prover_ms: 2093 prove/create_verifier_ms: 0 prove/execute_log_derivative_inverse_commitments_round_ms: 8913 prove/execute_log_derivative_inverse_round_ms: 7263 prove/execute_pcs_rounds_ms: 1900 prove/execute_relation_check_rounds_ms: 24044 prove/execute_wire_commitments_round_ms: 552 prove/gen_trace_ms: 1618 ``` ---- TL;DR: Had to do a major refactor of the codegen. Will come back later to clean some of it up. I didn't want to, but I started pulling the thread and had to end up doing a lot of refactor/cleanup. The new version of the codegen is (imperceptibly) slower (some things are traversed several times), but I think cleaner. VM Builder * Separated computation of columns * Cleaned up lots of args that were passed to handlebars but not used anymore * Separated computation of shifts Lookups and permutations * Separated the NAME of the lookup/perm and the name of the inverse column Relation builder * Most important work is here * Recurse expressions and look for aliases * Filtering only the used aliases per file was a bit tough: had to take the transitive closure of the alises used in the relations * Fixed degree of constant polynomial (was 1, but I think should be 0) * Fixed BB hacks, not needed anymore after #7859 * Will have to come back to set up a better way to walk expressions: a visitor (I think powdr has something like this)
- Loading branch information