⚡ GPU Neural Trainer

checking WebGPU… ← Portfolio

A tensor/autodiff engine written from scratch, with two backends: plain JS on the CPU (the reference implementation), and hand-written WebGPU compute shaders (WGSL) — forward and backward, not just inference. No TensorFlow.js, no ONNX Runtime. Trains a small MLP on 8×8 handwritten digits (sklearn.datasets.load_digits, baked in, no fetch) and reports held-out test accuracy, not training accuracy. Run the self-test panel below to cross-check the GPU kernels against the CPU reference on your own device, and the benchmark panel to see the real (sometimes negative) speedup of GPU compute at small problem sizes.

Training loss

Held-out test set — live predictions

Self-test: WebGPU kernels vs the CPU reference engine, on this device

Runs a forward + backward pass through both backends on identical weights and an identical batch of real digit images, then compares every intermediate tensor (logits, loss, and all four parameter gradients) between float32 GPU and float64 CPU arithmetic.

Benchmark: measured GPU vs CPU training-step time

Times one full forward+backward+Adam-update step, averaged over many repeats, at several (batch size, hidden width) combinations. WebGPU has real kernel-launch and buffer-transfer overhead — small problems can be slower on the GPU. The numbers below are measured on your device, right now, not assumed.

Model & training

Idle.

Dataset

Core engine: nucleu.js (CPU reference, loaded by both this page and node verificare.js) and webgpu.js (WGSL compute kernels). Dataset: digits.js. node verificare.js gradient-checks the CPU engine and trains it to convergence as portfolio evidence — see the README in the project source for the exact numbers.