TL;DR
My model is a 16-layer transformer in which every feed-forward layer is a mixture of 64 experts, with 8 chosen per token. It has 6.86B parameters in total and 1.22B active per token, and Megatron’s start-up log agrees with my hand count: to the last parameter for the per-GPU count, which equals the active count, and to two decimals for the totals.
From DeepSeek V4 I kept the router’s square-root-softplus scores, RMSNorm on queries and keys, and a clamp inside each expert. I left out the rest of DeepSeek’s recent machinery: MLA, mHC, CSA/HCA, DSA, multi-token prediction, Engram and the FP4 KV cache. The whole model is a set of Megatron-LM flags in one shared file.
What you’ll learn
- What a mixture of experts is: experts, the router, top-k selection, load balance, and total against active parameters.
- What DeepSeek V4 changed, and which of its changes suit a 6.86B model trained on 4,096-token sequences.
- How to count an MoE’s parameters by hand, and check the count against the training log.
- How grouped-query attention sets the KV cache’s size, and how the model maps onto Megatron-LM flags.
A transformer layer, briefly
A decoder-only transformer turns each token into a vector of size \(d\), the hidden state; in my model \(d = 2{,}048\). Each of its 16 layers updates that vector twice, first with attention and then with a feed-forward network. Each update is added back to the vector (a residual connection), after an RMSNorm rescales the layer’s input.
Attention mixes information between positions. The feed-forward network works on each position alone, and in a dense model it holds most of the parameters. That is the part a mixture of experts replaces.
From a dense layer to a mixture of experts
The dense feed-forward layer
Modern transformers use a gated feed-forward network called SwiGLU [1]:
where \(x \in \mathbb{R}^{d}\) is the normalized hidden state; \(W_1, W_3 \in \mathbb{R}^{d_{\text{ff}} \times d}\) are the gate and up projections; \(W_2 \in \mathbb{R}^{d \times d_{\text{ff}}}\) is the down projection; \(\odot\) multiplies element by element. In words: one branch gates each of the \(d_{\text{ff}}\) features, the other supplies them, and \(W_2\) maps them back to size \(d\).
My dense baseline uses \(d_{\text{ff}} = 8{,}192\) and no biases, so one layer has \(3 \times 2{,}048 \times 8{,}192 = 50{,}331{,}648\) parameters. Every token passes through all of them.
The mixture
An MoE layer keeps \(E\) smaller copies of this network, the experts, and runs only \(k\) of them for each token:
where \(E_i\) is expert \(i\), a SwiGLU network of width \(d_e\). \(\mathcal{T}(x)\) is the set of \(k\) experts chosen for token \(x\), and \(g_i(x)\) is expert \(i\)’s gate weight. In words: the layer’s output is a weighted sum of the few experts picked for this token, and the others never run for it.
Mine has \(E = 64\), \(k = 8\) and \(d_e = 1{,}024\). Eight experts of width 1,024 add up to the dense layer’s 8,192. So a token uses exactly the dense layer’s feed-forward parameter count, \(8 \times 3 \times 2{,}048 \times 1{,}024 = 50{,}331{,}648\), while the layer stores 8 times as many.
The router
The router chooses \(\mathcal{T}(x)\). It is one linear layer that scores every expert:
where \(W_r \in \mathbb{R}^{E \times d}\) is the router matrix, \(z \in \mathbb{R}^{E}\) the expert logits, and \(\operatorname{TopK}(z, k)\) the indices of the \(k\) largest logits. In words: score all 64 experts, keep the best 8, and share the weight among them with a softmax.
This is the classic router, and Megatron’s default. The router is small, \(64 \times 2{,}048 = 131{,}072\) parameters per layer, but it decides everything. I run it in fp32. In bf16 the logits sit on a grid \(2^{16} = 65{,}536\) times coarser, and near-ties can send a token to different experts [2].
Total and active parameters
An MoE splits a number that a dense model keeps as one:
where \(N_{\text{other}}\) counts every parameter outside the experts: embeddings, attention, norms and routers. \(L\) is the number of layers and \(P_e\) the parameter count of one expert. In words: experts multiply the parameters you store by \(E\), but the parameters each token uses only by \(k\).
Training compute per token follows the active count, at about \(6N_{\text{active}}\) FLOPs. Capacity, the room to store what the model learns, follows the total. My model stores 6.86B parameters but computes like a 1.22B dense model: it stores 5.6 times what it uses.
Matched active parameters do not mean matched speed. Tokens must travel to experts on other GPUs, and narrow experts run small, less efficient matrix multiplies. With a perfectly even load, my MoE ran at 0.533 times the dense model’s throughput (Part 4).
Load balance
A router left alone tends to favour a few experts. Their GPUs then do most of the work while the others wait, and unused experts waste their parameters. The standard measure is MaxVio:
where \(c_i\) is the number of tokens routed to expert \(i\) in one layer over a batch. In words: how much busier the busiest expert is than the average one, where 0 means perfectly even.
Suppose every one of \(T\) tokens picks the same 8 experts. Each of those gets \(T\) tokens while the mean is \(kT/E\), so MaxVio reaches its ceiling, \(E/k - 1 = 7\). My V4 and auxiliary-loss test runs hit exactly 7.0, in every layer (Part 6).
Three methods fight this. The first adds an auxiliary loss, as Switch Transformers did [3]:
where \(f_i\) is the share of all token-to-expert assignments that went to expert \(i\). \(p_i(x)\) is the router’s probability for \(i\) on token \(x\), \(P_i\) its mean over the batch, and \(\alpha\) the loss weight. In words: an expert that already receives many tokens is pushed to receive less probability.
The handbook’s tested script uses \(\alpha = 10^{-3}\).
The second is a bias that only changes which experts are chosen, DeepSeek-V3’s “auxiliary-loss-free” balancing [4]:
where \(s_i(x)\) is expert \(i\)’s score, \(b_i\) its bias, and \(u\) the update rate, \(10^{-3}\) in both V3 and V4. In words: after each step, under-loaded experts’ biases rise by \(u\) and over-loaded ones’ fall by \(u\), and the gate weights ignore the bias.
In V3’s ablation, the bias-balanced model scored higher on most benchmarks, for example 27.1 → 29.6 on GSM8K in its small model. A further test in the same report traced that gain to balancing over the whole batch rather than to dropping the loss.
The third, quantile balancing, also keeps one bias per expert. Rather than step it by a fixed rate, it solves for the bias that gives each expert its even share, \(kT/E\) tokens. My main run used it; Part 6 explains why.
DeepSeek V4 in brief
DeepSeek V4 is a pair of MoE models with a one-million-token context [5]. V4-Pro has 1.6T parameters, 49B of them active; V4-Flash has 284B, with 13B active.
Its report lists three upgrades over V3. They are a hybrid of two compressed attentions (CSA and HCA), manifold-constrained hyper-connections (mHC) in place of plain residuals, and the Muon optimizer. It keeps DeepSeekMoE and multi-token prediction.
Its changes to the MoE itself are small and precise:
- the router’s score changes from a sigmoid to the square root of a softplus;
- balancing stays bias-based, with a slight sequence-wise balance loss added;
- the first layers, dense in V3, become MoE layers routed by a hash of the token id;
- each expert’s SwiGLU is clamped, against loss spikes tied to outliers in the MoE layers.
| DeepSeek-V4-Flash | My model | |
|---|---|---|
| Parameters, total / active | 284B / 13B | 6.86B / 1.22B |
| Layers / hidden size | 43 / 4,096 | 16 / 2,048 |
| Experts per MoE layer | 1 shared + 256 routed, 6 chosen | 64 routed, 8 chosen |
| Expert width | 2,048 | 1,024 |
| Routing in the first layers | hash of the token id (3 layers) | learned, like every layer |
| Attention | CSA and HCA, interleaved | grouped-query attention |
| Residual stream | mHC, 4 streams | plain |
| Multi-token prediction | depth 1 | none |
| Optimizer | Muon, with AdamW for some parameters | AdamW |
| Training tokens | 32T | 2.6B |
| Sequence length | up to 1M | 4,096 |
What I kept from V4
Megatron-LM at my pinned commit has V4’s score function, QK normalization and SwiGLU clamp as flags. Each goes on top of the tested shape without changing it, so I kept all three.
1. Square-root-softplus scores
V4 scores each expert with:
where \(z_i\) is the router logit from Eq. 3. In words: a smooth, always-positive score that keeps growing, like \(\sqrt{z_i}\), for large logits, where V3’s sigmoid flattens out at 1.
For very negative logits it falls towards zero, like \(e^{z_i/2}\).
The chosen experts’ gate weights are their scores, renormalized and scaled:
where \(\rho\) is the routed scaling factor, 2.5 in my model. In words: the 8 chosen scores are divided by their sum, so they add up to 1, then multiplied by 2.5.
Why scale? With equal weights on \(k\) uncorrelated experts of equal size, the combined output shrinks to \(1/\sqrt{k}\) of one expert’s. A factor near \(\sqrt{k}\), here \(\sqrt{8} \approx 2.83\), restores it. A correction to my own plan: it listed 2.5 under V4, but 2.5 is DeepSeek-V3’s value at top-8, and V4-Flash ships 1.5 at top-6.
In the main run, quantile balancing chose the experts with its bias on the logits, and the gate weights still came from Eq. 9:
where \(\beta_i\) is expert \(i\)’s quantile-balancing bias. In words: V4’s scores and weights, with a different rule for which experts get chosen.
2. RMSNorm on queries and keys
V4 applies RMSNorm to each query head and to its single key-value head just before attention, which keeps attention logits from exploding. Its report notes that this makes a separate logit cap, QK-Clip, unnecessary. Megatron’s --qk-layernorm normalizes each head’s query and key the same way:
where \(q_h\) is the query of head \(h\) and \(k_g\) the key of group \(g\), both of size \(d_h = 64\). \(\gamma_q\) and \(\gamma_k\) are learned gains of size 64, shared by all heads, and \(\epsilon = 10^{-5}\). In words: every query and key is rescaled to the same size before the dot product, so only its direction and the gains matter.
That bounds the logits. Since \(\lVert q/\operatorname{RMS}(q)\rVert_2 \le \sqrt{d_h}\), the Cauchy–Schwarz inequality gives:
where \(\lVert\gamma\rVert_\infty\) is the largest gain in absolute value. In words: an attention logit can grow only through 128 gain parameters, not through the size of the activations.
With unit gains, RMSNorm’s starting value, the bound is \(\sqrt{64} = 8\).
3. A clamped SwiGLU in every expert
V4 caps the gate branch of each expert’s SwiGLU at 10 and clips the linear branch to \([-10, 10]\). Megatron’s --activation-func-clamp-value 10 does exactly that:
where \(W_1^{(i)}, W_3^{(i)} \in \mathbb{R}^{d_e \times d}\) and \(W_2^{(i)} \in \mathbb{R}^{d \times d_e}\) are expert \(i\)’s matrices, \(c = 10\), and \(\min\) and \(\operatorname{clip}\) act element by element. In words: however large an expert’s inputs get, each element of its hidden activation stays below 100 in absolute value.
That holds because SiLU of at most 10 is below 10, and the clipped branch is at most 10. V4’s report concedes that the clamp, like its anticipatory routing, works but is not understood. I ran no test without the clamp, so I cannot say what it did here. The main run’s check for rogue experts, whose output norm sits far above their layer’s median, found none.
What I left out, and why
| Component | From | What it does | Why I left it out |
|---|---|---|---|
| MLA, multi-head latent attention | V2, V3 [4] | Caches a small latent vector per token instead of full keys and values | The tested shape uses GQA, at 16 KiB per token |
| mHC | V4 [5, 12] | Widens the residual stream into several streams mixed by doubly stochastic matrices | Rewires every layer; the tested shape has plain residuals |
| CSA and HCA | V4 [5] | Compress keys and values along the sequence; CSA then attends sparsely | Built for contexts up to 1M tokens; mine is 4,096 |
| DSA, DeepSeek Sparse Attention | V3.2 [9] | A light indexer picks the past entries each query attends to | A long-context saving too |
| MTP, multi-token prediction | V3, V4 [4, 5] | An extra module predicts a further token, with its own loss | A second loss to weigh, new to the tested recipe |
| Engram | V4.1 [10, 11] | Hashed n-gram memory tables, looked up by token ids | A V4.1 addition, with 196B parameters of tables there |
| FP4 KV cache | V4.1 [10] | Stores the main KV cache in 4-bit floating point | A long-context serving saving; my cache is bf16 |
Megatron-LM at my commit has switches for several of these: MLA, MTP, mHC, DSA, and an attention variant named for DeepSeek V4. So leaving them out was a choice, not a gap. The rule was to start from a shape already trained on this hardware, and add only changes that leave it intact. Most of the rest pays off only at long context, as the KV-cache numbers below show.
Three more of V4’s features went too. Muon would have taken about 14% of the run and needs tuning. Hash-routed first layers and a shared expert would each have left the tested shape.
My architecture, exactly
| Part | Setting | Megatron flags |
|---|---|---|
| Layers | 16, every one MoE | --num-layers 16 |
| Hidden size \(d\) | 2,048 | --hidden-size 2048 |
| Attention | 32 query heads, 4 key-value groups, head size 64 | --num-attention-heads 32 --group-query-attention --num-query-groups 4 --kv-channels 64 |
| QK normalization | RMSNorm per head on queries and keys | --qk-layernorm |
| Positions | RoPE, base 500,000, full head | --position-embedding-type rope --rotary-base 500000 --rotary-percent 1.0 |
| Norms | RMSNorm, \(\epsilon = 10^{-5}\) | --normalization RMSNorm --norm-epsilon 1e-5 |
| Experts | 64 routed, 8 per token, no shared expert | --num-experts 64 --moe-router-topk 8 |
| Expert width \(d_e\) | 1,024, SwiGLU clamped at 10 | --moe-ffn-hidden-size 1024 --swiglu --activation-func-clamp-value 10 |
| Router | Square-root-softplus scores, scaling 2.5, fp32 | --moe-router-score-function sqrtsoftplus --moe-router-topk-scaling-factor 2.5 --moe-router-dtype fp32 |
| Balancing, main run | Quantile balancing, no auxiliary loss | --moe-router-load-balancing-type quantile_balancing --moe-aux-loss-coeff 0 |
| Vocabulary | 128,256 (Llama 3.2 tokenizer), tied embeddings | --tokenizer-type HuggingFaceTokenizer, no untie flag |
| Sequence length | 4,096 | --seq-length 4096 |
| Biases, dropout | None; 0 | --disable-bias-linear --attention-dropout 0 --hidden-dropout 0 |
| Precision | bf16, with an fp32 router | --bf16 |
Tied embeddings means the output layer reuses the input embedding matrix. Part 3 covers the tokenizer.
Counting the parameters
Derivation
One layer holds attention, four norms, a router and 64 experts, with no biases anywhere:
where \(n_h = 32\) query heads and \(n_g = 4\) key-value groups each have size \(d_h = 64\). The attention term counts the query and output projections, \(d \times n_h d_h\) each, and the key and value projections, \(d \times n_g d_h\) each. The norms are the two RMSNorms before attention and the experts, plus the query and key norms. In words: per layer, the experts dwarf everything else.
The total adds 16 layers, a final norm of size \(d\), and the tied embedding, \(V d\) with \(V = 128{,}256\). The active count swaps \(E\) for \(k\) in the expert term only.
| Term | Per layer | All 16 layers, embedding and final norm |
|---|---|---|
| Attention | 9,437,184 | 150,994,944 |
| Norms | 4,224 | 67,584 + 2,048 |
| Router | 131,072 | 2,097,152 |
| One expert, \(3d\,d_e\) | 6,291,456 | — |
| 64 experts, stored | 402,653,184 | 6,442,450,944 |
| 8 experts, active | 50,331,648 | 805,306,368 |
| Embedding, \(V d\), tied | — | 262,668,288 |
| Total | 6,858,280,960 | |
| Active per token | 1,221,136,384 |
Megatron prints its own count at start-up. The main run’s log reads 6.60B parameters in the transformer layers, 0.96B of them active, and 0.26B in the embedding. In total that is 6.86B, with 1.22B active. Its exact per-GPU count, 1,221,136,384, equals my active count.
That match is no accident. With 8 of the 64 experts on each GPU, a GPU holds exactly as many experts per layer as a token uses. The dense baseline’s log gives 1,219,039,232, again matching Eq. 14 with the dense layer in place of the experts.
Three shares stand out. The experts hold 93.9% of all parameters. The 262.7M-parameter embedding is 21.5% of the active count, because the vocabulary is large and the model small. The router, which decides everything, is 0.03% of the model.
Attention and the KV cache
The model uses grouped-query attention (GQA) [6], in which many query heads share a few key and value heads:
where \(o_{h,t}\) is head \(h\)’s output at position \(t\), and \(v_{g,s}\) the value of group \(g\) at position \(s\). \(\mathcal{S}(t)\) holds the positions up to \(t\) in the same document, under causal and document masks, and \(g(h)\) maps 8 query heads onto each group. In words: 32 heads ask questions, but only 4 sets of keys and values answer them, each shared by 8 heads.
Queries and keys also carry rotary position embeddings, RoPE [7]. Each pair of dimensions \(j\) is rotated by an angle proportional to the position, at frequency \(r^{-2j/d_h}\) with base \(r = 500{,}000\). Megatron’s default base would have been 10,000.
During generation, each past token’s keys and values are kept in a KV cache. GQA shrinks it:
where \(B_{\text{KV}}\) is the bytes stored per token, the 2 counts keys and values, and \(b_{\text{el}} = 2\) bytes per element in bf16. In words: each token stores one key and one value per group, in every layer.
For my model that is \(2 \times 16 \times 4 \times 64 \times 2 = 16{,}384\) bytes, or 16 KiB per token. The serving engine allocated 4 MB per 256-token block, the same figure. A separate key and value for each of the 32 heads would take 8 times as much.
That is also why I could leave V4’s attention machinery out. At 16 KiB per token, a 4,096-token sequence needs 64 MiB of cache, while a 1M-token sequence would need 16 GiB. V4’s compressed attention exists for the second case.
The model as Megatron-LM flags
Megatron-LM is NVIDIA’s library for training large transformers [8]. My model is not Python code but a list of flags. They live once in code/scripts/megatron/common.sh, which every launch script sources. The file builds Bash arrays, so each group of flags carries its comments:
# The tested model shape, unchanged (common.sh L26-32)
MODEL=(--use-mcore-models --use-flash-attn --disable-bias-linear --transformer-impl transformer_engine
--position-embedding-type rope --rotary-percent 1.0 --rotary-base 500000
--rotary-seq-len-interpolation-factor 1 --normalization RMSNorm --swiglu --norm-epsilon 1e-5
--num-layers 16 --hidden-size 2048 --ffn-hidden-size 8192
--num-attention-heads 32 --group-query-attention --num-query-groups 4
--kv-channels 64 --qk-layernorm --seq-length 4096 --max-position-embeddings 4096
--attention-dropout 0 --hidden-dropout 0 --init-method-std 0.02)
# The experts, without a router, plus V4's clamp (common.sh L36-39)
MOE_BASE=(--num-experts 64 --moe-ffn-hidden-size 1024 --moe-router-topk 8
--moe-token-dispatcher-type alltoall --moe-grouped-gemm
--moe-router-dtype fp32 --moe-per-layer-logging
--activation-func-clamp-value 10)
--ffn-hidden-size 8192 sets the dense baseline’s width, and --moe-ffn-hidden-size 1024 each expert’s. The router is a separate array, so two study runs can differ in the router alone:
# V4's router as planned: scores, bias, sequence-wise loss, scaling (common.sh L49-52)
ROUTER_V4=(--moe-router-score-function sqrtsoftplus
--moe-router-enable-expert-bias --moe-router-bias-update-rate 1e-3
--moe-router-load-balancing-type seq_aux_loss --moe-aux-loss-coeff 1e-4
--moe-router-topk-scaling-factor 2.5)
# The handbook's tested router: softmax with an auxiliary loss (common.sh L70)
ROUTER_AUX=(--moe-router-load-balancing-type aux_loss --moe-aux-loss-coeff 1e-3)
# The main run's router: V4's scores, the routed scaling 2.5 and quantile balancing (common.sh L74-75)
ROUTER_V4_QB=(--moe-router-score-function sqrtsoftplus --moe-router-load-balancing-type quantile_balancing
--moe-aux-loss-coeff 0 --moe-router-topk-scaling-factor 2.5)
MAIN_ROUTER=v4|aux|qb picks one for pretraining and every later stage. They must all agree, because the score function and the balancing bias are part of the trained model. moe_v4_qb.sh is the study run that tested quantile balancing against the V4 run, with the same model, data, optimizer and seed. Megatron refuses any auxiliary loss beside quantile balancing, so V4’s sequence-wise loss had to go.
A model written as flags has one trap: a forgotten flag silently takes Megatron’s default. A draft of my plan left out the tested model flags. The defaults would have built LayerNorm, dropout 0.1, no SwiGLU, learned positions and RoPE base 10,000.
The older build documents also spelled the score function sqrt_softplus, which Megatron’s parser rejects, and listed a flag that unties the embeddings. So check_flags.py runs every launch script through Megatron’s own parser and config checks, on a CPU, before any GPU is used.
What this design does not show
- It is V4-style, not V4. Beyond the router scores, QK norm and clamp, it is a standard GQA MoE, close to Qwen3-MoE’s layout. Nothing here tests mHC, CSA/HCA or MTP.
- No ablations. I never trained without the clamp or the QK norm, so I cannot say what each one did.
- One run on few tokens. The model saw 2.6B tokens, about a tenth of the compute-optimal amount for its active size (Part 1).
Run it yourself
Hardware and time. Training needs one node of 8×H100 (80 GB, NVLink); the main pretraining run took 4.09 h for 1,240 steps. The dry run and the flag check below need only a CPU.
# 1. Print the exact arguments of the main run, one per line, without launching.
# The paths can be placeholders for a dry run.
DRY_RUN=1 MAIN_ROUTER=qb MEGATRON_PATH=/path/to/Megatron-LM TOKENIZER_DIR=/path/to/tokenizer \
DATA_DIR=/path/to/data RUN_DIR=/tmp/dry RUN_NAME=dry \
bash code/scripts/megatron/moe_pretrain.sh
# 2. Check every launch script against Megatron's parser and TransformerConfig (CPU only).
# MEGATRON_PATH must be a Megatron-LM checkout at commit d6316eb45
# (the setup guide shows how to get it).
python -I code/scripts/megatron/check_flags.py --validate "$MEGATRON_PATH"
# 3. On the 8×H100 node, after the setup guide has exported MEGATRON_PATH, TOKENIZER_DIR
# and DATA_DIR: the main pretraining run.
MAIN_ROUTER=qb CKPT_DIR=/workspace/ckpt/pretrain RUN_DIR=/workspace/runs/pretrain RUN_NAME=pretrain \
bash code/scripts/megatron/moe_pretrain.sh 2>&1 | tee /workspace/runs/pretrain.log
# 4. The parameter count Megatron prints at start-up.
grep -E "number of parameters on|parameters in billions" /workspace/runs/pretrain.log
What to expect. Step 1 prints arguments such as --moe-router-score-function sqrtsoftplus and --moe-router-load-balancing-type quantile_balancing. Step 4 prints these lines, among others:
> number of parameters on (tensor, gtp_remat, pipeline) model parallel rank (0, 0, 0): 1221136384
Number of parameters in transformer block in billions: 6.60
Number of active parameters in transformer block in billions: 0.96
Number of parameters in embedding layers in billions: 0.26
Total number of parameters in billions: 6.86
Total number of active parameters in billions: 1.22
The files:
- code/scripts/megatron/common.sh: every flag array, and the
MAIN_ROUTERswitch; - code/scripts/megatron/moe_pretrain.sh: the main pretraining run;
- code/scripts/megatron/moe_v4_qb.sh: the quantile-balancing study run;
- code/scripts/megatron/check_flags.py: the flag checker.
The setup guide prepares the node, and the pretraining guide gives every step of the run. The configs and flags reference lists each flag, and the results page every number.
What to take away
- An MoE stores \(E\) experts but runs \(k\): total parameters set capacity, active parameters set compute.
- Count the parameters by hand with Eq. 14, then check them against the framework’s log; here they agree exactly.
- V4’s MoE changes are small: a new score function, bias balancing and a clamp, plus QK norm in attention. Each is one flag in Megatron.
- Most of V4’s other machinery targets million-token contexts; at 4,096 tokens, GQA’s 16 KiB per token is enough.
- Keep the model’s flags in one shared file, and check every flag against the framework’s parser before a GPU is involved.
References
- N. Shazeer. GLU Variants Improve Transformer. arXiv:2002.05202, 2020. arxiv.org/abs/2002.05202
- Hugging Face. The Ultimate MoE Training Handbook. huggingface.co/spaces/huggingface/moe-blogpost
- W. Fedus, B. Zoph and N. Shazeer. Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity. arXiv:2101.03961, 2021. arxiv.org/abs/2101.03961
- DeepSeek-AI. DeepSeek-V3 Technical Report. arXiv:2412.19437, 2024. arxiv.org/abs/2412.19437
- DeepSeek-AI. DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence. arXiv:2606.19348, 2026. arxiv.org/abs/2606.19348
- J. Ainslie et al. GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints. arXiv:2305.13245, 2023. arxiv.org/abs/2305.13245
- J. Su et al. RoFormer: Enhanced Transformer with Rotary Position Embedding. arXiv:2104.09864, 2021. arxiv.org/abs/2104.09864
- NVIDIA. Megatron-LM, at commit d6316eb45. github.com/NVIDIA/Megatron-LM
- DeepSeek-AI. DeepSeek-V3.2: Pushing the Frontier of Open Large Language Models (DeepSeek Sparse Attention). arXiv:2512.02556, 2025. arxiv.org/abs/2512.02556
- DeepSeek-AI. DeepSeek-V4.1-Flash: Pushing the Limits of KV Cache Compression (Engram, the FP4 KV cache). Technical report; model card at huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash
- Cheng et al. Conditional Memory via Scalable Lookup (Engram). arXiv:2601.07372, 2026. arxiv.org/abs/2601.07372
- Xie et al. Manifold-Constrained Hyper-Connections (mHC). arXiv:2512.24880. arxiv.org/abs/2512.24880
Cite this
@misc{aboagye2026minidsv4part02,
author = {Aboagye, Prince Osei},
title = {Mini DeepSeek V4, Part 2: The model: a DeepSeek-V4-style mixture of experts},
year = {2026},
howpublished = {\url{https://poaboagye.github.io/blog/02-the-model/}}
}