Prince Osei Aboagye
// Mini DeepSeek V4

Blog

Mini DeepSeek V4: Building an LLM From Scratch. A DeepSeek-V4-style mixture of experts: the model, the distributed training system, pretraining, SFT and RL (GRPO/GSPO), explained, built and measured on 8×H100.

  1. Dec 2026Part 00~23 min read

    Part 00: Start here: the whole project on one page

    The map of the series: what I built, what every stage measured and how noisy each number is, which part to read next, what hardware each level needs, and a glossary with the math.

    Read article →
  2. Dec 2026Part 01~21 min read

    Part 01: Planning the project, and the rules I wrote before the data

    How I scoped a DeepSeek-V4-style mixture-of-experts project, chose its size, fixed decision rules before seeing results, gated the path from a laptop to 8×H100, and kept a lab notebook that survived an audit.

    Read article →
  3. Dec 2026Part 02~19 min read

    Part 02: The model: a DeepSeek-V4-style mixture of experts

    A mixture of experts explained from scratch; what I kept from DeepSeek V4 and what I left out; my exact architecture, its parameter count checked against the training log, and the Megatron-LM flags that define it.

    Read article →
  4. Dec 2026Part 03~22 min read

    Part 03: Data and the tokenizer, and the traps inside public math data

    Every dataset behind the model: the Llama 3.2 tokenizer, 2.6B tokens of FineWeb-Edu, 55,083 checked SFT questions and a four-tier RL curriculum, with the checks that caught bad data before the 8×H100 run.

    Read article →
  5. Dec 2026Part 04~23 min read

    Part 04: The training system: Megatron-LM on 8×H100

    How I laid out a 6.86B-parameter mixture of experts on one 8×H100 node with Megatron-LM: the five kinds of parallelism, the memory and communication arithmetic, the checks on a new node, and what the measurements showed.

    Read article →
  6. Dec 2026Part 05~22 min read

    Part 05: Numerics and reproducibility: why the same weights gave different numbers

    How bf16 rounding, the order of sums and batching change an RL run's numbers, with measurements: two laptop bugs and their fixes, a first GSPO update that was not exactly on-policy on 8×H100, greedy answers that change with the batch, and what reproducing a run takes.

    Read article →
  7. Dec 2026Part 06~23 min read

    Part 06: Pretraining, and the router that collapsed

    Pretraining a 6.86B-parameter mixture of experts on 2.6B tokens on 8×H100: next-token training from scratch, how router balance is measured, why every router recipe collapsed in its first steps, and how quantile balancing fixed it.

    Read article →
  8. Dec 2026Part 07~22 min read

    Part 07: Supervised fine-tuning: teaching the answer format

    What supervised fine-tuning is, why its loss counts only the answer, and what 55,083 worked math solutions did for a weak 6.86B-parameter mixture of experts on 8×H100.

    Read article →
  9. Dec 2026Part 08~19 min read

    Part 08: Rewards and graders: checking the checker

    How a verifiable reward turns an answer into a number, how I audited my graders with deliberately broken answers, why false accepts matter most when the model rarely succeeds, and the grader that hung training.

    Read article →
  10. Dec 2026Part 09~34 min read

    Part 09: Reinforcement learning: GRPO and GSPO

    RL with a verifiable reward from first principles: the policy gradient, GRPO's group baseline, GSPO's sequence ratio and clip, the KL penalty and a worked example. Then the laptop experiments, the Megatron patch, and what GSPO did to a 6.86B mixture-of-experts model on 8×H100.

    Read article →
  11. Dec 2026Part 10~25 min read

    Part 10: The RL system: synchronous or asynchronous?

    One GSPO step on 8×H100, phase by phase: why generation waits for the longest answer, what asynchronous RL would change, and why I kept the loop synchronous.

    Read article →
  12. Dec 2026Part 11~18 min read

    Part 11: Serving, and the inference engine

    Prefill, decode, the KV cache and CUDA graphs, explained with our model's numbers; how Megatron's dynamic engine served the MoE on 8×H100; and why the 4-bit model could not run in it.

    Read article →
  13. Dec 2026Part 12~22 min read

    Part 12: Distillation and 4-bit training: tested on a laptop and one H100, then cut

    Knowledge distillation and 4-bit quantization-aware training, explained with their equations and then tested: on a laptop GPU, where a teacher made from-scratch students worse, and on one H100, where both pipelines ran before I cut them from the 8×H100 run.

    Read article →
  14. Dec 2026Part 13~17 min read

    Part 13: Evaluation: how to tell if training worked

    Greedy, pass@k and avg@k defined, with the unbiased pass@k estimator; paired tests in plain words; noise floors from evaluating the same weights twice; sharpening against reach; and a checklist for honest RL evaluation.

    Read article →
  15. Dec 2026Part 14~23 min read

    Part 14: The control run: was it the model or the RL code?

    RL barely moved my own model. Run on Qwen2.5-Math-1.5B with PocketRL's data, prompt and grader, my GSPO pipeline matched their published learning curve, which put the blame on my base model.

    Read article →
  16. Dec 2026Part 15~20 min read

    Part 15: Lessons: what broke, what I'd change, what's next

    The path from a 6 GB laptop to one H100, 8×H100 and a control run, and what each stage caught; the top failures as symptom, cause and fix; the arithmetic of why RL gained so little; what I would do differently; and what comes next.

    Read article →