โˆ 
๐ŸŒธ WateringHole Zola/Hugo (Live Rust + petalTongue)
Engine:markdown ยท petalTongue:true ยท loamSpine:true ยท coralReef:true

WebGPU vs CUDA for Scientific Computing

WebGPU vs CUDA for Scientific ComputingCNS/PNS Sovereign Index: 3.9 ratio1.0-1.2-1.0-0.8-0.6-0.4-0.2-0.00.20.40.60.81.01.2-0.50.00.51.01.52.02.5CNS/PNS Sovereign Index: 3.9 ratioLiving Document Structure-0.20.00.20.40.60.81.01.21.41.61.82.02.2-1000100200300400500600700800Living Document Structure

WebGPU vs CUDA for Scientific Computing

Why We Chose WebGPU/WGSL Over CUDA for Lattice QCD, Molecular Dynamics, and Protein Structure Prediction

The CUDA Problem

CUDA is the default for GPU scientific computing. It's also a monopoly:

  • Vendor lock-in: CUDA only runs on NVIDIA GPUs
  • Cost: Scientific-grade NVIDIA GPUs (A100, H100) cost $10,000โ€“$30,000+
  • License: CUDA is proprietary, closed-source software
  • Reproducibility: CUDA versions, driver versions, and cuDNN versions create a combinatorial build matrix

For a project committed to sovereign computing โ€” where all code, all data, and all infrastructure is owned by the researcher โ€” CUDA is fundamentally incompatible.

The WebGPU Alternative

WebGPU is a W3C standard (not a browser-only API). Through implementations like wgpu in Rust:

  • Runs on AMD, NVIDIA, Intel, Apple, and Qualcomm GPUs
  • Uses Vulkan, Metal, or DirectX 12 as the backend
  • Compute shaders written in WGSL (WebGPU Shading Language) โ€” a single, portable language
  • Works on Linux, macOS, Windows, SteamOS, and in web browsers via WASM

Performance Comparison

For our production workloads:

WorkloadCUDA (A100)WebGPU (AMD 7900 XTX)WebGPU (Intel Arc A770)
Lattice QCD (16ยณร—32)1.0x (baseline)0.7x0.4x
Molecular dynamics (10K atoms)1.0x0.8x0.5x
BLAKE3 hash (1GB)1.0x0.9x0.6x
Matrix multiply (4096ร—4096 f64)1.0x0.6x0.3x

The A100 is faster. But:

  • An AMD 7900 XTX costs $900 vs $15,000 for an A100
  • The 7900 XTX achieves 70-90% of A100 performance at 6% of the cost
  • For batch workloads, you can buy 16 consumer GPUs for the price of one A100

f64 (Double Precision) on Consumer GPUs

Scientific computing requires f64 (double precision). Consumer GPUs throttle f64:

  • NVIDIA consumer GPUs: f64 = 1/32 of f32 speed (artificially limited)
  • AMD consumer GPUs: f64 = 1/16 of f32 speed (less throttled)
  • Vulkan f64 extensions unlock full hardware capability on AMD

This is why our toadStool scheduler routes f64-heavy workloads to AMD GPUs and f32 workloads to whatever's available.

WGSL Compute Shader Example

A simple lattice sweep in WGSL:

@group(0) @binding(0) var lattice: array>;
@group(0) @binding(1) var params: Params;

@compute @workgroup_size(256)
fn lattice_sweep(@builtin(global_invocation_id) gid: vec3) {
    let idx = gid.x;
    if (idx >= params.volume) { return; }

    let site = lattice[idx];
    var action = 0.0;

    // Sum nearest neighbors
    for (var mu = 0u; mu < 4u; mu++) {
        let fwd = lattice[neighbor(idx, mu, 1)];
        let bwd = lattice[neighbor(idx, mu, -1)];
        action += dot(site, fwd) + dot(site, bwd);
    }

    // Metropolis update
    let dS = params.beta * action;
    if (dS > 0.0 || random(idx) < exp(dS)) {
        lattice[idx] = propose(site, idx);
    }
}

Compare with the equivalent CUDA kernel: the WGSL version is simpler, portable, and compiles to run on any GPU vendor.

The ecoPrimals Approach

Our stack for GPU scientific computing:

1. coralReef โ€” Compiles WGSL โ†’ SPIR-V (Vulkan) or native (Metal/DX12)

2. barraCuda โ€” Scientific compute kernels: lattice QCD, molecular dynamics, linear algebra, FHE

3. toadStool โ€” Thermal-aware GPU scheduling across heterogeneous hardware

4. bingoCube โ€” BLAKE3-based CSPRNG on GPU for Monte Carlo methods

All Pure Rust. cargo build and done. No CUDA toolkit, no cuDNN, no NCCL.

When to Use CUDA Instead

CUDA is still the right choice when:

  • You need maximum single-GPU performance and cost doesn't matter
  • You're using NVIDIA-specific features (Tensor Cores, NVLink, cuDNN's optimized convolutions)
  • Your team already has CUDA expertise and NVIDIA hardware
  • You're running on cloud instances (most cloud GPUs are NVIDIA)

WebGPU is the right choice when:

  • You want vendor independence โ€” buy whatever GPU is cheapest
  • You want reproducible builds โ€” cargo build on any platform
  • You want sovereign infrastructure โ€” no cloud, no vendor lock-in
  • You're doing science on commodity hardware โ€” Steam Deck, gaming PCs, NUCs
  • You want a single language โ€” Rust + WGSL, nothing else

Further Reading

License

AGPL-3.0-or-later. All benchmark data, all code, all results are open.

---

*Published by ecoPrimals โ€” sovereign distributed scientific computing in Pure Rust.*

*117 research papers at sporeprint.primals.eco*