GPU-Native EVM Execution
GPU-resident EVM with a per-transaction bytecode fiber VM, Block-STM parallel scheduling, and asynchronous cold-state page faults
LP-5620: GPU-Native EVM Execution
Abstract
This LP defines the GPU-native EVM (cevm) for Lux Network: a C++
EVM that executes the full bytecode interpreter on GPU as a per-tx
fiber VM, with Block-STM parallel scheduling and asynchronous
cold-state page faults. Production backends ship for Apple Metal
(M1/M2/M3 silicon), NVIDIA CUDA, and Dawn/WebGPU.
The headline mechanism is the fiber VM: 118 opcodes running the full
per-tx interpreter on GPU with proper suspend/resume semantics, so EVM
contracts can issue cold SLOAD/SSTORE without stalling the wave.
Architecture
Two execution surfaces
CEVM ships two GPU-native execution surfaces:
-
Wave-dispatch one-shot (§One-shot wave) — one Metal/CUDA dispatch per wave, one workgroup per tx, simple opcode coverage. Used by the standalone
evm-bench-kernelandevm-test-pipelinebinaries. Proven model: 32K-tx waves complete in 1 ms on M1 Max. -
QuasarGPU wave-tick scheduler (lp-5622) — bounded scheduler kernel with service rings. Includes the EVM fiber VM in
drain_exec, Block-STM indrain_validate/drain_repair, async page faults viaStateRequest/StateResp, and per-lane Quasar cert verification. This is the production execution path for Quasar-certified rounds.
Fiber VM model
struct FiberSlot {
uint32_t tx_index, pc, sp, status;
uint64_t gas;
uint32_t rw_count, incarnation;
uint32_t pending_key_lo_lo, pending_key_lo_hi; // SLOAD suspend slot
uint32_t pending_key_hi_lo, pending_key_hi_hi;
uint32_t msize; // memory size
RWSetEntry rw[8];
uint64_t stack[64 * 4]; // 64 entries × 4 limbs (256-bit)
uint8_t memory[1024]; // per-fiber scratch
uint32_t blob_offset, blob_size; // bytecode pointer (host-shared buffer)
};
Fiber state machine:
| State | Meaning |
|---|---|
0 (Ready) | not yet executing |
1 (Running) | currently in drain_exec |
2 (WaitingState) | suspended on cold-state SLOAD |
3 (Committable) | exec done, awaiting Block-STM validate |
4 (Reverted) | EVM REVERT or runtime fault |
A single fiber occupies ~3.4 KB; 4096 fibers fit in ~13.9 MB device memory.
256-bit arithmetic in MSL/CUDA
struct U256 { ulong v[4]; }; // little-endian limbs
Implemented:
add/subwith carry propagation across limbsmul— 4×4 schoolbook multiply (16 partial products)div/mod/sdiv/smod— bit-at-a-time (256 iterations) for correctness; specialized fast paths for divisor < 2^64shl/shr/sar— limb-level shift + bit shift, sign-extending SAReq/lt/gt/slt/sgt/iszero— straight comparisons- bitwise AND / OR / XOR / NOT / BYTE — per-limb
Tests confirm exact match against the CPU reference on EIP-150 vectors.
Opcode coverage (118 ops)
| Class | Opcodes |
|---|---|
| Arithmetic | ADD, SUB, MUL, DIV, SDIV, MOD, SMOD, ADDMOD, MULMOD, EXP, NOT, AND, OR, XOR, BYTE, SHL, SHR, SAR |
| Comparison | LT, GT, SLT, SGT, EQ, ISZERO |
| Stack | PUSH0..PUSH32, POP, DUP1..DUP16, SWAP1..SWAP16 |
| Memory | MLOAD, MSTORE, MSTORE8, MSIZE |
| Storage | SLOAD (cold-miss suspend), SSTORE (MVCC write) |
| Control | JUMP, JUMPI, JUMPDEST, PC, GAS |
| Env | ADDRESS, CALLER, ORIGIN, CALLVALUE, CALLDATALOAD, CALLDATASIZE, CALLDATACOPY, CHAINID, GASLIMIT, NUMBER, TIMESTAMP |
| Hash | KECCAK256 (inline keccak-f[1600]) |
| Halt | STOP, RETURN, REVERT, INVALID |
Deferred to v0.40+, with a documented fallthrough returning Error: CALL family, CREATE/CREATE2, LOGn, EXTCODE*, RETURNDATA*, TLOAD/TSTORE, MCOPY, BLOBHASH/BLOBBASEFEE, SIGNEXTEND, BASEFEE, COINBASE, BLOCKHASH, SELFBALANCE.
Gas accounting
Per-opcode gas costs (Berlin-class):
| Opcode | Gas |
|---|---|
| Default arithmetic / compare / stack / env | 3 |
| MLOAD / MSTORE / MSTORE8 | 3 |
| KECCAK256 | 30 + 6/word |
| SLOAD | 100 (warm), 2100 (cold, pre-suspend) |
| SSTORE | 5000 baseline |
| JUMPDEST | 1 |
| Floor (per-tx receipt) | 21000 |
Memory-expansion gas is tracked in v0.40; before that it is a fixed
budget at kFiberMemoryBytes.
SLOAD cold-miss suspend/resume protocol
on SLOAD slot=k:
look up MvccSlot for k
if slot empty (key_lo == 0 && key_hi == 0):
// cold miss
set fiber.status = WaitingState
pack k into fiber.pending_key_*
push StateRequest{tx_index, k} onto StateRequest ring
leave fiber.pc at the SLOAD opcode (resume re-runs)
return out of drain_exec for this fiber
on host StatePage arrival:
drain_state_resp claims the MvccSlot for k, sets last_writer_tx |= 0x80000000
re-injects the fiber into Crypto/Exec
resume sees status==WaitingState; advances to next instr after SLOAD
next SLOAD finds slot warm, proceeds normally
The high bit of last_writer_tx is the "loaded" sentinel — it
distinguishes never-loaded from legitimately-loaded-zero. See
lp-5622 §Async cold-state
page faults.
Block-STM integration
drain_exec populates each fiber's RWSetEntry rw[8] with read and
write versions for every storage, memory, or state access.
drain_validate walks the RW set and compares observed versions against
current MVCC versions; a mismatch is a conflict, which goes to the
repair queue with a bumped incarnation.
Measured behaviour on contention: 16 same-key txs → 120 conflicts → 120 repairs → 16 commits — textbook Block-STM.
Backends
| Backend | Platform | Status | File |
|---|---|---|---|
| Apple Metal | macOS/iOS (M1/M2/M3) | Production | cevm/lib/consensus/quasar/gpu/quasar_wave.metal |
| NVIDIA CUDA | Linux/Windows (CC ≥ 8.0) | Production | cevm/lib/consensus/quasar/gpu/quasar_wave.cu |
| WebGPU/Dawn | cross-platform | Ready on the legacy one-shot path; Dawn shim pending | cevm/lib/evm/gpu/kernel/evm_kernel.metal |
Runtime dispatcher: QuasarGPUEngine::create() selects Metal on
__APPLE__, CUDA on EVM_CUDA, else returns nullptr.
Benchmarks
One-shot wave dispatch (synthetic loop)
10K transactions × 5K loop iterations (550M opcodes), retained as a sanity benchmark:
| Backend | M ops / sec | Speedup vs CPU |
|---|---|---|
| C++ CPU | 193 | 1.0× |
| Metal GPU (one-shot) | 2,303 | 12.1× |
Gas match: byte-identical CPU vs GPU.
Wave-tick scheduler (production path)
End-to-end stress on quasar-gpu-engine-test, Apple M1 Max:
| Workload | Throughput / latency |
|---|---|
| 1024 disjoint-key txs | 8 wave ticks, ~150 ms (~6,800 tx/s end-to-end including roots + cert checks) |
| 16 same-key contending txs | 120 conflicts + 120 repairs, all commit |
| 64 fast-path + 16 cold-state txs | host page-fault round trip works, slot finalizes |
| Determinism | byte-identical roots across two engine instances |
End-to-end TPS includes ingress, decode, admission, EVM exec, Block-STM validate, commit, receipt keccak chain, cert verify, and quorum aggregation. Pure-execution micro-benchmarks are higher; these numbers are honest end-to-end.
Gas-rate and opcode-rate baselines
Measured on the cevm benchmark harness. The Ggas/s rows measure end-to-end execution with full state access; the opcode-kernel row measures raw opcode dispatch and uses the CPU opcode kernel as its 1.0× baseline — the two rows are not comparable to each other.
| Backend | Throughput | Speedup |
|---|---|---|
| Go EVM (baseline) | 4.2 Ggas/s | 1.0× |
| cevm C++, full state | 20.9 Ggas/s | 5.1× |
| cevm GPU opcode kernel (Metal) | 85.9 M op/s | 4.85× over the CPU opcode kernel |
Throughput claim ladder
| Tier | Workload | Plausible throughput |
|---|---|---|
| 1 — events/sec | order placements, cancels, intents | 1 B aggregate, lane-isolated |
| 2 — state transitions/sec | precompile / EVM lane-local effects | 100 M cluster scale |
| 3 — finalized settlement/sec | certified roots with full audit | 1–10 M |
The claim is billion-event throughput, EVM-settled, Quasar-certified — not 1 B EVM TPS on a single shared state machine. That is bounded by contention and data availability, not GPU compute.
Security
- Gas equivalence. Gas accounting is identical between the CPU and GPU paths. GPU execution is an optimization; it does not change EVM semantics. A transaction costing X gas on CPU costs X gas on GPU, and the test suite validates gas and state-root equivalence bit-for-bit.
- Transaction isolation. Each transaction's fiber stack and memory arena are private to that fiber. There is no cross-transaction data path in device memory.
- No floating point. All EVM operations are integer arithmetic, so no GPU floating-point rounding can enter a consensus value.
- Transparent CPU fallback. With no GPU present, cevm runs entirely on CPU with no behavioural change.
- Fiber stack overflow: bounded by
kFiberStackDepth = 64× 4 limbs; reverts tostatus = Errorif exceeded. - Memory expansion: bounded by
kFiberMemoryBytes = 1024; larger expansion is deferred to v0.40 with proper gas accounting. - MVCC arena exhaustion: open-addressing with
kDefaultMvccSlots = 8192slots; a full arena returnskMvccInvalidIdxand the tx faults cleanly — no infinite probe loop. - No CPU compute on the round path — the host is doorbell and I/O only.
- Sixteen findings across three adversarial review rounds of the one-shot path were fixed.
CEVM and QuasarGPU
┌───────────────────────────────────────────────────────┐
│ cevm: Ethereum-compatible EVM │
│ │
│ cevm/lib/evm/ the EVM core │
│ vm.cpp, baseline_*.cpp, advanced_*.cpp │
│ │
│ cevm/lib/evm/gpu/ one-shot wave path │
│ evm_kernel.metal │
│ evm_kernel.cu │
│ kernel/ │
│ │
│ cevm/lib/consensus/quasar/gpu/ │
│ ┌───────────────────────────────────────────┐ │
│ │ QuasarGPU wave-tick scheduler │ │
│ │ quasar_wave.metal / .cu │ │
│ │ drain_exec ← runs the fiber VM │ │
│ │ drain_validate / drain_repair │ │
│ │ drain_cert_lane / drain_state_resp │ │
│ └───────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────┘
This LP covers the EVM proper. lp-5622 covers the wave-tick adapter that embeds the EVM fiber VM into Quasar consensus rounds. QuasarSTM covers the Block-STM scheduling fabric the fibers run under.
Implementation plan
| Version | Theme |
|---|---|
| one-shot | wave dispatch, 60+ opcodes, 12× speedup |
| v0.36 | fiber VM substrate — FiberSlot type, suspend/resume scaffolding |
| v0.39 | full EVM fiber VM in drain_exec, 118 opcodes, SLOAD cold-miss |
| v0.40 | CALL family, CREATE/CREATE2, LOGn, memory-expansion gas, SSTORE journaling |
| v0.41 | CUDA backend mirror complete |
| v0.42 | TLOAD/TSTORE, MCOPY, RETURNDATA*, full Cancun coverage |
| v0.43 | EIP-2929 cold/warm gas accounting in the fiber path |
| v0.44+ | precompile family, including the DEX matching precompile |
References
| Resource | Location |
|---|---|
| EVM core | cevm/lib/evm/ |
| QuasarGPU substrate | cevm/lib/consensus/quasar/gpu/ |
| Tests | cevm/test/unittests/quasar_gpu_engine_test.mm (13/13 PASS) |
| lp-0110 | Quasar consensus |
| lp-5607 | GPU acceleration framework |
| lp-5621 | Interchangeable EVM implementations |
| lp-5622 | QuasarGPU execution adapter |
| lp-9000 | DEX core — consumes the fiber VM |
Copyright
Copyright (C) Lux Industries Inc. All rights reserved.