Accelerate Eidos transcript grinding with WebGPU
- 主要语言
- Rust
- 星标
- 772
- 派生
- 352
- 平均合并
- 1 天 7 小时
- 30 天内合并 PR
- 84
描述
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.
贡献指南
调研方向
The issue is about adding a WebGPU backend to the Eidos proof-of-work grinding in the Miden VM. Start by examining the existing CPU-based grinding implementation, likely in the Eidos module, to understand the transcript semantics, compression, and candidate generation. Look for the current Rayon-based parallel search. The WebGPU implementation will need to create a compute shader that replicates the grinding logic, manages search windows, and uses atomic operations for early termination. Focus on reusing GPU resources and adding a configurable threshold to switch between CPU and GPU. Testing should validate witness correctness and handle edge cases like exhausted windows and device failures.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- backend, performance
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100