0xMiden / 0xMiden/miden-vm

Accelerate Eidos transcript grinding with WebGPU

Open
#3,813 6 comments 2 reactions 0 assignees View on GitHub
prover
Dominant language
Rust
Stars
772
Forks
352
Avg merge
1d 12h
Merged PRs (30d)
93

Description

Add an optional WebGPU backend for Eidos proof-of-work grinding. The goal is to return any valid witness as quickly as possible. Candidate order does not matter, and different runs may produce different witnesses.

The search should stay on the GPU. Upload the fixed challenger snapshot and difficulty once, then let workers generate and test candidates in loops. A shared atomic result lets workers stop cooperatively when someone finds a witness. Use bounded search windows to keep dispatches manageable, advancing to another window only if necessary. The input is roughly 100 bytes and the result is a single offset, so reducing CPU/GPU synchronization matters much more than transfer bandwidth.

The CPU should validate the returned witness before advancing the challenger. The kernel must reproduce Eidos’s compression and transcript semantics, including transition tags, output masking, and the additional compression when the witness fills the absorb block. Tests should check witness validity and transcript continuation without requiring CPU and GPU searches to find the same witness. Coverage should include exhausted windows, field boundaries, and device failure.

A local prototype produced these release-build measurements on an **Apple M5 Max**, compared with the current native implementation using **18 Rayon threads**:

| Grinding difficulty | Native Rayon | WebGPU | GPU speedup |
|---|---:|---:|---:|
| 12 bits | 0.11–0.12 ms | 0.20–0.22 ms | CPU faster |
| 17 bits | 0.62–1.40 ms | 0.31–0.45 ms | **2.0–3.1×** |
| 20 bits | 4.12–8.92 ms | 0.94–1.55 ms | **4.4–5.8×** |
| 24 bits | 60.8–122.1 ms | 6.55–9.05 ms | **9.3–13.5×** |

Ranges span two transcript states requiring one or two compressions per candidate. Each value is a mean over 128 searches, or 64 searches at 24 bits. GPU timings include dispatch and readback with the device and pipeline reused; initialization adds approximately **10 ms**. These measure grinding latency, and whole-prover impact still needs measurement.

Start with native `wgpu` support, reuse GPU resources across searches, and retain CPU fallback with a configurable difficulty threshold. The current VM’s 17-bit query grinding is the immediate target. Tune worker count and window size against the Rayon baseline before choosing defaults.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.