LPsLux Proposals
EVM & Execution
LP-5622

QuasarGPU Execution Adapter

Final

GPU-native execution adapter for Quasar-certified rounds — wave-tick scheduler, device-resident rings, EVM fibers, MVCC Block-STM, async cold state, per-lane certificate verification

LP-5622: QuasarGPU Execution Adapter

Abstract

QuasarGPU is CEVM's GPU-side execution adapter for Quasar-certified rounds. It executes the round on GPU — Block-STM, EVM fibers, batched crypto, root construction — and produces the artifacts the Quasar consensus engine certifies: block_hash, state_root, receipts_root, execution_root, mode_root. It optionally aggregates per-lane certificates from inbound vote, share, and proof artifacts.

This is an execution adapter, not a replacement for luxfi/consensus. The boundary is:

luxfi/consensus  orders, votes, certifies, finalizes
cevm             executes, validates, roots, receipts
quasar/gpu/      GPU-side execution adapter for Quasar rounds

Consensus decides what must be executed; cevm proves what execution produced; Quasar certifies the resulting commitment.

Architecture

Wave-tick scheduler — no host phase orchestration

Classical GPU EVM models dispatch a separate kernel per phase (exec → wait → validate → wait → commit → wait). QuasarGPU replaces all of it with one bounded kernel re-launched once per wave tick:

host:                                  GPU wave-tick kernel:
─────                                  ──────────────────────
begin_round(QuasarRoundDescriptor) → │ service drains run in parallel:
push_txs(...)                       │
push_certs(...) (P/Q/Z lanes)       │   gid 0: Ingress    → Decode
poll_state_requests() → host LSM    │   gid 1: Decode     → Crypto/StateRequest
push_state_pages(...)               │   gid 2: Crypto     → Commit/DagReady/Exec
poll_quasar_certs() ← from CertOut  │   gid 3: DagReady   → Exec
                                    │   gid 4: Exec       → Validate (EVM fibers)
run_wave_tick() — re-dispatch ──────┤   gid 5: Validate   → Commit/Repair (Block-STM)
                                    │   gid 6: Repair     → Exec (incarnation++)
poll_round_result() ← RoundResult   │   gid 7: Commit     → root material
                                    │   gid 8: StateRequest (host poll)
                                    │   gid 9: StateResp  → resume Crypto
                                    │   gid 10: CertLane  → batch verify + aggregate
                                    │   gid 11: CertOut   (host poll)

No persistent hot-spinning kernel. Each wave tick is a bounded dispatch; workgroups exit when their service ring is empty or their budget is exhausted. The GPU scheduler is free to interleave other kernels between ticks.

Service map

The substrate ships 12 services; the production train adds 4 more.

enum class ServiceId : uint32_t {
    // substrate services (12)
    Ingress           = 0,   // host tx blobs
    Decode            = 1,   // sender recovery / admission gate
    Crypto            = 2,   // sig verify, route to Commit / DagReady / Exec
    DagReady          = 3,   // MVCC ready set (Nebula mode)
    Exec              = 4,   // EVM fiber VM
    Validate          = 5,   // Block-STM read-set check
    Repair            = 6,   // re-execute conflicting txs
    Commit            = 7,   // commit + per-tx receipt keccak
    StateRequest      = 8,   // GPU → host page faults (out)
    StateResp         = 9,   // host → GPU page replies (in)
    CertLane          = 10,  // BLS / Pulsar / MLDSAGroth16 lane artifacts
    CertOut           = 11,  // GPU-emitted per-lane QuasarCert commitments

    // production services (4 new) — v0.43, v0.47, v0.48
    AdaptiveSchedule  = 12,  // ConflictSpec admission, predictor consult (A)
    BridgeAttest      = 13,  // cross-chain attestation drain (B)
    MarketAuction     = 14,  // auction-rule batched matching for hot DEX lanes (M)
    FiberCheckpoint   = 15,  // per-CALL-frame checkpoint emit / GC (F)

    Count             = 16
};

The four new drains are referred to as A/B/M/F. Each uses a dedicated ring with the same RingHeader + items_arena layout and the same wave-tick budget contract as the substrate services. Activation is the point at which Count flips from 12 to 16 in the layout type.

