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).
Part of the gpt-oss family: 20.9B · 117B
Architecture · VRAM · KV cache · Tensor shapes · Parameter count · FLOPs
Architecture
| Architecture | GptOssForCausalLM |
|---|---|
| Layers (L) | 24 |
| Hidden size (d) | 2,880 |
| Attention | GQA (8 query heads share each KV head); a learned sink per head |
| Heads | 64 query, 8 key/value, 64 each |
| Feed-forward | 32 experts of 2,880, 4 per token (SwiGLU), with biases |
| Vocabulary (V) | 201,088 |
| Tied embeddings | no: separate output head |
| Biases | on q, k, v and the output projection; on the router and every expert |
| Extra norms | pre-norm (RMSNorm before attention and FFN) |
| Max context | 131,072 tokens; 12 of 24 layers use a 128-token sliding window |
| Weights in the release | MXFP4 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:
| Precision | Bytes per parameter | Weights | |
|---|---|---|---|
| FP32 | 4 | 83.7 GB | 77.91 GiB |
| BF16 / FP16 | 2 | 41.8 GB | 38.96 GiB |
| INT8 / FP8 | 1 | 20.9 GB | 19.48 GiB |
| INT4 | 0.5 | 10.5 GB | 9.74 GiB |
| As released | mixed | 13.8 GB | 12.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
On common GPUs
Whether the weights plus a 8K-token KV cache fit in 90% of the card (how this is worked out):
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.
| Context | KV cache, BF16 | 8-bit KV | With the sliding window | Weights + KV, BF16 |
|---|---|---|---|---|
| 4K | 201 MB | 101 MB | 104 MB | 42.0 GB |
| 32K | 1.6 GB | 805 MB | 808 MB | 43.4 GB |
| 128K (max) | 6.4 GB | 3.2 GB | 3.2 GB | 48.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.
| Tensor | Shape | Parameters |
|---|---|---|
| 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 BF16 | 32 × [5,760] | 184,320 |
mlp.experts.down_proj | 32 × [2,880, 2,880] | 265,420,800 |
mlp.experts.down_proj_bias | 32 × [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.
2. Every block, ×24
3. Final norm and output head
4. Total
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.
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 T | 2N | Attention | Total per token |
|---|---|---|---|
| 4K | 8.4 GFLOPs | 830.5 MFLOPs | 9.2 GFLOPs |
| 32K | 8.4 GFLOPs | 6.5 GFLOPs | 14.8 GFLOPs |
| 128K | 8.4 GFLOPs | 25.8 GFLOPs | 34.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.