GLM · Z.ai

GLM-5.2

GLM-5.2 from Z.ai has 743,377,019,904 parameters, of which about 41.3B are used for each token (a mixture of experts). Its weights take 1.49 TB in BF16 and about 372 GB at 4-bit, and each token of context adds 109.8 KB of KV cache (3.6 GB at 32K tokens).

743Bparameters
41.3Bactive per token
1.49 TBBF16 weights
372 GB4-bit weights
109.8 KBKV per token

Architecture · VRAM · KV cache · Tensor shapes · Parameter count · FLOPs

Architecture

ArchitectureGlmMoeDsaForCausalLM
Layers (L)78
Hidden size (d)6,144
AttentionMLA (multi-head latent attention)
Heads64 (query/key 192+64, value 256); KV compressed to rank 512
Feed-forward256 experts of 2,048, 8 per token, plus 1 shared (SwiGLU); 3 dense layers (layers 0–2) with FFN 12,288
Vocabulary (V)154,880
Tied embeddingsno: separate output head
Biasesnone
Extra normspre-norm (RMSNorm before attention and FFN)
Max context1,048,576 tokens
Sparse attentionDeepSeek Sparse Attention: a 32-head indexer picks the top 2,048 earlier tokens for each query; 21 of 78 layers have their own indexer, the rest reuse the previous one's choice
Weights in the release–

How much memory the weights need

Each parameter takes 4 bytes in FP32, 2 in BF16, 1 at 8 bits and half a byte at 4 bits, so the weights alone need:

PrecisionBytes per parameterWeights
FP3242.97 TB2769.30 GiB
BF16 / FP1621.49 TB1384.65 GiB
INT8 / FP81743 GB692.32 GiB
INT40.5372 GB346.16 GiB

GB here is 109 bytes; GiB (230) is what tools like nvidia-smi show. Real 4-bit files are a little larger: they also store scales, and some layers are often kept at higher precision. Every expert has to be in memory, not just the active ones: the router picks different experts for each token. A running model also needs its KV cache, activations and the runtime's own buffers.

Memory calculator

On common GPUs

Whether the weights plus a 8K-token KV cache fit in 90% of the card (how this is worked out):

Too big for any single card up to 80 GB, even at 4-bit: it needs 419 GB there. Split across 80 GB GPUs it takes at least 20 at BF16, 11 at 8-bit, 6 at 4-bit (the last row).

GPU memoryBF168-bit4-bit
80 GB1.49 TBtoo big791 GBtoo big419 GBtoo big
80 GB × n20 cards11 cards6 cards

Each cell is the weights plus the 8K-token KV cache at that precision; ✓ where it fits. The 80 GB × n row divides that evenly over n cards (tensor or pipeline parallel), the best case: real splits duplicate some buffers.

KV cache

What it is: the KV cache, explained.

MLA caches one compressed latent of r_kv = 512 numbers plus a shared RoPE key of h_r = 64 per layer, instead of full keys and values for every head:

L × (r_kv + h_r + h_I) × 2 bytes = 78 × (512 + 64 + 128) × 2 = 109,824 bytes per token

