Softanza
StartFrançais
Softanza
Visual & spatial

GPU

Compute and render on one device with a self-tuning, self-checking foundry; f64 and multi-GPU refused by choice.

5 Strong · 4 Solid · 3 Partial · 0 Emerging

Measured against: wgpu · taichi · three.js · Folders: base/gpu(opens in a new tab) · For programmers: this area's reference

nine materials rendered by the GPU foundry
nine materials rendered by the GPU foundry. rendered by the library's guard gg5_gallery and committed with it at 0e72e2e2c as gg5_gallery.png · the source(opens in a new tab)

Rethought from first principles

What Softanza kept from what works, and what it rethought, as the library wrote it down in its design documents and narrations.

The Softanza wayThe GPU is used only where a measurement shows it wins, and the CPU path always remains the reference answer.

Kept from the best practice

  • One lightweight, proven library is built in: wgpu-native (WebGPU). Kernels compile from text at run time, and the same kernels also run in a browser. source(opens in a new tab)
  • Data stays on the device: upload once, chain several kernels, read back once, because moving data costs more than computing on it. source(opens in a new tab)
  • Every GPU operation ships with a parity check against the CPU result, within a tolerance set from measurement. source(opens in a new tab)

Rethought

  • Exact double-precision work stays on the CPU by decision. The GPU serves only domains that tolerate single precision, because consumer cards run doubles 32 to 64 times slower. source(opens in a new tab)
  • Each route to the GPU must win a measurement first, with kill criteria written in advance. Standalone element-by-element operations were dropped because data transfer was 92% of their cost. source(opens in a new tab)
  • GPU compute is described, not hand-written. stzKernelMaker turns a short formula into a kernel, making it approachable the way the regex maker did for patterns. source(opens in a new tab)
  • Kernel variants are proposed by a plain loop, not a language model, since the search space is small. An engine checker verifies each one and refuses impossible speeds. source(opens in a new tab)

An in-house wgpu plane that does what neither three.js (render-only) nor taichi (compute-only) does: compute and render on one device, zero-copy. Its distinctive core is a self-tuning foundry; real consumers are accelerated and verified (t-SNE 5-8x, UMAP up to 16x, k-means 6x, neural forward 5x, exact vector search 18x), always with a bit-identical CPU fallback. What it refuses by measured decision — f64 on GPU, multi-GPU, deep 3D — are scope boundaries, not oversights.

What a crafter does with it, and what stands out

  • a self-tuning, self-checking calibration foundry: category-of-one
  • compute and render zero-copy on one device
  • every GPU route measured, verified, and reversible to CPU
  • byte-identical WGSL native vs browser

What is owed

  • broaden the kernel transpiler beyond elementwise
  • whole-pipeline GPU residency
  • idle-aware routing (GK1b)
  • deeper 3D rendering

The Softanza way, run

What Softanza does differently in this area, shown by code taken from its narrations and guards, and run for this page.

A one-line formula becomes a GPU kernel; writing it needs no device, and the generated code can be read before anything runs.

Softanza
k1 = StzKernelMakerQ()
k1.TakesVector(:A)
k1.TakesVector(:B)
k1.TakesScalar(:alpha)
k1.ReturnsVector(:C)
k1.ForEachElement('{ @C = alpha * @A + @B }')
cW = k1.ToWGSL()
? cW
Output
struct StzTile { xoff : u32, p0 : u32, p1 : u32, p2 : u32 }
@group(0) @binding(0) var<uniform> tile : StzTile;
struct P { n : u32, pad : u32, s_alpha : f32 }
@group(0) @binding(1) var<uniform> p : P;
@group(0) @binding(2) var<storage, read> v_a : array<f32>;
@group(0) @binding(3) var<storage, read> v_b : array<f32>;
@group(0) @binding(4) var<storage, read_write> v_c : array<f32>;
@compute @workgroup_size(256)
fn main(@builtin(global_invocation_id) gid : vec3<u32>) {
  let i = gid.x + tile.xoff * 256u;
  if (i < p.n) { v_c[i] = p.s_alpha * v_a[i] + v_b[i]; }
}

run on 2026-10-01 21:17 inside the library at commit 0e72e2e2c; taken from base/test/gpu/gpu_declarative_narrated.ring(opens in a new tab)

The lanes, one by one

Lanes and their notes are quoted as they were read at the source, on Read from the source on 2026-09-16, from a read-only main worktree.

The calibration foundry
Strong
A checker runs reference vs candidate at a visible and a hidden shape, refusing by name any time under a measured roofline; a shape-keyed store keeps the winnergpu_verify.zig / gpu_foundry.zig (GK0)
Device & runtime (wgpu)
Strong
gpu.zig over vendored wgpu-native v29: generation-keyed handles, bounded VRAM cache, WGSL compile-cache, TDR-safe tiling, async dispatch, live instrumentsgpu.zig
Compute kernels
Strong
A WGSL kernel library: matmul (tiled + register-blocked), pairdist, softmax, reductions, FFT convolution (Stockham radix-2), fused multi-head attentiongpu_ops.zig / gpu_fft.zig
Compute + render on one device
Strong
Compute and render in one DLL sharing one device: instanced 2D display list, HarfBuzz text, texture atlas, 3D meshes in one instanced draw; zero-copy provengpu_scene.zig / gpu_text.zig / gpu_scene3d.zig
Acceleration seams (GS)
Strong
t-SNE 5-8x, UMAP 9.8-16.5x, k-means up to 6.1x, semantic index 2-2.5x, neural backbone 5.3x, vector search 17.9x; each with a bit-identical CPU fallbacktsne_gpu / umap_gpu / kmeans_gpu / neural_backbone.zig
W-string -> WGSL transpiler
Solid
gpu_wgsl.zig turns a stzKernelMaker spec into elementwise WGSL: f32-only, 20-function whitelist, refuses unknown functions by name; elementwise-onlygpu_wgsl.zig / stzKernelMaker
Browser / WebGPU edge tier
Solid
The transpiler compiles into stz.wasm; same spec -> byte-identical WGSL native vs browser -> f32-exact results (5/5); elementwise kernels onlytest/gpu/edge_proof
Residency & buffer model
Solid
Upload once -> run N kernels -> read once; every op takes and returns stzGpuBuffer handles; bounded FIFO VRAM cache; single-device, not usage-awarestzGpuBuffer
Idle / power management
Solid
stz_gpu_wake(cap_ms) does adaptive copies until one runs at full speed; every guard wakes the device before timing; idle-aware routing (GK1b) not builtWake(400)
Precision — f64 on GPU
Partial
f32 throughout; f64 refused by measured decision (consumer NVIDIA runs it at 1/64 of f32); the f64 solver tier stays CPU SIMDgpu_math.zig
Multi-GPU / scaling
Partial
Adapter enumeration and selection of one device, per-adapter calibration; no two-device parallelism, out of scope with a pre-written 1.5x kill lineSelectAdapter
3D render depth
Partial
A camera, one directional light, instanced meshes in a single call; no PBR materials, shadows, post-processing or a deep scene graphgpu_scene3d.zig / gpu_mesh.zig