llama-wgsl
A language model running on your GPU, inside the browser.
llama-wgsl downloads SmolLM2 from Hugging Face, streams the weights straight into GPU memory and runs every layer with compute shaders I wrote by hand in WGSL. No server, no WebAssembly, no ML framework: about 1,500 lines of plain JavaScript.
- Hand-written kernels. Fused QKV and SwiGLU matrix-vector kernels, grouped-query attention, RoPE with a KV cache, and a GPU argmax for greedy decoding.
- bf16 without shader-f16. Two weights per 32-bit word, widened in registers, so every WebGPU device can run it at half the memory of f32.
- Checked against transformers. Logits agree within 4.8e-5 and a 32-token greedy reply is identical, token for token.