Commit Graph

29 Commits

Author SHA1 Message Date
Thibaut Schaeffer
86c31acd9a Make powdr generic over the pgo method (#3188)
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.
2025-08-22 13:59:23 +00:00
Leandro Pacheco
17e0e6d939 metrics for autoprecompiles (#2978)
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
2025-08-08 21:44:37 +00:00
Steve Wang
4994f1aa68 Generalize block filter in Adapter (#3133)
As per @Schaeff's comment
https://github.com/powdr-labs/powdr/pull/3124#issuecomment-3144116469.

This can be orthogonal with #3124, which this PR can apply on top of.
Alternatively, if we don't want the CLI option of max number of basic
block instructions, we can apply this PR without #3124.
2025-08-04 07:55:51 +00:00
Steve Wang
a03c1960ea Generalize CLI structs (#3123)
Generalize so that we can use `PgoType` and adjacent CLI functions in
more use cases in a generic way.
2025-08-01 15:27:17 +00:00
Steve Wang
a3fc1ee854 Create APC with constraint on max number of basic block instructions (#3114)
Reth test will be fixed after we merge this.
2025-07-30 08:45:35 +00:00
Thibaut Schaeffer
54861dd793 Move pgo to apc crate (#3036)
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
2025-07-14 12:53:01 +00:00
Georg Wiese
4b3441d560 Add --apcs-candidates-dir argument (#3022)
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`
2025-07-09 15:13:47 +00:00
Steve Wang
458ee84f2a PGO max column CLI (#2974)
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)`.
2025-07-02 09:54:51 +00:00
Thibaut Schaeffer
57d34d13b8 Adjust cell PGO cost function, add hard limit on column count (#2949)
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>
2025-06-27 00:50:47 +00:00
Leo
63c1944d34 restore pgo API (#2941)
We need the `CompiledProgram` entry point because in the reth benchmark
we already have the elf binary
2025-06-24 09:17:22 +00:00
Steve Wang
81a099c3db Deprecate OVM CLI PGO (#2935)
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.
2025-06-23 10:37:17 +00:00
Leandro Pacheco
52caecd2a0 add --metrics to prove command (#2925)
allows exporting metrics to a json file
2025-06-23 08:55:21 +00:00
Thibaut Schaeffer
aea80c1c5f Move pgo type to openvm crate (#2916) 2025-06-18 19:55:49 +00:00
Thibaut Schaeffer
f28e52fa2a Clean up API (#2914)
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
2025-06-18 13:22:11 +00:00
Thibaut Schaeffer
233278b6f7 Move deps to workspace (#2875)
Fewer places to change the rev
2025-06-10 18:58:03 +00:00
Steve Wang
f6097e2525 Option for prove to use a smaller segment (#2845)
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.
2025-06-09 09:39:12 +00:00
Leo
b573cdbd80 more nightly tests (#2855)
This should be merged only if
https://github.com/powdr-labs/powdr/actions/runs/15495026836/job/43629576763
passes.
2025-06-06 16:52:53 +00:00
Steve Wang
52c12432d2 Fix OVM Witgen (#2836)
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>
2025-06-06 13:37:52 +00:00
Georg Wiese
cc3d4e13f6 Refactor interface to powdr autoprecompiles (#2829)
Small refactorings, with the goal of making the interface to
`powdr_autoprecompiles` smaller. See my comments below.
2025-06-06 12:12:48 +00:00
Steve Wang
85905f3373 Pgo trace cell (#2781)
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`.
2025-06-04 07:55:05 +00:00
Thibaut Schaeffer
0a0ae0810b Update openvm and stark-backend (#2830)
Needs to be updated with the correct hashes after merges of the prs in
stark-backend and openvm
2025-06-03 17:41:00 +00:00
Thibaut Schaeffer
1a11972cc7 Associated openvm type (#2812)
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>
2025-06-03 12:37:31 +00:00
Thibaut Schaeffer
7ead3990e7 Witgen: avoid timestamp LT checks on irrelevant memory interactions (#2764)
- [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>
2025-06-03 12:17:58 +00:00
Leo
1608312fa2 update openvm and stark-backend hashes (#2811) 2025-06-02 19:51:56 +00:00
Thibaut Schaeffer
8d27539adf Update openvm dep (#2786)
Updated because the version changed to 1.1.2
2025-05-28 14:19:21 +00:00
Leo
a76e8c415f Configuration bus map instead of constant (#2766) 2025-05-26 14:08:40 +00:00
Leo
9084ac4fc3 api features option (#2763)
This allows users of the `powdr-openvm` lib to pass build features.
2025-05-23 14:00:29 +00:00
Leo
1d6a12b1b8 update openvm rev (#2741) 2025-05-21 07:54:51 +00:00
Thibaut Schaeffer
2d6708bbc5 Add openvm crates (#2714)
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
2025-05-16 14:30:09 +00:00