Every ring is a fixed-capacity device buffer with a RingHeader at the front (head/tail/capacity/mask/items_ofs/pushed/consumed) and items laid out back-to-back in a per-round items_arena. Cross-workgroup visibility uses the relaxed-atomic + threadgroup_barrier(mem_device) pattern.

Layout types (host/device shared)

TypePurposeSize
RingHeaderper-ring metadata + pushed/consumed counters48 B
IngressTxraw tx envelope32 B
DecodedTxpost-recovery tx48 B
VerifiedTxpost-admission tx (carries blob offset/size for the fiber VM)32 B
RWSetEntryone read or write per Block-STM tx24 B
ExecResulttx execution output + RW set216 B (8 RW slots)
CommitItemcommittable tx + per-tx receipt hash64 B
MvccSlotopen-addressing MVCC arena slot32 B
DagNodeNebula DAG node + parents + children + pending envelope128 B
DagWriterSlotmost-recent-writer-per-key for DAG construction32 B
StateRequestGPU → host page-fault descriptor32 B
StatePagehost → GPU page-fault reply (≤64 B inline payload)96 B
QuasarCertIngressper-lane cert artifact ingress96 B
QuasarCertper-lane cert emission432 B
QuasarRoundDescriptorhost writes once per round304 B
QuasarRoundResultGPU writes; host reads272 B

Inline keccak-f[1600]

The kernel ships an inline FIPS-202 keccak permutation (24 rounds, RC table, rotation table). Used for:

  • block_hash — finalization digest
  • state_root — accumulated commit chain
  • receipts_root — per-tx receipt hash chain
  • execution_root — Block-STM trace commitment
  • per-cert subject re-derivation (replay protection)

Zero CPU keccak fallback on the round path. The metal::keccak256_cpu helper in lib/evm/gpu/metal/keccak_host.mm is reserved for legacy non-Quasar consumers.

EVM fiber VM

drain_exec runs the in-kernel EVM interpreter — a per-tx fiber with:

  • pc, sp, gas, status
  • stack[64] of 256-bit values (4 × 64-bit limbs each = 13.6 MB for 4096 fibers)
  • memory[1024] per-fiber scratch
  • pending_key_*[4] cold-state suspend slot
  • rw[8] Block-STM read/write set

Coverage is 118 opcodes — full arithmetic including ADDMOD / MULMOD / EXP, all signed and unsigned compares, bitwise including SAR / BYTE, KECCAK256, env opcodes, PUSH0..PUSH32, DUP1..16, SWAP1..16, MLOAD / MSTORE / MSTORE8 / MSIZE, SLOAD / SSTORE with cold-miss suspend, JUMP / JUMPI / PC / JUMPDEST / GAS, STOP / RETURN / REVERT / INVALID. The full opcode table is in lp-5620.

Cold-miss SLOAD suspends: status = 2, key in pending_key_*, push StateRequest, restore stack, return. drain_state_resp resumes by re-injecting and stamping the MVCC slot's last_writer_tx |= 0x80000000 as the "loaded" sentinel.

Deferred to v0.40+: CALL family, CREATE/CREATE2, LOGn, EXTCODE*, RETURNDATA*, TLOAD/TSTORE, MCOPY, BLOBHASH/BLOBBASEFEE.

Block-STM

drain_exec records read and write entries into the tx's RW set. drain_validate runs the MVCC version check (mvcc_check_consistent); on mismatch it is a conflict and goes to the repair queue with a bumped incarnation. On match it runs mvcc_apply_writes (atomic version bump) and pushes a CommitItem.

Telemetry on QuasarRoundResult: conflict_count, repair_count, fibers_suspended, fibers_resumed. Measured behaviour: 16 same-key contending txs produce 120 conflicts → 120 repairs → 16 commits — textbook Block-STM running entirely on GPU.

Async cold-state page faults

The host services GPU-emitted state requests via its LSM, cache, and disk path. The GPU never blocks on host I/O:

host loop:
    while round in progress:
        run_wave_tick()
        reqs = poll_state_requests()
        if reqs.empty(): continue
        pages = state_db.batch_get(reqs)
        push_state_pages(pages)

