Phase 02 — Inference from First Principles
This phase opens the runtime black box. It implements enough tensor machinery to show how weights, layouts, arithmetic, activations, and numerical error become an inference result, then accelerates the same verified workload.
Branches
- Tensor Kernels & Inference from Scratch — shapes, strides, layouts, broadcasting, matrix multiplication, convolution, bias, activations, softmax, normalization, weights, and forward passes.
- SIMD, Threads & Workers — SIMD128, autovectorization, intrinsics, shared memory, atomics, Web Workers, cross-origin isolation, worker pools, and parallel overhead.
Workbench milestones
v1 — Tiny inference engine: load fixed weights and execute a small MLP using dense tensors, matrix multiplication, bias, ReLU, and stable softmax.
v2 — SIMD and parallelism: compare the same kernel and fixture across scalar Wasm, SIMD128, and a justified threaded/worker path.
What this phase establishes
- Tensor contracts whose element type, shape, strides, and layout are explicit.
- Numerically stable primitives checked against an independent reference.
- A scalar implementation that remains the correctness baseline.
- Measurements that separate useful compute from copies, scheduling, and worker startup.
- Honest criteria for when SIMD or threads do not improve the workload.
Exit criteria
- The tiny engine reproduces golden logits or probabilities within a documented tolerance.
- Scalar, SIMD, and threaded variants consume the same inputs and semantics.
- Reports include warm-up, p50/p95, throughput, peak memory, copies, module size, and environment.
- Cross-origin isolation and unavailable-thread paths are tested explicitly.
Continue with Phase 03: From Models to Browser Inference.