Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

Developer releases a 190-line pure-JAX implementation of DeepSeek-V3

AI summary

A developer released a pure-JAX implementation of key DeepSeek-V3 architecture components in 190 lines, along with tests, a checkpoint, training logs, diagrams, and reproduction instructions. The author reports pretraining a 36.2M-parameter model on public-domain detective fiction using a MacBook Air M5, while explicitly describing it as an architecture demonstration rather than a capable language model. The project omits sparse expert dispatch, MLA weight absorption, FP8 training, DualPipe, node-limited routing, YaRN, and post-training.

In-depth insight

The release provides a compact, readable reference for studying MLA, DeepSeekMoE routing, balancing, and multi-token prediction, although its reported training results remain author-supplied and the implementation is not operationally equivalent to full DeepSeek-V3.

The architecture from the DeepSeek-V3 technical report in 190 lines of pure JAX, pretrained from scratch on a MacBook Air on public-domain detective fiction.

No Flax, no Equinox, no PyTorch. Params are plain dicts of arrays and every part of the model is a function you can read top to bottom in deepseek_v3.py.

Read the write-up:DeepSeek V3 in 190 lines of pure JAX, with diagrams, the code explained piece by piece, and the results.

What's in the 190 lines

Idea from the paperWhat it doesWhere
Multi-head Latent Attention (MLA)Caches one small latent per token instead of full keys and values: 480 → 144 numbers per token per layer heremla, init_cache
Decoupled RoPEOne rotary key shared by all heads, kept outside the compressed latentrope, apply_rope, mla
DeepSeekMoE1 shared expert that always runs + 16 routed experts, top-4 per tokenroute, moe
Auxiliary-loss-free balancingA per-expert bias nudges routing toward idle experts; it changes which experts are picked, not their weightsupdate_bias, route
Sequence-wise balance lossThe small complementary loss from the paper (α = 1e-4)seq_balance_loss
Multi-token prediction (MTP)An extra module also predicts the token after next, weighted λ = 0.3 in the lossforward, loss_fn
Training and generationbf16 compute on f32 master weights; prefill + decode with the MLA cachemake_train_step, generate

#DeepSeek-V3#deepseek-v3-jax#JAX#DeepSeekMoE#Multi-head Latent Attention#DeepSeek-AI

Original · 6 min readRead the original
Group chat

No comments yet. Start the conversation.