A faulted tx exits Decode into StateRequest and the workgroup moves on. Other txs continue through the fast path while the slow tx awaits host service. The finalization gate (commit.consumed == ingress.pushed) holds across both fast and slow lanes.

Per-lane certificate verification

drain_cert_lane reads inbound QuasarCertIngress items, dispatches to a per-lane verifier, and accumulates stake into per-lane counters. At the 2/3 quorum threshold a QuasarCert is emitted onto CertOut.

LaneVerifierShipped stateSubstrate file
BLSverify_bls_aggregatev0.44 real BLS12-381 pairinglib/consensus/quasar/gpu/crypto/bls12_381.metal / .cu
Coronaverify_corona_sharev0.45 real Module-LWE share verifier against the Q-Chain ceremony keylib/consensus/quasar/gpu/crypto/corona.metal / .cu
MLDSAGroth16verify_mldsa_groth16v0.45 real Groth16 over BLS12-381 against the Z-Chain verifying keylib/consensus/quasar/gpu/crypto/groth16.metal / .cu

The substrate originally shipped HMAC-keccak placeholders across all three lanes — real cryptographic verification (one-way with a master secret; cross-lane domain tags reject replay), structured so the swap to real BLS, Module-LWE, and Groth16 was a single function-pointer change. That swap landed in v0.44 (BLS) and v0.45 (Corona + Groth16). The HMAC-keccak path is preserved as a development-only mode for deterministic test vectors, behind EVM_DEV_HMAC_VERIFIER=1.

Public API

namespace quasar::gpu {

class QuasarGPUEngine {
public:
    static std::unique_ptr<QuasarGPUEngine> create();

    QuasarRoundHandle begin_round(const QuasarRoundDescriptor&);
    void              push_txs(QuasarRoundHandle, std::span<const HostTxBlob>);
    void              push_certs(QuasarRoundHandle, std::span<const HostCertIngress>);
    void              push_state_pages(QuasarRoundHandle, std::span<const HostStatePage>);

    std::vector<HostStateRequest> poll_state_requests(QuasarRoundHandle);
    std::vector<HostQuasarCert>   poll_quasar_certs(QuasarRoundHandle);

    QuasarRoundResult run_wave_tick(QuasarRoundHandle);
    QuasarRoundResult run_until_done(QuasarRoundHandle, std::size_t max_ticks);
    QuasarRoundResult poll_round_result(QuasarRoundHandle);

    void request_close(QuasarRoundHandle);
    void end_round(QuasarRoundHandle);
};

}  // namespace quasar::gpu

Backends

BackendStatusFile
Apple MetalComplete (v0.31..v0.39)quasar_wave.metal, quasar_gpu_engine.mm
NVIDIA CUDAComplete (v0.41) — persistent CTAs, __threadfence, same APIquasar_wave.cu, quasar_gpu_engine_cuda.cpp
Runtime dispatcherMetal on Apple, CUDA on EVM_CUDA, else nullptrquasar_gpu_runtime.cpp

The Metal and CUDA kernels share the layout types (quasar_gpu_layout.hpp) byte-for-byte; structural drift is caught by static_assert at compile time on both sides.

Scaling formula

T ≈ min(
    E_gpu,                                    // GPU event execution capacity
    B_net / bytes_per_event,                  // network bandwidth
    B_state / bytes_per_state_access,         // hot-state memory bandwidth
    L_independent / conflict_amplification,   // lane independence
    C_cert / cert_cost_per_root,              // certificate throughput
    D_da / data_availability_bytes            // data availability
)

The design thesis:

Increase T by maximizing L_independent and minimizing cert_cost_per_root.

L_independent comes from lane partitioning. cert_cost_per_root is constant in TPS because validators sign roots, not individual transactions.

Throughput claim ladder

TierWorkloadPlausible throughput
Tier 1 — events/secorder placements, cancels, intents, market data1 B aggregate, lane-isolated
Tier 2 — state transitions/secprecompile / EVM lane-local effects100 M (cluster scale)
Tier 3 — finalized settlement/seccertified roots, receipts, audit commitments1–10 M

The claim is billion-event throughput, EVM-settled, Quasar-certified — not "1 B EVM TPS on a single shared state machine", which is bounded by contention and data availability, not GPU compute.