That is the figure for runtimes that cache the latent (vLLM, SGLang, DeepSeek's own). Code that expands it back to per-head keys and values caches 78 × 64 × (256 + 256) × 2 = 5.1 MB per token.

ContextKV cache, BF168-bit KVWeights + KV, BF16
4K450 MB225 MB1.49 TB
32K3.6 GB1.8 GB1.49 TB
128K14.4 GB7.2 GB1.5 TB
1024K (max)115 GB57.6 GB1.6 TB

For one sequence. Batching multiplies the KV cache by the number of sequences, not the weights.

Every tensor shape

The names are those in the Hugging Face checkpoint; shapes are [out, in] for weight matrices, as PyTorch stores them. One block is shown: the model repeats it 78 times (in two kinds).

TensorShapeParameters
Embedding
model.embed_tokens.weight[154,880, 6,144]951,582,720
Dense blocks with an indexer (layers 0–2): model.layers.N.…
self_attn.q_a_proj.weightcompress the query[2,048, 6,144]12,582,912
self_attn.q_a_layernorm.weight[2,048]2,048
self_attn.q_b_proj.weightexpand to every head[16,384, 2,048]33,554,432
self_attn.kv_a_proj_with_mqa.weightthe latent that is cached, plus one shared RoPE key[576, 6,144]3,538,944
self_attn.kv_a_layernorm.weight[512]512
self_attn.kv_b_proj.weightexpand the latent to keys and values[28,672, 512]14,680,064
self_attn.o_proj.weight[6,144, 16,384]100,663,296
self_attn.indexer.wq_b.weightindexer queries, from the compressed query[4,096, 2,048]8,388,608
self_attn.indexer.wk.weightone indexer key per token, cached[128, 6,144]786,432
self_attn.indexer.k_norm.weightLayerNorm[128]128
self_attn.indexer.k_norm.bias[128]128
self_attn.indexer.weights_proj.weighthow much each indexer head counts[32, 6,144]196,608
mlp.gate_proj.weight[12,288, 6,144]75,497,472
mlp.up_proj.weight[12,288, 6,144]75,497,472
mlp.down_proj.weight[6,144, 12,288]75,497,472
input_layernorm.weight[6,144]6,144
post_attention_layernorm.weight[6,144]6,144
MoE blocks with an indexer (every 4th: layers 6, 10, …, 74): model.layers.N.…
self_attn.q_a_proj.weightcompress the query[2,048, 6,144]12,582,912
self_attn.q_a_layernorm.weight[2,048]2,048
self_attn.q_b_proj.weightexpand to every head[16,384, 2,048]33,554,432
self_attn.kv_a_proj_with_mqa.weightthe latent that is cached, plus one shared RoPE key[576, 6,144]3,538,944
self_attn.kv_a_layernorm.weight[512]512
self_attn.kv_b_proj.weightexpand the latent to keys and values[28,672, 512]14,680,064
self_attn.o_proj.weight[6,144, 16,384]100,663,296
self_attn.indexer.wq_b.weightindexer queries, from the compressed query[4,096, 2,048]8,388,608
self_attn.indexer.wk.weightone indexer key per token, cached[128, 6,144]786,432
self_attn.indexer.k_norm.weightLayerNorm[128]128
self_attn.indexer.k_norm.bias[128]128
self_attn.indexer.weights_proj.weighthow much each indexer head counts[32, 6,144]196,608
mlp.gate.weightthe router: one score per expert[256, 6,144]1,572,864
mlp.gate.e_score_correction_biasrouting only[256]256
mlp.experts.{0…255}.gate_proj.weight256 × [2,048, 6,144]3,221,225,472
mlp.experts.{0…255}.up_proj.weight256 × [2,048, 6,144]3,221,225,472
mlp.experts.{0…255}.down_proj.weight256 × [6,144, 2,048]3,221,225,472
mlp.shared_experts.gate_proj.weightshared expert: runs for every token[2,048, 6,144]12,582,912
mlp.shared_experts.up_proj.weightshared expert: runs for every token[2,048, 6,144]12,582,912
mlp.shared_experts.down_proj.weightshared expert: runs for every token[6,144, 2,048]12,582,912
input_layernorm.weight[6,144]6,144
post_attention_layernorm.weight[6,144]6,144
MoE blocks that reuse an indexer (57 layers): model.layers.N.…
self_attn.q_a_proj.weightcompress the query[2,048, 6,144]12,582,912
self_attn.q_a_layernorm.weight[2,048]2,048
self_attn.q_b_proj.weightexpand to every head[16,384, 2,048]33,554,432
self_attn.kv_a_proj_with_mqa.weightthe latent that is cached, plus one shared RoPE key[576, 6,144]3,538,944
self_attn.kv_a_layernorm.weight[512]512
self_attn.kv_b_proj.weightexpand the latent to keys and values[28,672, 512]14,680,064
self_attn.o_proj.weight[6,144, 16,384]100,663,296
mlp.gate.weightthe router: one score per expert[256, 6,144]1,572,864
mlp.gate.e_score_correction_biasrouting only[256]256
mlp.experts.{0…255}.gate_proj.weight256 × [2,048, 6,144]3,221,225,472
mlp.experts.{0…255}.up_proj.weight256 × [2,048, 6,144]3,221,225,472
mlp.experts.{0…255}.down_proj.weight256 × [6,144, 2,048]3,221,225,472
mlp.shared_experts.gate_proj.weightshared expert: runs for every token[2,048, 6,144]12,582,912
mlp.shared_experts.up_proj.weightshared expert: runs for every token[2,048, 6,144]12,582,912
mlp.shared_experts.down_proj.weightshared expert: runs for every token[6,144, 2,048]12,582,912
input_layernorm.weight[6,144]6,144
post_attention_layernorm.weight[6,144]6,144
After the last block
model.norm.weightfinal norm[6,144]6,144
lm_head.weightscores every token in the vocabulary[154,880, 6,144]951,582,720

The parameter count, step by step

Each line gives the formula, the numbers from config.json, and the subtotal. The symbols:

V
vocabulary 154,880
d
hidden size 6,144
L
layers 78
H
attention heads 64
h_n
query/key size without RoPE 192
h_r
RoPE part of query/key 64
h_v
value size per head 256
r_kv
KV latent rank 512
r_q
query latent rank 2,048
f
FFN hidden size 12,288
E
routed experts 256
k
experts per token 8
f_e
expert FFN size 2,048

1. Embedding

One row of d numbers for each of the V tokens in the vocabulary.

Embedding
V × d
154,880 × 6,144
= 951,582,720

2. Dense blocks with an indexer (layers 0–2), ×3

Attention (MLA)
r_q × d + r_q + H·(h_n+h_r) × r_q + (r_kv+h_r) × d + r_kv + H·(h_n+h_v) × r_kv + d × H·h_v
2,048 × 6,144 + 2,048 + 16,384 × 2,048 + 576 × 6,144 + 512 + 28,672 × 512 + 6,144 × 16,384
= 165,022,208
Indexer (32 heads, top 2,048 keys)
H_I·h_I × r_q + h_I × d + 2 × h_I + H_I × d
4,096 × 2,048 + 128 × 6,144 + 2 × 128 + 32 × 6,144
= 9,371,904
Feed-forward (SwiGLU)
2 × (f × d) + d × f
2 × (12,288 × 6,144) + 6,144 × 12,288
= 226,492,416
Norms
2 × d
2 × 6,144
= 12,288
One block
attention + indexer + feed-forward + norms
165,022,208 + 9,371,904 + 226,492,416 + 12,288
= 400,898,816
3 blocks
3 × block
3 × 400,898,816
= 1,202,696,448

3. MoE blocks with an indexer (every 4th: layers 6, 10, …, 74), ×18

Attention (MLA)
r_q × d + r_q + H·(h_n+h_r) × r_q + (r_kv+h_r) × d + r_kv + H·(h_n+h_v) × r_kv + d × H·h_v
2,048 × 6,144 + 2,048 + 16,384 × 2,048 + 576 × 6,144 + 512 + 28,672 × 512 + 6,144 × 16,384
= 165,022,208
Indexer (32 heads, top 2,048 keys)
H_I·h_I × r_q + h_I × d + 2 × h_I + H_I × d
4,096 × 2,048 + 128 × 6,144 + 2 × 128 + 32 × 6,144
= 9,371,904
Mixture of experts (256 experts, 8 per token)
E × d + E + 2 × (E × (f_e × d)) + E × (d × f_e) + 2 × (f_e × d) + d × f_e
256 × 6,144 + 256 + 2 × (256 × (2,048 × 6,144)) + 256 × (6,144 × 2,048) + 2 × (2,048 × 6,144) + 6,144 × 2,048
= 9,702,998,272
Norms
2 × d
2 × 6,144
= 12,288
One block
attention + indexer + mixture of experts + norms
165,022,208 + 9,371,904 + 9,702,998,272 + 12,288
= 9,877,404,672
18 blocks
18 × block
18 × 9,877,404,672
= 177,793,284,096

4. MoE blocks that reuse an indexer (57 layers), ×57

Attention (MLA)
r_q × d + r_q + H·(h_n+h_r) × r_q + (r_kv+h_r) × d + r_kv + H·(h_n+h_v) × r_kv + d × H·h_v
2,048 × 6,144 + 2,048 + 16,384 × 2,048 + 576 × 6,144 + 512 + 28,672 × 512 + 6,144 × 16,384
= 165,022,208
Mixture of experts (256 experts, 8 per token)
E × d + E + 2 × (E × (f_e × d)) + E × (d × f_e) + 2 × (f_e × d) + d × f_e
256 × 6,144 + 256 + 2 × (256 × (2,048 × 6,144)) + 256 × (6,144 × 2,048) + 2 × (2,048 × 6,144) + 6,144 × 2,048
= 9,702,998,272
Norms
2 × d
2 × 6,144
= 12,288
One block
attention + mixture of experts + norms
165,022,208 + 9,702,998,272 + 12,288
= 9,868,032,768
57 blocks
57 × block
57 × 9,868,032,768
= 562,477,867,776

5. Final norm and output head

Final norm + head
d + V × d
6,144 + 154,880 × 6,144
= 951,588,864

6. Total

Total
embedding + blocks + final
951,582,720 + 1,202,696,448 + 177,793,284,096 + 562,477,867,776 + 951,588,864
= 743,377,019,904

7. Active parameters per token

The router sends each token to 8 of the 256 experts in each MoE block, so only those experts' weights are used, plus the shared expert, which every token uses. One routed expert is 37,748,736 parameters.

Active
total − MoE blocks × (E − k) × expert
743,377,019,904 − 75 × 248 × 37,748,736
= 41,250,530,304

8. Multi-token prediction

The checkpoint also ships 1 multi-token-prediction module, trained to guess tokens further ahead. It is not used for ordinary decoding (it can drive speculative decoding), so it is left out of the total above but is in the files.

MTP module 1 (layer 78): its own pieces
3 × d + d × 2d
3 × 6,144 + 6,144 × 12,288
= 75,515,904
MTP module 1: a transformer block
one block, as in MoE blocks with an indexer
9,877,404,672
= 9,877,404,672
In the checkpoint
language model + MTP
743,377,019,904 + 9,952,920,576
= 753,329,940,480

Hugging Face counts 753,329,940,480 parameters in the zai-org/GLM-5.2 safetensors files. The arithmetic above matches exactly.

FLOPs per token

A forward pass costs about two floating-point operations (a multiply and an add) for every weight a token passes through: 2 × N, with N the active weights used in matrix multiplies (the embedding lookup is a read, not a multiply; the output head is a multiply). Here that is 2 × 41,250,530,304 = 82.5 GFLOPs per token.

Attention adds the work of comparing the token with every earlier one: 2 × L × T × H × (hqk + hv) for T tokens of context, which grows with the context while 2N does not.

That is for one new token at position T, as when generating. Averaged over a whole training sequence of length T, each token sees T/2 earlier ones on average, which halves it.

Context T2NAttentionTotal per token
4K82.5 GFLOPs20.9 GFLOPs103.4 GFLOPs
32K82.5 GFLOPs167.5 GFLOPs250.0 GFLOPs
128K82.5 GFLOPs670.0 GFLOPs752.5 GFLOPs
1024K82.5 GFLOPs5.36 TFLOPs5.44 TFLOPs

Training costs about three times the forward pass per token (6N): the backward pass does roughly twice the forward work.

More in the glossary: FLOPs per token · quantization · parameters.

Compare

GLM-5.2 vs Inkling · GLM-5.2 vs DeepSeek-V3.2 · Compare with any model →

Close in size: DeepSeek-V3.2 672B · DeepSeek-V3 671B · DeepSeek-R1 671B · DeepSeek-V3.1 671B · Inkling 947B

Source

Read from zai-org/GLM-5.2, fetched 2026-12-03. GLM-5.3 has these shapes. GLM-5 and 5.1 put an indexer in every layer instead of one in four, which makes them about 0.5B larger.