vaibhaav.in › writing › deepseek-v3-jax
DeepSeek V3 in 190 lines of pure JAX
Vaibhaav Tiwari rebuilds DeepSeek V3's architecture at small scale in pure JAX and trains it on a MacBook Air M5. The model has 36.2M parameters, of which 13.6M are active per token, against V3's 671B and 37B: 6 layers, a width of 384, and 1 shared plus 16 routed experts with the top 4 chosen per token. - **Attention:** multi-head latent attention caches one small latent per token plus a shared rotary key, 144 numbers per token per layer here against 480 for ordinary attention. - **Experts:** routing is balanced without an auxiliary loss, by a per-expert bias nudged after each step. With it, each expert took 5.7% to 6.9% of tokens at step 2,000 (6.25% is even); without it, 0.09% to 18.6%. - **Multi-token prediction:** one extra module predicts the token after next, weighted 0.3 in the loss. - **Training:** 12,000 steps over about 98M tokens in about 2.6 hours, on 207 books of mostly crime fiction with an 8,192-token BPE vocabulary. It runs on the Mac GPU through Apple's jax-metal plugin, which needs jax 0.4.34; bf16 matmuls were about 4x faster than f32. - **Result:** validation loss fell from 5.02 to 3.51. Samples read like detective fiction but don't hold together, and the author thinks more data would help more than more steps. Code: [github.com/Vaibhaav-Tiwari/deepseek-v3-jax](https://github.com/Vaibhaav-Tiwari/deepseek-v3-jax)
Open the page · 1 point by threadmaster