Skip to content

About

Formally verified 64-bit Tile-Dataflow + SIMT Compute GPU built in Lean 4 on lambda-hdl (zero Sparkle)

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

lambda-gpu (λ-GPU) v2.7

A from-scratch, zero-CPU-compromise, formally verified 4-Core 64-bit Tile-Dataflow + SIMT Compute GPU SoC (λISA-64) with a 6-Stage PipedTileCore, Direct Z3-Verified TileScoreboardCtrl (u_sb) Submodule, 4-Stage Mixed-Precision BF16 × BF16 → FP32 Tensor Core, True Multi-Block Online-Rescaling FlashAttention-2 (4x8, 0.86% rel error vs. IEEE float64, ZERO extra DSPs!), 4-Beat ARLEN=3 64-Byte ARM AXI4 Burst Interconnect (4× fewer ARs!), Universal End-to-End Compiler Correctness Proof (all $2^{1024}$ 4×4 matrices), Yosys Pure-I/O Miter Backend LEC, Native Compiled CIRCT arcilator C++ Execution (2.527 MHz sim, 40/40 bit-exact!), and 69.88 MHz Real Post-Route Lattice ECP5-85F Timing — built in Lean 4 on lambda-hdl v0.11 (ZERO Sparkle, ZERO sorry, 55 Lean 4 theorems + 10/10 Z3 CEC/BMC/k-Ind + 4/4 Yosys LEC + Verilator + arcilator + Yosys + nextpnr-ecp5 verified).


Architectural & Soundness Highlights (v2.7)

  • 100% Native 64-bit GPU ISA (λISA-64) — Zero RISC-V/CPU compromise: 4-bit SASS async barrier waitMask, 2-bit depBar, 3-bit lane predication, unified operands, V_MAC, V_DP4A, V_SHFL, RDNA S_AND_SAVEEXEC/XOR/OR, full Softmax FlashAttention-2 ML Vector Ops (V_BF16_RELU, V_BF16_MAX, V_FP32_TO_BF16, V_BF16_TO_FP32, V_FP32_MAX, V_BF16_EXP2, V_BF16_RCP, V_BF16_ADD, V_BF16_SUB, V_BF16_MUL), DMA_PUSH (with 4-beat ARLEN=3 64-byte bursts!), W_MMA_I8, W_MMA_BF16, W_MMA_BF16_F32, T_CLEAR, T_MOV, and TILE_SEND.
  • 6-Stage PipedTileCore + 4-Stage FP32 Tensor Core + Direct TileScoreboardCtrl (u_sb) — 69.88 MHz Post-Route ECP5-85F! (PipedTileCore.lean, BF16.lean, ScoreboardBMC.lean):
    • Real Post-Route Timing Closure: EX0/EX1 split of bf16Add + EX0 precompute of EXP2/RCP/EA, 4-stage Matrix Engine (M0A [TQUEUE Mux] → M0B [Pure FF → MULT18X18D] → M1 [Dual-Path Align + Add/Sub] → M2 [CLZ + Norm + WB]), and parallel-speculative exponent precompute push real post-route 40nm ECP5-85F Fmax to 69.88 MHz (5.79 ns logic + 8.52 ns routing, +55.4% faster than v2.2) and cut Xilinx ABC9 mapped LUT depth to lev = 15 (avg 1.35), levB = 19!
    • Zero Model-Extraction Gap: PipedTileCore directly instantiates the Z3-verified TileScoreboardCtrl (submod "u_sb" tileScoreboardCtrl) for TQUEUE (Q0/Q1) and W_MMA occupancy control!
    • Two Proved DSP-Sharing Theorems (bf16MulToFp32_hi16_eq_bf16Mul & bf16MulFromProd_eq_bf16Mul): proved via bv_decide across all $2^{32}$ inputs — ONE shared 4-wide matrix multiplier array powers BOTH W_MMA_BF16 and W_MMA_BF16_F32, AND Stage EX0's existing integer lane multipliers power V_BF16_MUL, keeping ZERO extra DSPs (48 DSP48E1 / 48 MULT18X18D)!
    • 15 true Xilinx Block RAMs (1 × RAMB36E1 + 14 × RAMB18E1) via lambda-hdl's explicit MemKind.syncBRAM (9.88× fewer LUTRAMs than Sparkle v1).
  • Full SoC-Ready 4-Core GPU (LambdaMesh2x2SoC) with 4-Beat ARLEN=3 AXI4 Bursts (Mesh2x2SoC.lean):
    • Preserves 14 true hierarchical submodules through CIRCT firtool 1.163.0 AND compiles cleanly to CIRCT arcilator LLVM IR (29,334 lines for the full 4-core SoC, 9,138 lines for PipedTileCore): 4 × (PipedTileCore + TileScoreboardCtrl u_sb) + Direct 4×4 Hardware Tile NoC + 4 × SplitToAXI4Bridge (with 4-beat ARLEN=3 burst reads!) + 1 × AXI4Mux4 (unified 128-bit ARM AXI4 DRAM Master) + 1 × AXI4LiteCSR (32-bit ARM AXI4-Lite Host Control & Telemetry CSRs with auto-generated gen/gpu_soc_csr.h).
    • 72 live RTL HAssert invariants checked simultaneously during Verilator simulation!
  • 3-Way Independent Bit-Exact Verification & Closed-Loop Formal Soundness:
    • 3 Independent Simulators: Lean 4 Golden Oracle ≡ Verilator 5.054 (80/80 PASS) ≡ Native Compiled CIRCT arcilator LLVM IR (40/40 PASS at 2.527 MHz sim!).
    • 55 zero-sorry Lean 4 theorems (Audit.lean), including compileGemm4x4_end_to_end_spec (universal end-to-end 16-step matrix-multiply correctness over all $2^{1024}$ 4×4 inputs!) + 5/5 injected GPU bugs rejected at compile time (bug_injection_test.sh).
    • Live Z3 CEC + RTL BMC + Unbounded $k$-Induction: 10/10 positive Z3 proofs unsat (8 CEC including parallel-speculative BF16/FP32 + 16-cyc RTL BMC + Unbounded $k$-Induction on live TileScoreboardCtrl) + 2/2 non-vacuity mutants sat!
    • GPU End-to-End Backend LEC (make lec): proves Direct SV ≡ CIRCT firtool SV via Yosys 8-cycle pure-I/O miter SAT across 4/4 GPU controller & SoC interconnect modules + 1/1 mutant REJECTED!

