GLM · Z.ai

GLM-4.5

GLM-4.5 from Z.ai has 352,797,829,024 parameters, of which about 33.6B are used for each token (a mixture of experts). Its weights take 706 GB in BF16 and about 176 GB at 4-bit, and each token of context adds 376.8 KB of KV cache (12.3 GB at 32K tokens).

353Bparameters
33.6Bactive per token
706 GBBF16 weights
176 GB4-bit weights
376.8 KBKV per token

Part of the GLM-4.5 family: 107B · 353B

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

Architecture

ArchitectureGlm4MoeForCausalLM
Layers (L)92
Hidden size (d)5,120
AttentionGQA (12 query heads share each KV head)
Heads96 query, 8 key/value, 128 each
Feed-forward160 experts of 1,536, 8 per token, plus 1 shared (SwiGLU); 3 dense layers (layers 0–2) with FFN 12,288
Vocabulary (V)151,552
Tied embeddingsno: separate output head
Biaseson q, k and v
Extra normsRMSNorm on q and k (per head)
Max context131,072 tokens
Weights in the releasebfloat16

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
FP3241.41 TB1314.27 GiB
BF16 / FP162706 GB657.14 GiB
INT8 / FP81353 GB328.57 GiB
INT40.5176 GB164.28 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 202 GB there. Split across 80 GB GPUs it takes at least 10 at BF16, 5 at 8-bit, 3 at 4-bit (the last row).

GPU memoryBF168-bit4-bit
80 GB709 GBtoo big378 GBtoo big202 GBtoo big
80 GB × n10 cards5 cards3 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.

Every layer keeps a key and a value vector for each of its 8 KV heads, for every token in the context:

2 × L × K × h × 2 bytes = 2 × 92 × 8 × 128 × 2 = 376,832 bytes per token

Grouped-query attention is why this is small: with a KV head for each of the 96 query heads it would be 12 times larger.

ContextKV cache, BF168-bit KVWeights + KV, BF16
4K1.5 GB772 MB707 GB
32K12.3 GB6.2 GB718 GB
128K (max)49.4 GB24.7 GB755 GB

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 92 times (in two kinds).

TensorShapeParameters
Embedding
model.embed_tokens.weight[151,552, 5,120]775,946,240
Dense blocks (layers 0–2): model.layers.N.…
self_attn.q_proj.weight[12,288, 5,120]62,914,560
self_attn.q_proj.bias[12,288]12,288
self_attn.k_proj.weight[1,024, 5,120]5,242,880
self_attn.k_proj.bias[1,024]1,024
self_attn.v_proj.weight[1,024, 5,120]5,242,880
self_attn.v_proj.bias[1,024]1,024
self_attn.o_proj.weight[5,120, 12,288]62,914,560
self_attn.q_norm.weightshared by every head[128]128
self_attn.k_norm.weight[128]128
mlp.gate_proj.weight[12,288, 5,120]62,914,560
mlp.up_proj.weight[12,288, 5,120]62,914,560
mlp.down_proj.weight[5,120, 12,288]62,914,560
input_layernorm.weight[5,120]5,120
post_attention_layernorm.weight[5,120]5,120
MoE blocks (layers 3–91): model.layers.N.…
self_attn.q_proj.weight[12,288, 5,120]62,914,560
self_attn.q_proj.bias[12,288]12,288
self_attn.k_proj.weight[1,024, 5,120]5,242,880
self_attn.k_proj.bias[1,024]1,024
self_attn.v_proj.weight[1,024, 5,120]5,242,880
self_attn.v_proj.bias[1,024]1,024
self_attn.o_proj.weight[5,120, 12,288]62,914,560
self_attn.q_norm.weightshared by every head[128]128
self_attn.k_norm.weight[128]128
mlp.gate.weightthe router: one score per expert[160, 5,120]819,200
mlp.gate.e_score_correction_biasrouting only[160]160
mlp.experts.{0…159}.gate_proj.weight160 × [1,536, 5,120]1,258,291,200
mlp.experts.{0…159}.up_proj.weight160 × [1,536, 5,120]1,258,291,200
mlp.experts.{0…159}.down_proj.weight160 × [5,120, 1,536]1,258,291,200
mlp.shared_experts.gate_proj.weightshared expert: runs for every token[1,536, 5,120]7,864,320
mlp.shared_experts.up_proj.weightshared expert: runs for every token[1,536, 5,120]7,864,320
mlp.shared_experts.down_proj.weightshared expert: runs for every token[5,120, 1,536]7,864,320
input_layernorm.weight[5,120]5,120
post_attention_layernorm.weight[5,120]5,120
After the last block
model.norm.weightfinal norm[5,120]5,120
lm_head.weightscores every token in the vocabulary[151,552, 5,120]775,946,240

