DeepSeek · 2024-05 · Sparse MoE

DeepSeek-V2

DeepSeek-V2 is a multi-head latent attention (MLA) transformer released by DeepSeek in 2024-05, with 60 layers, hidden size 5120 and a context window of 163,840 tokens.

Layer stack

Attention ×60 · Layers 60

Key facts

FamilyDeepSeek
Released2024-05
Params236 B
Active21 B
Context163,840 tokens
AttentionMLA · kv_lora_rank 512
Layers60
Hidden5,120
Heads128
Vocab102,400
PositionRoPE
NormRMSNorm
Activationsilu
Dtypebf16
Architecture classDeepseekV2ForCausalLM

Architecture overview

t₁ t₂ t₃ t₄ input tokens Embedding · Vocab 102,400 → Hidden 5,120 Q · 128 Wᴰᴷⱽ ↓ c_KV · 512 kᴿ · RoPE 64 Wᵁᴷ/Wᵁⱽ ↑ ⊕kᴿ Attention KV cache/token ≈ 512+64 vs dense 2·5,120 → ≈ 1/17.8 Router E1 E2 E3 E4 E5 E6 E7 E8 +152… Shared expert ×2 top-6 of 160 experts · ≈ 21B params active per token × 60 transformer block Attention Feed-forward / MoE RMSNorm pre-norm Final norm · RMSNorm LM head → Vocab 102,400 p p p → next token Position RoPE Dtype BF16 Context 160K tok
Drawn from the shipped config.json · 60 layers / width 5,120 / context 163,840. Original diagram by this atlas.

Attention

multi-head latent attention (MLA). kv_lora_rank=512. RoPE θ=10,000.

Feed-forward / MoE

It is a sparse mixture-of-experts with 160 routed experts and top-6 routing; about 21B parameters are active per token.

Field-level comparison

Compared against the previous model of the same lab; where none exists, against the structurally closest model. The ratio column is this model divided by the comparison model.

Full-field comparison vs predecessor DeepSeekMoE 16B
ModelDeepSeek-V2DeepSeekMoE 16BRatio
model_typedeepseek_v2deepseek
architecturesDeepseekV2ForCausalLMDeepseekForCausalLM
hidden_size51202048×2.50
num_hidden_layers6028×2.14
num_attention_heads12816×8.00
num_key_value_heads12816×8.00
intermediate_size1228810944×1.12
hidden_actsilusilu
n_routed_experts16064×2.50
num_experts_per_tok66≈1
n_shared_experts22≈1
moe_intermediate_size15361408×1.09
kv_lora_rank512
qk_rope_head_dim64
q_lora_rank1536
rope_theta1000010000≈1
max_position_embeddings1638404096×40.00
rms_norm_eps0.0000010.000001≈1
vocab_size102400102400≈1
torch_dtypebfloat16bfloat16
attention_biasfalsefalse
attention_dropout00
aux_loss_alpha0.001
bos_token_id100000100000≈1
eos_token_id100001100001≈1
first_k_dense_replace11≈1

Most similar architectures

Similarity values range from 0 (no shared categorical features) to 1 (identical profiles).

Raw config fields

41 fields
architecturesDeepseekV2ForCausalLM
attention_biasfalse
attention_dropout0
aux_loss_alpha0.001
bos_token_id100000
eos_token_id100001
first_k_dense_replace1
hidden_actsilu
hidden_size5120
initializer_range0.02
intermediate_size12288
kv_lora_rank512
max_position_embeddings163840
model_typedeepseek_v2
moe_intermediate_size1536
moe_layer_freq1
n_group8
n_routed_experts160
n_shared_experts2
norm_topk_probfalse
num_attention_heads128
num_experts_per_tok6
num_hidden_layers60
num_key_value_heads128
pretraining_tp1
q_lora_rank1536
qk_nope_head_dim128
qk_rope_head_dim64
rms_norm_eps0.000001
rope_theta10000
routed_scaling_factor16
scoring_funcsoftmax
seq_auxtrue
tie_word_embeddingsfalse
topk_group3
topk_methodgroup_limited_greedy
torch_dtypebfloat16
transformers_version4.39.3
use_cachetrue
v_head_dim128
vocab_size102400