gpt-oss · OpenAI

gpt-oss-20b

gpt-oss-20b from OpenAI has 20,914,757,184 parameters, of which about 4.19B are used for each token (a mixture of experts). Its weights take 41.8 GB in BF16 and about 10.5 GB at 4-bit (as released, with MXFP4 experts: 13.8 GB), and each token of context adds 49.2 KB of KV cache (1.6 GB at 32K tokens).

20.9Bparameters
4.19Bactive per token
41.8 GBBF16 weights
10.5 GB4-bit weights
49.2 KBKV per token

Part of the gpt-oss family: 20.9B · 117B

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

Architecture

ArchitectureGptOssForCausalLM
Layers (L)24
Hidden size (d)2,880
AttentionGQA (8 query heads share each KV head); a learned sink per head
Heads64 query, 8 key/value, 64 each
Feed-forward32 experts of 2,880, 4 per token (SwiGLU), with biases
Vocabulary (V)201,088
Tied embeddingsno: separate output head
Biaseson q, k, v and the output projection; on the router and every expert
Extra normspre-norm (RMSNorm before attention and FFN)
Max context131,072 tokens; 12 of 24 layers use a 128-token sliding window
Weights in the releaseMXFP4 experts (4.25 bits a weight), BF16 for the rest

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
FP32483.7 GB77.91 GiB
BF16 / FP16241.8 GB38.96 GiB
INT8 / FP8120.9 GB19.48 GiB
INT40.510.5 GB9.74 GiB
As releasedmixed13.8 GB12.82 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.

How the experts are stored: MXFP4

gpt-oss-20b is released with its expert weights already quantized to MXFP4: each run of 32 weights shares one 8-bit power-of-two scale, and each weight is a 4-bit float, two to a byte. In the files every expert matrix becomes two U8 tensors, e.g. gate_up_proj_blocks [32, 5,760, 90, 16] (16 bytes hold 32 weights) and gate_up_proj_scales [32, 5,760, 90].

The parameter count on this page is the logical one: 19,110,297,600 expert weights, whatever their storage. Stored, they take 19,110,297,600 ÷ 2 = 9,555,148,800 bytes of blocks plus 19,110,297,600 ÷ 32 = 597,196,800 bytes of scales: 4.25 bits a weight, 10.2 GB in all. Attention, the router, the embedding and the head (1,804,459,584 parameters) stay in BF16, 3.6 GB.

3.6 GB + 10.2 GB = 13.8 GB of weights as released

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):

GPU memoryBF168-bit4-bit
8 GB–––
12 GB–––
16 GB––✓
24 GB–✓✓
48 GB✓✓✓
80 GB✓✓✓

KV cache

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 × 24 × 8 × 64 × 2 = 49,152 bytes per token

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

ContextKV cache, BF168-bit KVWith the sliding windowWeights + KV, BF16
4K201 MB101 MB104 MB42.0 GB
32K1.6 GB805 MB808 MB43.4 GB
128K (max)6.4 GB3.2 GB3.2 GB48.3 GB

In the config, 12 of 24 layers use a 128-token sliding window. Runtimes that honour it never cache more than 128 tokens for those layers; the column shows what that saves.

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 24 times.

TensorShapeParameters
Embedding
model.embed_tokens.weight[201,088, 2,880]579,133,440
Every block: model.layers.N.…
self_attn.q_proj.weight[4,096, 2,880]11,796,480
self_attn.q_proj.bias[4,096]4,096
self_attn.k_proj.weight[512, 2,880]1,474,560
self_attn.k_proj.bias[512]512
self_attn.v_proj.weight[512, 2,880]1,474,560
self_attn.v_proj.bias[512]512
self_attn.o_proj.weight[2,880, 4,096]11,796,480
self_attn.o_proj.bias[2,880]2,880
self_attn.sinksone learned "sink" score per head, so a head can attend to nothing[64]64
mlp.router.weightthe router: one score per expert[32, 2,880]92,160
mlp.router.bias[32]32
mlp.experts.gate_up_projstored as MXFP4: _blocks (two 4-bit values per byte) and _scales (one per 32 values)32 × [5,760, 2,880]530,841,600
mlp.experts.gate_up_proj_biasbiases stay in BF1632 × [5,760]184,320
mlp.experts.down_proj32 × [2,880, 2,880]265,420,800
mlp.experts.down_proj_bias32 × [2,880]92,160
input_layernorm.weight[2,880]2,880
post_attention_layernorm.weight[2,880]2,880
After the last block
model.norm.weightfinal norm[2,880]2,880
lm_head.weightscores every token in the vocabulary[201,088, 2,880]579,133,440

The parameter count, step by step

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

V
vocabulary 201,088
d
hidden size 2,880
L
layers 24
H
query heads 64
K
key/value heads 8
h
head size 64
E
routed experts 32
k
experts per token 4
f_e
expert FFN size 2,880

1. Embedding

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

Embedding
V × d
201,088 × 2,880
= 579,133,440

2. Every block, ×24

Attention
H·h × d + H·h + 2 × (K·h × d) + 2 × K·h + d × H·h + d + H
4,096 × 2,880 + 4,096 + 2 × (512 × 2,880) + 2 × 512 + 2,880 × 4,096 + 2,880 + 64
= 26,550,144
Mixture of experts (32 experts, 4 per token)
E × d + E + E × (2f_e × d) + E × (2f_e) + E × (d × f_e) + E × (d)
32 × 2,880 + 32 + 32 × (5,760 × 2,880) + 32 × (5,760) + 32 × (2,880 × 2,880) + 32 × (2,880)
= 796,631,072
Norms
2 × d
2 × 2,880
= 5,760
One block
attention + mixture of experts + norms
26,550,144 + 796,631,072 + 5,760
= 823,186,976
24 blocks
L × block
24 × 823,186,976
= 19,756,487,424

3. Final norm and output head

Final norm + head
d + V × d
2,880 + 201,088 × 2,880
= 579,136,320

4. Total

Total
embedding + blocks + final
579,133,440 + 19,756,487,424 + 579,136,320
= 20,914,757,184

5. Active parameters per token

The router sends each token to 4 of the 32 experts in each MoE block, so only those experts' weights are used. One routed expert is 24,891,840 parameters.

Active
total − MoE blocks × (E − k) × expert
20,914,757,184 − 24 × 28 × 24,891,840
= 4,187,440,704

OpenAI's model card gives 3.61B active: the same count without the 579M embedding table, which is a lookup rather than a multiply.

Hugging Face counts 20,914,757,184 parameters in the openai/gpt-oss-20b safetensors files (it counts the MXFP4 experts as logical weights, two per stored byte, and leaves the scales out). 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 × 4,187,440,704 = 8.4 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. Layers with a window see at most 128 tokens, which the table allows for.

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
4K8.4 GFLOPs830.5 MFLOPs9.2 GFLOPs
32K8.4 GFLOPs6.5 GFLOPs14.8 GFLOPs
128K8.4 GFLOPs25.8 GFLOPs34.2 GFLOPs

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

Compare

gpt-oss-20b vs Qwen3 30B-A3B · Compare with any model →

Close in size: Mistral Small 3 (24B) 23.6B · Gemma 3 27B 27B · Gemma 2 27B 27.2B · DeepSeek-V2-Lite 15.7B · Qwen2.5 14B 14.8B

Source

Read from openai/gpt-oss-20b, fetched 2026-12-02.