Verified Benchmark, SoC, PPA & Real Post-Route Timing Results (v2.7)

1. Three-Way Bit-for-Bit Verification & Simulator Throughput (Verilator 5.054 vs. CIRCT arcilator)

All 20 kernels × {1-cycle DRAM, 50-cycle DRAM} PASS bit-for-bit across CIRCT firtool SV (Verilator, 40/40), Direct SV (Verilator, 40/40), AND Native Compiled CIRCT arcilator LLVM IR (clang++ -O3, 40/40) = 120/120 single-core runs PASS!

  • Head-to-Head Simulator Throughput (make arcilator-bench, 100× 20-Kernel Suite = 652,600 GPU cycles):
    • CIRCT arcilator (clang++ -O3): 652,600 cycles in 258.23 ms → 2.527 MHz (2,527.2 kCycles/sec)
    • Verilator 5.054 (-O3): 652,600 cycles in 260.36 ms → 2.507 MHz (2,506.5 kCycles/sec)
  • flash_online_attn_4x8 (True Multi-Block Online-Rescaling FlashAttention-2 across 2 × 4×4 K/V blocks): 1,456 cyc @ 1c / 1,648 cyc @ 50c DRAM (256 mixed-precision W_MMA_BF16_F32 MACs + running (m, l, O) SMEM rescaling), independent IEEE-754 float64 accuracy max|O_hw - O_f64| = 0.0066 (0.86% rel)!
  • flash_softmax_attn_4x4 (Single-Block Mixed-Precision Online-Softmax FlashAttention-2): 536 cyc @ 1c / 632 cyc @ 50c DRAM (128 mixed-precision MACs), IEEE-754 float64 max|rowSum(P) - 1| = 0.0159, max|O_hw - O_f64| = 0.0290 (1.65% rel)!
  • tileGemm_4x4_wmma (50c DRAM): 166 cyc vs. matMul_4x4_simt (2,692 cyc) → 16.22× faster (AXI4 AR = 2, 4× burst reduction!)
  • latHide_4warp_16w (50c DRAM): 223 cyc vs. latHide_1warp_16w (688 cyc) → 3.09× SIMT latency hiding
  • tiledGemm_4x16x4_2warp_spec (50c DRAM): 321 cyc vs. 1-warp (504 cyc) → 1.57× double-buffered overlap

2. Full 4-Core GPU SoC (LambdaMesh2x2SoC_firtool.sv) — AXI4-Lite Host CSRs + 4-Beat ARLEN=3 128-Bit AXI4 DRAM

Heterogeneous multi-head 4-core workload (Core 0: Q×Kᵀ --NoC--> Core 1: S×V --NoC--> Core 2: O×W_O → DRAM + concurrent Core 3: Live Online-Softmax FlashAttention-2 (BF16 → FP32)) driven purely via ARM AXI4-Lite CSRs over a single shared 128-bit AXI4 DRAM bus with live staggered backpressure:

  • 1-Cycle DRAM: 573 wall cyc | CSR mma=320, ret=110 | AXI4 AR=8 (4.0× fewer ARs!), AW=12, W=12, B=12 | CoreWr=[0,0,4,8] (0 DRAM bytes spilled for S & O!) | 0/72 HAssert violations | PASS
  • 50-Cycle DRAM: 672 wall cyc | CSR mma=320, ret=110 | AXI4 AR=8 (4.0× fewer ARs!), AW=12, W=12, B=12 | CoreWr=[0,0,4,8] (0 DRAM bytes spilled!) | 0/72 HAssert violations | PASS

3. Yosys Xilinx 7-Series PPA & Real Post-Route Lattice ECP5-85F Timing

Metric Sparkle v1 Unpipelined lambdaTileCore lambda-hdl v2.2 (4-Stage) lambda-hdl v2.5 (6-Stage) lambda-hdl v2.7 (6-Stage + 4-Stage MMA + Speculative BF16/FP32) Delta vs. v1 / v2.2
Xilinx 7-Series LCs (synth_xilinx -family xc7) 8,867 8,873 11,501 11,900 Full FP32 Tensor Core + Softmax + u_sb + 4-Beat Burst
Xilinx DSP48E1 Slices 112 48 48 48 2.33× fewer DSPs (0 extra for FP32 + Softmax!)
True Xilinx Block RAMs 0 15 15 15 (1 RAMB36E1 + 14 RAMB18E1) Real BRAMs for IMEM, SGPR, VGPR
Distributed LUTRAMs 1,264 128 128 128 (RAM64X1S) 9.88× fewer LUTRAMs
Flip-Flops / Latches 1,543 / 0 3,755 / 0 5,474 / 0 5,991 / 0 0 latches
Yosys ABC9 Pre-Map AIG Depth (lev, avg) 107 (avg 11.15) 52 (avg 3.43) 45 (avg 2.64) 38 (avg 2.35) 2.82× peak / 4.74× avg shallower than v1!
Yosys ABC9 Mapped LUT Depth (lev, avg) 27 (avg 3.33) 20 (avg 1.69) 17 (avg 1.48) 15 (avg 1.35), levB = 19 1.80× peak / 2.47× avg shallower than v1!
Real Post-Route FPGA Fmax (nextpnr-ecp5, ECP5-85F-8) — 44.96 MHz (10.36ns logic) 54.15 MHz (6.78ns logic) 69.88 MHz (5.79ns logic + 8.52ns route; 27% LUT4, 8% FF) +55.4% vs v2.2 (+29.0% vs v2.5)!

Quick Start

nix develop
make all             # Build Lean + 55 proofs + static check + FIRRTL/SV + CIRCT firtool + Verilator (Core + Mesh + AXI4 Core + Full 4-Core SoC) + 8/8 Z3 CEC + RTL Z3 BMC/k-Ind + 4/4 Yosys LEC + Compiled CIRCT arcilator C++ Execution (40/40) + Axiom Audit + 5/5 Bug-Injection Audit
make arcilator-bench # Run head-to-head 652,600-cycle throughput benchmark: CIRCT arcilator (-O3) vs Verilator 5.054 (-O3)
make yosys           # Run Yosys Xilinx 7-series PPA & ABC9 timing comparison (Sparkle v1 vs lambda-hdl v2.7)
make pnr             # Run real Lattice ECP5-85F Place-and-Route timing via yosys + nextpnr-ecp5 --freq 80

License

Original project material is available under either the MIT License or the Apache License 2.0, at your option.

About

Formally verified 64-bit Tile-Dataflow + SIMT Compute GPU built in Lean 4 on lambda-hdl (zero Sparkle)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages