Introduce `PgoAdapter` which wraps `Adapter` and can call apc
generation. Removes the match statements over the pgo method. Breaking
change. Now the client can pick some pgo implementations like
`pgo::CellPgo` and use it like
`CellPgo::<MyAdapter>::new(pgo_data).generate_apcs(blocks)`. The client
can also implement `PgoAdapter<A: Adapter>` for its own pgo
implementation.
collect the following metrics for autoprecompiles:
- `(before|after)_opt_(cols|constraints|interactions)`
- `total_apc_gen_time`
- `apc_gen_time` per autoprecompile
- `num_calls` per autoprecompile
Larger PR, but after this basically everything that can be made agnostic
is agnostic.
`PowdrConfig` is split in two, as the `autoprecompile` crate does not
care about the arithmetization method. This could be cleaned up a bit
though.
Need to merge
https://github.com/powdr-labs/openvm-reth-benchmark/pull/24/ first and
update the hashes.
TODO:
- [x] merge #3033
- [x] fix reth
- [x] remove POWDR_OPCODE constant in apc and pass it instead
Exposes the changes of #3015 to the CLI
To test, run this from `cli-openvm`:
`mkdir -p apcs && cargo run -r prove $(pwd)/../openvm/guest-keccak
--input 1 --autoprecompiles 1 --apc-candidates-dir apcs`
Adding CLI option as a utility and also an example for reth-benchmark,
which currently can't parse `Cell(Option<usize>)` and only defaults to
`Cell(None)`.
In cell pgo:
- rank apcs by `cells_saved / column_count`
- select them as long as the total column count doesn't cross a max
value, possibly skipping some
---------
Co-authored-by: Steve Wang <qian.wang.wg24@wharton.upenn.edu>
The OVM CLI `Pgo` command and `powdr_ovm::pgo` function mostly collects
the execution frequency of each PC in the original program, and
therefore has become a misnomer now that the concept of PGO is mostly
implemented in `customize_exe.rs`.
This PR removes the `Pgo` command and also inlines `powdr_ovm::pgo`
function to `get_pc_idx_count`, which should be the correct name for the
intended purpose.
Some refactoring:
- avoid collecting a large string in `export_pil`, add basic test
- introduce `OriginalVmConfig` which wraps SdkVmConfig and serves airs,
bus map, etc, with internal caching
- refactor to make the external API higher level. `compile_exe_with_elf`
can be used directly by `openvm-reth-benchmark`, see
https://github.com/powdr-labs/openvm-reth-benchmark/pull/7
Just doing this for `prove` so far because that's needed for our test,
but technically can be added for `execute` as well because execution
already uses `SegmentationStrategy`.
Doesn't touch the CLI.
Pair here: https://github.com/powdr-labs/openvm/pull/24
OVM tests for creating multiple APCs (introduced in PGO branch) fails.
This patches the error that we cannot skip witgen for the last
read/write access to memory.
Previously we thought this was the last access, but some APC has
timestamp increment as the last access, which is not a "real" access.
---------
Co-authored-by: schaeff <thibaut@powdrlabs.com>
Co-authored-by: Leo Alt <leo@powdrlabs.com>
Depend on: https://github.com/powdr-labs/powdr/pull/2808
Mostly the same as: https://github.com/powdr-labs/powdr-openvm/pull/121
Differences:
1. Given that we generate apc for all eligible basic blocks, some apc
fail due to some new optimization applied (currently narrowed down to
`exhaustive_search`). Note that previously in powdr-openvm, apc can be
generated for all eligible basic blocks.
2. Remove basic block that fail to generate apc for from the list of
eligible basic blocks, which requires propogating error information all
the way up to `customize`.
As an alternative to #2804 use a new trait with an associated type to
have a single generic parameter instead of two.
After this PR, only the openvm cli is specific to BabyBear, everything
else is generic and generic type annotations are removed (since all
types can now be infered thanks to the associated type).
One current drawback is that the number crate must depend on `p3-sdk`
and `p3-backend`, although it only needs the field implementation. A
solution to that would be to point to the p3 crates openvm points to,
instead of using the reexports.
Update: I was wrong on only the CLI being generic. The StdIn type
exposed by openvm is specific to BabyBear, so everything in `lib` is
still BabyBear specific.
---------
Co-authored-by: Georg Wiese <georgwiese@gmail.com>
- [x] Collect sets of `RecordId` for each APC row during record
generation
- [ ] During trace generation, avoid generating lt check column values
for memory access beyond the first one
---------
Co-authored-by: Steve Wang <qian.wang.wg24@wharton.upenn.edu>
Based on commit 1dbe4db
- Split into two crates, lib and cli
- upgrade stwo, marked one stwo test `should_panic` @ShuangWu121
- various clippy and fmt fixes linked to the rust version update
- bring all rust versions to 2025-05-14. CI still installs other
versions for openvm which uses them internally. The stable rust version
we test on is bumped to 1.85
- remove `examples` and related tests, which test the powdr crate on the
previous version of powdr (since it uses another nightly). Happy to
discuss this if it's important @leonardoalt