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).
Part of the GLM-4.5 family: 107B · 353B
Architecture · VRAM · KV cache · Tensor shapes · Parameter count · FLOPs
Architecture
| Architecture | Glm4MoeForCausalLM |
|---|---|
| Layers (L) | 92 |
| Hidden size (d) | 5,120 |
| Attention | GQA (12 query heads share each KV head) |
| Heads | 96 query, 8 key/value, 128 each |
| Feed-forward | 160 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 embeddings | no: separate output head |
| Biases | on q, k and v |
| Extra norms | RMSNorm on q and k (per head) |
| Max context | 131,072 tokens |
| Weights in the release | bfloat16 |
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:
| Precision | Bytes per parameter | Weights | |
|---|---|---|---|
| FP32 | 4 | 1.41 TB | 1314.27 GiB |
| BF16 / FP16 | 2 | 706 GB | 657.14 GiB |
| INT8 / FP8 | 1 | 353 GB | 328.57 GiB |
| INT4 | 0.5 | 176 GB | 164.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.
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 memory | BF16 | 8-bit | 4-bit |
|---|---|---|---|
| 80 GB | 709 GBtoo big | 378 GBtoo big | 202 GBtoo big |
| 80 GB × n | 10 cards | 5 cards | 3 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.
| Context | KV cache, BF16 | 8-bit KV | Weights + KV, BF16 |
|---|---|---|---|
| 4K | 1.5 GB | 772 MB | 707 GB |
| 32K | 12.3 GB | 6.2 GB | 718 GB |
| 128K (max) | 49.4 GB | 24.7 GB | 755 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).
| Tensor | Shape | Parameters |
|---|---|---|
| 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.weight | 160 × [1,536, 5,120] | 1,258,291,200 |
mlp.experts.{0…159}.up_proj.weight | 160 × [1,536, 5,120] | 1,258,291,200 |
mlp.experts.{0…159}.down_proj.weight | 160 × [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.
2. Dense blocks (layers 0–2), ×3
3. MoE blocks (layers 3–91), ×89
4. Final norm and output head
5. Total
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.
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.
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 T | 2N | Attention | Total per token |
|---|---|---|---|
| 4K | 67.3 GFLOPs | 18.5 GFLOPs | 85.8 GFLOPs |
| 32K | 67.3 GFLOPs | 148.2 GFLOPs | 215.4 GFLOPs |
| 128K | 67.3 GFLOPs | 592.7 GFLOPs | 660.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.