The parameter count, step by step

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

V
vocabulary 151,552
d
hidden size 5,120
L
layers 92
H
query heads 96
K
key/value heads 8
h
head size 128
f
FFN hidden size 12,288
E
routed experts 160
k
experts per token 8
f_e
expert FFN size 1,536

1. Embedding

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

Embedding
V × d
151,552 × 5,120
= 775,946,240

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

Attention
H·h × d + H·h + 2 × (K·h × d) + 2 × K·h + d × H·h + 2 × h
12,288 × 5,120 + 12,288 + 2 × (1,024 × 5,120) + 2 × 1,024 + 5,120 × 12,288 + 2 × 128
= 136,329,472
Feed-forward (SwiGLU)
2 × (f × d) + d × f
2 × (12,288 × 5,120) + 5,120 × 12,288
= 188,743,680
Norms
2 × d
2 × 5,120
= 10,240
One block
attention + feed-forward + norms
136,329,472 + 188,743,680 + 10,240
= 325,083,392
3 blocks
3 × block
3 × 325,083,392
= 975,250,176

3. MoE blocks (layers 3–91), ×89

Attention
H·h × d + H·h + 2 × (K·h × d) + 2 × K·h + d × H·h + 2 × h
12,288 × 5,120 + 12,288 + 2 × (1,024 × 5,120) + 2 × 1,024 + 5,120 × 12,288 + 2 × 128
= 136,329,472
Mixture of experts (160 experts, 8 per token)
E × d + E + 2 × (E × (f_e × d)) + E × (d × f_e) + 2 × (f_e × d) + d × f_e
160 × 5,120 + 160 + 2 × (160 × (1,536 × 5,120)) + 160 × (5,120 × 1,536) + 2 × (1,536 × 5,120) + 5,120 × 1,536
= 3,799,285,920
Norms
2 × d
2 × 5,120
= 10,240
One block
attention + mixture of experts + norms
136,329,472 + 3,799,285,920 + 10,240
= 3,935,625,632
89 blocks
89 × block
89 × 3,935,625,632
= 350,270,681,248

4. Final norm and output head

Final norm + head
d + V × d
5,120 + 151,552 × 5,120
= 775,951,360

5. Total

Total
embedding + blocks + final
775,946,240 + 975,250,176 + 350,270,681,248 + 775,951,360
= 352,797,829,024

6. Active parameters per token

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

Active
total − MoE blocks × (E − k) × expert
352,797,829,024 − 89 × 152 × 23,592,960
= 33,632,266,144

7. 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 92): its own pieces
2 × (V × d) + 3 × d + d × 2d
2 × (151,552 × 5,120) + 3 × 5,120 + 5,120 × 10,240
= 1,604,336,640
MTP module 1: a transformer block
one block, as in MoE blocks
3,935,625,632
= 3,935,625,632
In the checkpoint
language model + MTP
352,797,829,024 + 5,539,962,272
= 358,337,791,296

Hugging Face counts 358,337,791,296 parameters in the zai-org/GLM-4.5-Base 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 × 33,632,266,144 = 67.3 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
4K67.3 GFLOPs18.5 GFLOPs85.8 GFLOPs
32K67.3 GFLOPs148.2 GFLOPs215.4 GFLOPs
128K67.3 GFLOPs592.7 GFLOPs660.0 GFLOPs

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-4.5 vs MiniMax M2 · Compare with any model →

Close in size: Qwen3.5 397B-A17B 396B · Llama 4 Maverick (17B-128E) 401B · Llama 3.1 405B 406B · Inkling-Small 264B · Qwen3 235B-A22B 235B

Source

Read from zai-org/GLM-4.5-Base, fetched 2026-12-03. GLM-4.6 and GLM-4.7 keep these shapes.