feat: reuse compiled artifacts in rvr - #2833
Conversation
Resolves INT-7138, INT-7158, INT-7164. ### INT-7138: Preserve `main_commit` on non-present `min_cached_idx` rows Moves the `main_commit` set to after `fill_present_row` and `fill_non_present_row` so it won't be overwritten in the latter. ### INT-7158: Reject unsupported `max_cached` values in proof-shape CUDA ### INT-7164: Validate transcript CUDA proof count range No fix required, but added a comment to explain `SWITCH_BLOCK` usage so this doesn't get flagged as often. We may want to consider removing it later as a maintenance item if it doesn't hurt performance.
Related to INT-7134.
resolves int-7202
Resolves INT-7136 and INT-7153. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This was done erroneously in the SHA2 refactor but the upstream feature is called sha256 so we shouldn't change it.
…tracegen (#2670) ## Summary Reduce CUDA stack usage, register pressure, and spills in `keccakf_op` and `sha2_main` trace generation kernels, inspired by #2524. ### keccakf_op_tracegen - Rewrote `keccakf_permutation` to operate in-place: eliminated the 200 B `temp[25]` scratch array, walk the rho/pi 24-element cycle with a single saved temp, compute chi in-place with two temps per row, and use a scalar `d` in theta. Stays `__forceinline__` so the state never has to live in local memory. - Moved the row-fill body into a `__noinline__` helper `fill_keccakf_op_row` so the heavy working set (200 B keccak state union, `MemoryAuxColsFactory`, `BitwiseOperationLookup`, the 50-iteration `mem_helper.fill` loop) lives in the helper's own frame instead of the kernel's. ### sha2_main_tracegen - Factored the body into a shared `__forceinline__` template `sha2_main_row_body<V>` plus a thin `__noinline__` wrapper `sha2_main_row_outlined<V>`. Uses `if constexpr (V::WORD_BITS > 32)` to route SHA-512 through the outlined wrapper while keeping SHA-256 on the inlined path (SHA-256 was already tight at 16 B stack / 255 regs, and unconditional outlining would regress it). ### ptxas -v results (sm_89) | Kernel | Before | After | |---|---|---| | `keccakf_op_tracegen` | 1656 B stack / 1268 spills / 255 regs | 16 B kernel + 368 B helper / 168 spills / 24 regs | | `sha2_main_tracegen<512>` | 1256 B stack / 1260 spills / 255 regs | 64 B kernel + 144 B helper / 144 spills / 24 regs | | `sha2_main_tracegen<256>` | 16 B / 16 spills / 255 regs | unchanged | [Reth benchmark comparison](https://github.com/axiom-crypto/openvm-eth/actions/runs/24105029878) Co-authored-by: axiom-agent <agent@axiom.xyz>
This resolves INT-7337 and INT-7340.
Resolves INT-7374.
## Deduplicate Keccak round logic in CUDA code Addresses #2670 (comment) ### Problem `keccakf_op.cuh` carried a second copy of the Keccak-f round logic that already existed in `p3_keccakf.cuh`. Both were correct, but maintaining two copies creates drift risk for future bug fixes or tuning. ### Changes - **`p3_keccakf.cuh`**: Extracted a shared `__forceinline__` helper `keccak256::keccakf_round_body()` that implements a single Keccak-f round on a flat `uint64_t[25]` state. Reduced `apply_round_in_place()` to a thin `__noinline__` wrapper that delegates to it. - **`keccakf_op.cuh`**: Replaced the 50-line duplicate `keccakf_permutation()` (and its local `rotl64()` helper) with a 5-line loop over the shared round body. - **`primitives/utils.cuh`**: Replaced the `ROTL64` macro with a proper `__forceinline__` function `rotl64()` for type safety and single-evaluation guarantees. ### Performance No impact. All helpers are `__forceinline__`, so the compiler produces identical code. The `__noinline__` / `__forceinline__` wrapper pattern (same as `sha2_main.cu`) preserves the existing stack frame topology.
Set up [sccache](https://github.com/mozilla/sccache) with an S3 backend across all CI workflows for distributed Rust compilation caching. This caches compiled artifacts in S3 so that repeated builds across PRs and branches avoid redundant compilation work. - Add a reusable `setup-sccache` composite action (`.github/actions/setup-sccache/`) that configures sccache with S3 credentials, auto-detects CUDA architecture for cache key partitioning, and falls back gracefully to uncached builds if sccache fails to start or S3 is unavailable. - Integrate sccache into all 20+ CI workflows (extension tests, guest library tests, CUDA tests, CLI, benchmarks, lints, SDK, recursion, continuations, etc.). - Replace `cargo install --force` with `cargo build` + PATH for local tools (`cargo-openvm`, `openvm-prof`). `cargo install --force` always rebuilds from scratch (no incremental compilation), while `cargo build` leverages both sccache and incremental compilation from the `rust-cache` target directory — making no-change rebuilds near-instant. - Ensure all `runs-on` labels include `extras=s3-cache` for S3 access. Compared against PR #2682 (same day, ~1hr earlier, no sccache), with **98–100% sccache hit rates** across all workflows: | Workflow | Before (s) | After (s) | Improvement | |----------|-----------|-----------|-------------| | CUDA SDK Tests | 724 | 397 | **-45%** | | CUDA Continuations | 898 | 507 | **-44%** | | Extension Tests CUDA (combined) | 662 | 404 | **-39%** | | OpenVM CLI Tests | 738 | 505 | **-32%** | | Guest Lib: verify-stark | 252 | 133 | **-47%** | | Guest Lib: sha2 | 158 | 77 | **-51%** | | Extension Tests: ecc (false) | 228 | 159 | **-30%** | | Extension Tests: pairing (true) | 132 | 65 | **-51%** | - [x] All CI workflows pass on this branch - [x] sccache stats show high cache hit rates (98–100%) - [x] Graceful fallback: workflows still work if sccache/S3 is unavailable - [x] `cargo openvm` commands work correctly via `cargo build` + PATH instead of `cargo install` --------- Co-authored-by: Claude <claude@axiom.xyz>
deletes the custom sccache action and uses runson
towards int-5817
fixes failing ci
closes INT-6721
…8` (#2685) resolves int-6954
depends on #2685 resolves int-6953
Co-authored-by: Ayush Shukla <ayush@axiom.xyz>
316c914 to
0b8d705
Compare
Closes INT-8282
Re-do of PR #2777 (base_alu part only), now on top of the u16 memory-bus limbs change. Summary of the changes: - Split base_alu chip into add_sub and xor_or_and chops. - New xor_or_and chip is the old base_alu minus ADD/SUB. - New add_sub chip handles the add and sub opcodes and store 2 bytes per field element in its column. - This allows us to remove the interactions needed to range check that each individual field elements is bytes that was present in the previous base_alu chip. - Core width of the add_sub chip drops to 14 columns compared to the 29 columns of the base_alu chip. - Rewrite tests.rs of add_sub chip for the new u16 columns layout. Improves perf by 6% on the reth benchmark: https://github.com/axiom-crypto/openvm-eth/actions/runs/27436476879 Closes INT-8102 --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Ayush Shukla <ayush@axiom.xyz>
5d2277b to
b5d2f9d
Compare
This comment has been minimized.
This comment has been minimized.
|
@claude provide Code Review for this PR |
|
Claude finished @mansur20478's task in 3m 18s —— View job Code Review: PR #2833 — Reuse compiled artifacts in RVR
SummaryThis PR adds content-addressed caching for compiled RVR shared libraries ( The PR is already approved by @gdmlcjs. I have one actionable finding (the Findings1.
|
Note: cells_used metrics omitted because CUDA tracegen does not expose unpadded trace heights. Commit: 51a16b4 |
5e8a1fc to
46277f7
Compare
gdmlcjs
left a comment
There was a problem hiding this comment.
- In crates/rvr/rvr-openvm/c/Makefile, there are some configs that can be set with environment variables using
?=. They are not contained in the fingerprint so we should better add them in the fingerprint or change?=to=. - There were some changes in the base branch: removed
lto=falsefor macOS, changed method names fromcompile_puretocompile. Could you update those changes? A rebase might be helpful. - I'm not sure, but instead of having two versions of each function (with
cache_dir: Option<&Path>and without) it might be simpler to have just one version (withcache_dir: Option<&Path>). Could you look into that?
8351e0c to
f211621
Compare
f6f015a to
f94ebaf
Compare
Part 2 of the original ticket split into two. Part 1: link
Part 2 consist of reusing persisted artifacts whenever possible instead of recompiling. The idea is to compile in rvr-mode till getting
.cfiles, and instead of invokingmake, check whether already existing.soare fit for reuse. Artifact fingerprints must match for.sofile to be reused. During compilationArtifact fingerprint is a SHA-256 fingerprint of:
native_debug_infoflagtoolchain.compiler,toolchain.linker,toolchain.make,toolchain.host_oshost_cpu_features: affects-march=native(unnecessary?)make_args: make variables except EXT_LIBS and EXT_SRCSproject_dirin sorted order. The folder includes external static libs and external source files too.New methods:
compile_pure_cached,compile_metered_cached,compile_metered_cost_cachedthat takecache_diras an additional argument - a place on disk for storing artifacts. Invokable from sdk.The following loading functions do not perform validation:
load_compiled_pure,load_compiled_metered,load_compiled_metered_costmethods don't have.sovalidation.Modified
build.rsof extensions to rebuild rvr FFI staticlibs on Cargo.lock and ffi-common source changes.resolves INT-7843