Test surface

test/unittests/quasar_gpu_engine_test.mm:

TestWhat it asserts
empty_roundbegin/close/finalize with no txs
single_tx_real_rootsblock_hash, receipts_root, execution_root all non-zero
multi_tx_countersper-stage pushed == consumed for 128 txs
bounded_backpressure1024 txs across a small per-tick budget; finalizes
end_to_end_stress1024 txs in 8 wave ticks, ~150 ms on M1 Max
state_page_faulthost-serviced cold misses round-trip
root_determinismsame input → same roots across runs
block_stm_independent_txs64 disjoint-key txs, conflict_count = 0
block_stm_conflict_repair16 same-key txs, conflict_count = 120, repair_count = 120
evm_fiber_arithmeticPUSH1 1; PUSH1 2; ADD; STOP commits with correct gas
evm_fiber_storageSLOAD cold-miss → suspend → resume; fibers_suspended ≥ 1
evm_fiber_revertREVERT path drains cleanly
quasar_quorum_round_trip3 BLS + 1 ML-DSA + 2 Pulsar; tampered and cross-lane replay rejected

Plus the broader 19-binary GPU test surface — parity, modes, host-bridge, pipeline, unified, gpu-state, opcodes, dispatch, refund, access-list, stack-depth, storage-overflow. All 19 PASS on Apple M1 Max.

Forbidden patterns

QuasarGPU must not use:

  • one global STM clock
  • one global version-map lock
  • retry-until-success GPU loops
  • nondeterministic conflict victim selection
  • opcode-level STM (it is tx-level)
  • CPU compute on the round path (the host is doorbell and I/O only)
  • per-version malloc (use the per-round arena)
  • global hot-key spinlocks

Implementation plan

Substrate

VersionTheme
v0.31..v0.39substrate complete
v0.40predicted-access-set DAG construction + frontier selection (Nebula mode)

Production train

VersionTheme
v0.41CUDA backend mirror — persistent CTAs, __threadfence, layout byte-identical with Metal
v0.42cert-subject hardening (certificate_subject includes P/Q/Z roots), KnownTotalOrder, mode roots separated
v0.43ConflictSpec ABI + LaneClass + dynamic per-lane VersioningMode + AdaptiveSchedule drain
v0.44real BLS12-381 pairing kernel
v0.45real Corona Module-LWE share verifier + real Groth16 verifier
v0.46full EVM coverage (175 opcodes; full CALL/CREATE family, LOGn, EXTCODE*, RETURNDATA*, TLOAD/TSTORE, MCOPY, BLOBHASH/BLOBBASEFEE) + journaled SSTORE + EIP-2929/3529 + Tier 3 semantic reducers
v0.47predictive scheduling + execution-hint roots emitted per wave tick
v0.48VersionBlock layout (4 → 8 inline versions per key) + the A/B/M/F drains
v0.49commit-server scaffold + formal CPU reference + cross-backend determinism harness gated in CI at ≥ 80% line coverage

The wire schema is unchanged across the whole train.

References

ResourceLocation
Substrate sourcecevm/lib/consensus/quasar/gpu/
Testscevm/test/unittests/quasar_gpu_engine_test.mm
Layout typescevm/lib/consensus/quasar/gpu/quasar_gpu_layout.hpp
Metal kernelcevm/lib/consensus/quasar/gpu/quasar_wave.metal
CUDA kernelcevm/lib/consensus/quasar/gpu/quasar_wave.cu
Host driver (Metal)cevm/lib/consensus/quasar/gpu/quasar_gpu_engine.mm
Host driver (CUDA)cevm/lib/consensus/quasar/gpu/quasar_gpu_engine_cuda.cpp
Runtime dispatchercevm/lib/consensus/quasar/gpu/quasar_gpu_runtime.cpp
lp-0110Quasar consensus and certificate lanes
lp-4110BLS12-381
lp-4400ML-DSA
lp-4440Corona threshold signatures
lp-4450Pulsar threshold ML-DSA
lp-5620GPU-native EVM
lp-5625GPU-residency invariant
lp-8000Z-Chain verifying-key source for the Groth16 lane

Copyright (C) Lux Industries Inc. All rights reserved.