Skip to content

perf(DON'T MERGE): [WIP] execution and tracegen rewrite #1567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

jonathanpwang
Copy link
Contributor

To be rebase merged

Before merging to main: make sure all TODO and TEMP have been removed and addressed.

jonathanpwang and others added 12 commits May 2, 2025 10:58
Note: this PR is not targeting `main`.
I've used `TODO` and `TEMP` to mark places in code that will need to be
cleaned up before merging to `main`.

Beginning the refactor of online memory to allow different host types in
different address spaces.
Going to touch a lot of APIs.
Focusing on stabilizing APIs - currently this PR will not improve
performance.

Tests will not all pass because I have intentionally disabled some
logging required for trace generation.
Only execution tests will pass (or run the execute benchmark).

In future PR(s):

- [ ] make `Memory` trait for execution read/write API
- [ ] better handling of type conversions for memory image
- [ ] replace the underlying memory implementation with other
implementations like mmap

Towards INT-3743

Even with wasteful conversions, execution is faster:
Before: https://github.com/openvm-org/openvm/actions/runs/14318675080
After:
https://github.com/openvm-org/openvm/actions/runs/14371335248?pr=1559
Not merging to main

Add `GuestMemory` trait and implement for `AddressMap`. We are moving
more towards a trait based style to re-use code when different types of
memory might be swapped out.
- make `VmSegmentExecutor` generic on `<Mem, Ctx, Ctrl>` where:
  - `Mem`: struct that implements `GuestMemory`
  - `Ctx`: struct that stores host context during execution
- `Ctrl`: struct that implements pre/post segment execution hooks,
termination condition and instruction execution logic
- add `TracegenVmSegmentExecutor` that implements the current execution
flow
- move segmentation strategies to new file
- deleting `Vm{Adapter,Core}Chip` traits
- no more records, directly use trace buffer
- jal_lui chip is a demonstration of the new changes with working unit
tests
- changed unit tester

- [x] need to add some dummy volatile memory to the tester to balance
based on touched addresses
…1590)

- introduce a new generic `InsExecutorE1` trait 
- add `InsExecutor::execute_e1` for rv32im instructions
- fix some loadstore tests
- remove records
- wrap unsafe memory read/writes into safe wrappers

---------

Co-authored-by: Jonathan Wang <[email protected]>
closes INT-3839

---------

Co-authored-by: Ayush Shukla <[email protected]>
- make `Rv32HintStoreChip` use the `NewVmChipWrapper`
- rename `SingleTraceStep` to `TraceStep` and update it to work for
chips whose execution creates multiple trace rows
- comment out criterion execute benchmarks for now
one line fix. now that we're only initializing `TracingMemory` with
`new`, we should remove this line from `with_image`
jonathanpwang and others added 3 commits May 2, 2025 22:52
remove `memory/offline.rs` as we aren't using it anymore.

Delete `VmAdapterChip` trait and `VmChipWrapper` since we also aren't
using them anymore.
Made the rv32im tests pass and made all the testing files to have the
same testing interface.
Deleted the `test_adapter`. Kept all the test cases unchanged. The only
commented test case remaining is the `store` test to the address space
4, which is failing because currently memory accesses with block size 4
are not supported with the address space 4.

All the test files have 3 types of tests: Positive, Negative, and Sanity
tests.
All the test files have 2 helper functions: `create_test_chip`,
`set_and_execute`.

An important thing to notice about negative tests when expecting an
interaction fail (aka ChallangePhase error) is that ther might be an
imbalance created for the wrong reasons. For example, there might be an
imbalance on the range checker bus created by the interactions:
[send 1] (sent from the chip_air)
[receive 2] (the execution did `add_count(2)` at some point)
This is not a "valid" fail since 1 is still in the range of the range
checker. Because of this a manual check is needed for all the negative
checks. To see all the imbalances occurred during a test remove the
'disable_debug_builder();' line from the `run_negative_test` function
and run the test. I am 95% sure that I wen through all the negative
tests and checked that the imbalances occurred are correct.

The `test_adapter` tried to address this issue by getting rid of
interaction imbalances on the memory bus. But even with the `test
_adapter` a manual check was necessary.
To solve this I suggest that we somehow keep all the interactions that
occur during the test and automatically check that actually an invalid
interaction has happened on a specified bus.

Resolves INT-3975

---------

Co-authored-by: Ayush Shukla <[email protected]>
Fixed an error in divrem negative tests. The trace pranking was done
incorrectly. 2 instructions were being called (so the trace had height
2) each time but only one of the rows was being modified. Changed it so
only one instruction is called each time
Also, made the setup_tracing the default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants