Historical Evolution & Inductive Bias Matrix (1958–Present)
| Era & Family | Core Primitive | Inductive Bias | Compute & Memory Scaling | What It Solved & Where It Breaks |
|---|---|---|---|---|
| Perceptron (1958) | y = step(w·x + b) |
Single linear hyperplane | O(D) |
Solved linearly separable classification; fails on XOR and non-convex manifolds. |
| Feedforward MLP + Backprop (1986) | A = σ(XW + b) |
Universal function approximation over flat vectors | O(L · D²) |
Learns arbitrary non-linear features via chain rule; lacks spatial or sequential invariance. |
| Convolutional Nets (1989–2012) | (I ∗ K)r,c + Pooling |
2D locality & translation equivariance | O(H · W · Cin · Cout · k²) |
Dramatically reduces parameters on grids/images; fixed local receptive field per layer. |
| Recurrent Nets & LSTM/GRU (1986–1997) | ht = (1−zt)⊙ht−1 + zt⊙h̃t |
Markovian temporal state & additive memory gate | O(T · D²) sequential steps |
Constant Error Carousel prevents temporal vanishing gradients; cannot parallelize across time T. |
| Deep Residual Nets / ResNets (2015) | x(l) = x(l−1) + Fl(Norm(x(l−1))) |
Identity skip highway + variance standardization | O(L · D²) for L > 100 |
Additive +I Jacobian prevents gradient shattering at extreme depth. |
| Transformers (2017) | softmax(QKT/√dk)V |
Dynamic all-to-all token routing | O(T² · D + T · D²) |
Parallelizes sequence training & eliminates recurrent bottlenecks; quadratic O(T²) KV-cache growth. |
| Continuous Image DDPM (2020) | εθ(√ᾱtx0 + √(1−ᾱt)ε, t) |
Iterative score/noise field reversal | O(S · FLOPsbackbone) over S steps |
Stable high-dimensional distribution synthesis without adversarial collapse; requires multiple denoising steps. |
| Discrete Masked Text Diffusion (2024) | pθ(x0 | zt) over [MASK] |
Bidirectional parallel token refinement | O(S · T² · D) with S ≪ T |
Generates and edits tokens in parallel by confidence instead of strict left-to-right decoding. |
| Decision Pointer Heads (2025) | (Wqhlast)T(Wkh‹k›)/T |
Bounded option scoring + calibrated abstention | Single forward pass O(T · D²) |
Eliminates multi-token JSON generation for classification/routing; cannot invent free-form prose. |
| Selective SSM / Mamba & Sparse MoE | ht = Ā(xt)ht−1 + B̄(xt)xt |
Input-dependent linear recurrence / conditional capacity | O(T · D) state scan; active parameter sparsity |
Linear-time long context and massive parameter capacity at fixed FLOPs per token. |
Structuring Neural Network Kernels: Raw JS vs Raw WASM vs WebGPU
| Runtime Target | Memory Model | Parallelism & Dispatch | Sweet Spot |
|---|---|---|---|
Raw JS (Float32Array) |
TypedArray views on V8/JSC heap; zero copy to DOM/Canvas | Single thread (or Web Workers); JIT loop unrolling when loop order is i → k → j |
Micro-models (D ≤ 64), rapid prototyping, zero marshaling overhead |
Raw WebAssembly (wasm32) |
Contiguous linear arena WebAssembly.Memory with deterministic 4-byte f32.load/f32.store |
Predictable AOT/JIT machine code, 128-bit v128 SIMD (f32x4.mul), zero GC pauses |
CPU inference & training from D = 32 to D = 1024 across all browsers |
WebGPU (WGSL @compute) |
Explicit device storage buffers + fast on-chip var<workgroup> shared SRAM tiles |
Thousands of concurrent GPU threads grouped into @workgroup_size(8, 8) tiles synchronized via workgroupBarrier() |
Large batch/matrix sizes (M, K, N ≥ 256) where compute FLOPs amortize PCIe/queue submission latency |
How the In-Memory Raw WebAssembly (wasm32) GEMM Kernel Works
In site/neural-networks/engine.js, buildWasmGemmBytes() constructs a valid 183-byte WebAssembly binary module directly in a Uint8Array—with zero external .wasm files or C/Rust compilers. Both JavaScript and WebAssembly share a contiguous WebAssembly.Memory buffer viewed as a Float32Array:
;; Disassembly of the in-memory compiled gemm_f32(aPtr, bPtr, cPtr, M, K, N) kernel
(func $gemm_f32 (export "gemm_f32")
(param $aPtr i32) (param $bPtr i32) (param $cPtr i32)
(param $M i32) (param $K i32) (param $N i32)
(local $i i32) (local $j i32) (local $k i32) (local $sum f32)
;; Triple nested loop over M × N × K reading/writing linear memory in 4-byte f32 strides:
;; sum += f32.load(aPtr + ((i * K + k) << 2)) * f32.load(bPtr + ((k * N + j) << 2))
;; f32.store(cPtr + ((i * N + j) << 2), sum)
)
Reverse-Mode Autograd & Decoupled AdamW Update
Every neural network training loop follows four exact steps: (1) forward pass caching intermediate pre-activations z(l) and activations a(l), (2) loss evaluation at the output head, (3) reverse-mode chain-rule propagation of δ(l) = ∂L / ∂z(l), and (4) parameter update:
// Output layer gradient for Sigmoid + Binary Cross-Entropy simplifies to (p - y) / N
for (let i = 0; i < N; i++) dZ[i] = (probs[i] - Y[i]) / N;
// Backpropagate through hidden layers l = L-1 ... 0
for (let l = layers.length - 1; l >= 0; l--) {
// 1. Parameter gradients: dW = prevA^T · dZ, db = sum(dZ)
// 2. Propagate error to previous layer: dPrevZ = (dZ · W^T) * activationGrad(prevZ)
// 3. Decoupled AdamW update:
m = beta1 * m + (1 - beta1) * g;
v = beta2 * v + (1 - beta2) * (g * g);
w = w * (1 - lr * weightDecay) - lr * (mHat / (Math.sqrt(vHat) + 1e-8));
}
Extending the Workbench with registerBlockType()
You can register new neural network paradigms into BLOCK_REGISTRY from the browser console or module code at any time:
import { registerBlockType } from "./engine.js";
registerBlockType({
type: "griffin_rg_lru",
label: "Real-Gated Linear Recurrent Unit (RG-LRU)",
category: "recurrent",
description: "Diagonal gated linear recurrence with hardware-efficient scan.",
computeStats(shape) {
return {
outShape: { ...shape },
params: 3 * shape.d * shape.d,
flops: 6 * shape.t * shape.d * shape.d
};
}
});