gpt-oss Architecture Explained: MoE, Attention Sinks and MXFP4
By LatestLLM Editorial · Published · Specs verified · 34 min read · License: Apache 2.0
gpt-oss is OpenAI's family of open-weight, text-only reasoning models, released under the Apache 2.0 license in two sizes: gpt-oss-120b (116.83B parameters, 5.13B active per token) and gpt-oss-20b (20.91B parameters, 3.61B active). Both are mixture-of-experts transformers that keep inference cheap in four ways: attention alternates between a 128-token window and full attention, every head has a learned attention sink, each token is sent to only 4 experts, and the expert weights are stored in a 4-bit format so that the 120B model fits on a single 80 GB GPU.
Key takeaways
- gpt-oss is a text-only, decoder-only mixture-of-experts transformer in two sizes: gpt-oss-120b (36 layers, 116.83B total and 5.13B active parameters) and gpt-oss-20b (24 layers, 20.91B total and 3.61B active).
- Attention layers alternate between a sliding window of 128 tokens and fully dense attention. Every layer uses grouped-query attention with 64 query heads and only 8 key/value heads of size 64, and every head has a learned attention sink.
- Each mixture-of-experts layer has 128 experts (120B) or 32 experts (20B). A router picks the top 4 for every token and weights them with a softmax over only those 4. No shared expert is used.
- The expert weights are 98.2% of the 120B model and 91.4% of the 20B model. They were post-trained in MXFP4 at 4.25 bits per weight, giving checkpoints of 60.8 GiB and 12.8 GiB, small enough for one 80 GB GPU and a 16 GB machine.
- Normalisation is plain pre-norm RMSNorm. Position information uses RoPE with a base of 150,000, stretched by YaRN from 4,096 to 131,072 tokens of context.
- The numbers on this page come from OpenAI's model card, each model's published config.json and OpenAI's reference implementation.
gpt-oss variants
| Size | Type | Parameters | Layers | Attention mix | Context | Inputs |
|---|---|---|---|---|---|---|
| gpt-oss-120b | Mixture-of-experts (4 of 128 experts, MXFP4 weights, Fits one 80 GB GPU) | 116.83B total · 5.13B active | 36 | 18 local · 18 global (1:1) | 128K tokens | text |
| gpt-oss-20b | Mixture-of-experts (4 of 32 experts, MXFP4 weights, Runs in 16 GB) | 20.91B total · 3.61B active | 24 | 12 local · 12 global (1:1) | 128K tokens | text |
Inside one transformer block
Tokens: text cut into pieces
A model cannot read letters the way you do. Your text is first chopped into small pieces called tokens, and every piece gets a number from a fixed list. gpt-oss's list has 201,088 entries.
Think of it like this: Like turning a sentence into LEGO bricks. Every brick shape has a catalogue number, and the model only ever sees the numbers.
Embedding: numbers that describe meaning
Each token number is looked up in a big table and replaced by a list of 2,880 numbers that describe what the token means. Similar meanings get similar lists.
Think of it like this: Like giving every word a GPS coordinate on a map of meaning. “Cat” and “kitten” land close together; “cat” and “tax” land far apart.
Transformer block × 36
The same two-step recipe is repeated 36 times: first attention, where words look at other words, then a mixture-of-experts step, where each word is processed on its own by a few specialists. Each repeat passes its result to the next.
Think of it like this: A document handed through 36 editors in a row. Every editor adds margin notes but keeps what is already written.
RMSNorm: keeping numbers steady
Normalisation rescales the numbers so they stay at a steady size, which keeps training stable. gpt-oss applies it once before attention and once before the mixture-of-experts step, and nowhere else inside a layer.
Think of it like this: Like an audio compressor on the way into each room. Whatever the volume arriving, the level entering stays in a comfortable range.
Grouped-query attention: windowed and dense
Attention lets every word look at other words to work out its meaning in context, such as what “it” refers to. gpt-oss alternates two kinds of layer: layers that only look at the nearest 128 tokens, and layers that look at everything. Every head also has a built-in way to attend to nothing.
Think of it like this: One pass of proofreading checks each sentence against its neighbours; the next pass checks it against the whole report. Alternating the two keeps long documents affordable.
Residual add: keep what was there
Each step adds its result to what was already there instead of replacing it, so earlier information is never lost.
Think of it like this: Highlighting a textbook instead of rewriting it. The original text stays and your notes pile on top.
Mixture-of-experts: a team of specialists
Instead of one big feed-forward network there are 128 smaller ones, called experts. A router picks the best 4 for each token, so only a slice of the model works on each word. There is no shared expert that every token must use.
Think of it like this: A hospital with 128 specialists. A triage nurse, the router, sends each patient to 4 of them, never to all 128.
Output head: scoring every possible next word
After the last layer, one more normalisation and a final step turn each vector into a score for every one of the 201,088 possible next tokens. The highest scores are the model's guesses.
Think of it like this: A game-show buzzer round: all 201,088 words ring in with a score, and the loudest ones win.
The big picture: how gpt-oss is built
In simple words: gpt-oss reads text as a long list of numbers, passes it through a tall stack of layers, and at the end scores every possible next word. Each layer has two jobs: attention, where words look at each other, and a mixture-of-experts step, where each word is handled by a few specialists.
Think of it like this: Picture a relay race with 36 runners (in the 120B model). Each runner receives the baton, which is the numbers for your text, adds a little something and hands it on. Nobody drops the baton; they only add to it.
gpt-oss is a family of two open-weight reasoning models from OpenAI, released on August 5, 2025 under the Apache 2.0 license and OpenAI's gpt-oss usage policy. The model card describes both as autoregressive mixture-of-experts transformers that build on the GPT-2 and GPT-3 architectures. Text is split into tokens, each token becomes a vector from an embedding table, and that vector travels upward through a stack of 36 transformer blocks (24 in the smaller model). An output layer then scores every token in the vocabulary, and the highest-scoring tokens become the model's prediction for what comes next.
What is distinctive is how familiar parts are combined to keep a large model cheap to run. Attention alternates between a narrow 128-token window and a full look at the whole text, every attention head has a learned way to pay attention to nothing, and almost all of the parameters sit in feed-forward experts, of which only four run for each token. Those experts are stored in a 4-bit format, which is why the 117B-parameter model fits on a single 80 GB GPU. The sections below take these choices one at a time.
There are two sizes. gpt-oss-120b has 116.83B parameters in total and 5.13B active per token; gpt-oss-20b has 20.91B in total and 3.61B active. Both are text-only and share the same width (2,880), the same attention layout and the same 4 experts per token. They differ in depth, 36 layers against 24, and in the number of experts per layer, 128 against 32. Switch sizes in the diagram to watch the same design scale up or down.
Go deeper: details for practitioners
- The model card counts parameters by component. For gpt-oss-120b: 114.71B in the mixture-of-experts blocks, 0.96B in attention and 1.16B in the embedding and unembedding tables. For gpt-oss-20b: 19.12B, 0.64B and 1.16B.
- The model card counts the unembedding matrix as active but not the embedding table, which matches how they are used: one row of the embedding table is looked up per token, while the output matrix is multiplied with every vector.
- According to the model card, pretraining used a text-only dataset of trillions of tokens with a focus on STEM, coding and general knowledge, and the knowledge cutoff is June 2024. The 120B run took 2.1 million H100-hours, and the 20B almost 10 times fewer.
- After pretraining, the models were post-trained with chain-of-thought reinforcement learning similar to OpenAI o3, which is how they learned to reason and to use tools.
- In the diagram, data flows from bottom to top, the way it flows through the model.
What is a decoder-only transformer?
A model that reads a sequence of tokens and predicts the next one, using attention only over the tokens that came before. It is the design behind most chat models.
What does “active parameters” mean?
In a mixture-of-experts model only some of the weights do work for any one token. The active parameters are the ones that do: 5.13B of gpt-oss-120b's 116.83B.
What does open-weight mean?
The trained numbers (the weights) can be downloaded and run on your own hardware. It does not by itself mean that the training data or training code were released.
Tokens and embeddings: turning text into numbers
In simple words: A language model works on numbers, not letters. gpt-oss first cuts text into tokens from a list of 201,088 entries, then looks each token up in a table that gives it 2,880 numbers describing its meaning.
Think of it like this: It is like a dictionary where every entry is a coordinate on a map of meaning instead of a definition. Words that mean similar things sit near each other.
gpt-oss uses the o200k_harmony tokenizer, a byte-pair-encoding tokenizer that OpenAI open-sourced in its TikToken library. It extends the o200k tokenizer used by models such as GPT-4o and o4-mini with extra tokens for the harmony chat format, and it has 201,088 tokens in total, according to the model card.
Each token ID selects one row of the embedding table. In both sizes the table has 201,088 rows of 2,880 numbers, about 0.58 billion parameters. Unlike Gemma 4, gpt-oss does not tie its embeddings: the output layer has its own matrix of the same shape. That is why the model card lists 1.16B embedding and unembedding parameters in both models.
Because the tables are the same size in both models, they matter very differently. They are about 5.5% of gpt-oss-20b but only about 1.0% of gpt-oss-120b.
Go deeper: details for practitioners
- The configuration lists vocab_size as 201,088 and tie_word_embeddings as false.
- The 4-bit quantisation does not touch these tables. The configuration excludes the attention layers, the router, the embedding table and the output layer from conversion, so they stay in a higher-precision format.
- A large vocabulary generally means common words and non-English text need fewer tokens, which means shorter sequences and a smaller KV cache.
What is a vocabulary?
The fixed list of pieces (tokens) the model can read and write. Every piece has a number; the model never sees raw letters.
What are untied embeddings?
Models can reuse the input embedding table, flipped, as their output layer to save memory. gpt-oss keeps two separate matrices instead.
Alternating attention: a 128-token window, then a full look
In simple words: Every other layer in gpt-oss looks only at the last 128 tokens. The layers in between look at the whole text. That keeps long conversations affordable while still letting the model connect facts that are far apart.
Think of it like this: When you proofread a long report, one pass checks each sentence against the few sentences around it, and the next pass checks it against the entire report. Alternating the two keeps the job manageable.
Standard self-attention lets every token look at every earlier token. That is powerful but expensive: both the work and the cached memory grow with the length of the text. The model card says gpt-oss attention blocks alternate between banded window and fully dense patterns, following GPT-3, and that the bandwidth is 128 tokens.
The published layer list starts with a sliding-window layer, then a dense layer, and repeats. The 120B model's 36 layers are therefore 18 sliding-window and 18 dense layers, and the 20B model's 24 layers are 12 and 12. That is a 1:1 mix, with far more full-attention layers than Gemma 4's 5:1, but a much shorter window: 128 tokens against Gemma's 1,024.
The payoff is memory. A sliding-window layer never needs to remember more than 128 tokens however long the conversation grows. Only the dense layers keep a cache that grows with the whole text. Under the assumptions of the compare tool below, gpt-oss-120b needs about 4.84 GB of KV cache at 131,072 tokens, against about 9.66 GB if all 36 layers were dense.
Information can still travel far. Whatever a dense layer gathers from the distant text is passed up through the later layers, including the sliding-window ones, so the model can connect distant parts of a document.
Go deeper: details for practitioners
- The configuration sets sliding_window to 128 and lists layer_types as alternating sliding_attention and full_attention, starting with sliding_attention. OpenAI's reference implementation applies the window to the layers with an even zero-based index.
- A 128-token window is much narrower than Gemma 4's 1,024 (512 on its small models). A narrow window makes each sliding-window layer very cheap, but each one sees only a short stretch of text, so reaching further relies on the dense layers and on stacking layers.
- The memory estimate assumes a bfloat16 cache and that sliding-window layers keep only their window. Real inference engines can differ in how they trim and page the cache.
What is sliding-window attention?
Each token attends only to the previous N tokens (the window) instead of to the whole text. The window slides forward as the text grows.
What does dense attention mean?
Every token can look at every earlier token. It is the standard form of attention and the most expensive for long texts.
What does a 1:1 mix mean?
Out of every two layers, one uses a sliding window and one is dense.
Grouped-query attention and the KV cache
In simple words: While writing, the model keeps notes on every earlier token. gpt-oss keeps them small: 64 query heads share only 8 sets of notes, so each token costs very little memory.
Think of it like this: Imagine a library where many readers share a few copies of each book instead of every reader owning their own. Everyone can still read; the shelves stay small.
During generation the model caches the keys and values of every token it has already processed, so it does not recompute them. This KV cache grows with the length of the text and, for long contexts, becomes a large user of memory.
Grouped-query attention (GQA) shares each set of keys and values across several query heads. Both gpt-oss models use 64 query heads with a head size of 64 and only 8 key/value heads, so 8 query heads read from every key/value head. Every layer uses the same layout. Unlike the larger Gemma 4 models, there is no separate setting for the dense layers, and both keys and values are stored on every layer.
That makes the cost easy to compute. One token on one layer needs 8 heads × 64 numbers × 2 (keys and values) × 2 bytes, which is 2,048 bytes in bfloat16. A dense layer holding 131,072 tokens therefore needs about 268 MB, while a sliding-window layer never needs more than about 262 KB.
Under the compare tool's assumptions, a single sequence needs about 0.31 GB of KV cache at 8K tokens, 1.21 GB at 32K and 4.84 GB at 128K on gpt-oss-120b. On gpt-oss-20b, which has only 12 dense layers, the figures are 0.20 GB, 0.81 GB and 3.22 GB. These are calculated from the published configs, not measured.
Go deeper: details for practitioners
- Estimate used by the compare tool: sliding-window layers cache min(context, 128) × 2 × 8 × 64 × 2 bytes per layer, and dense layers cache context × 2 × 8 × 64 × 2 bytes per layer.
- The configuration lists attention_bias as true, so the query, key, value and output projections carry bias terms. In OpenAI's reference implementation the three input projections are fused into a single linear layer.
- Attention scores are scaled by one over the square root of the head size, 64, as in a standard transformer.
What are keys and values?
For every token the model computes a key (what this token is about) and a value (the information it carries). Attention compares a query with all keys and blends the matching values.
Why does the KV cache matter?
It decides how much memory a long conversation needs on top of the model weights, and so how long a context fits on your hardware.
Attention sinks: a way to pay attention to nothing
In simple words: Every attention head in gpt-oss has a built-in “attend to nothing” slot. When no earlier word is useful, the head can park its attention there instead of forcing it onto a real word.
Think of it like this: A multiple-choice exam that includes “none of the above”. Without that option you must circle a letter even when none of them fits.
Softmax attention turns scores into weights that always add up to 1, so a head has to hand out all of its attention even when nothing in the text is relevant. Models often cope by dumping the surplus on the first token, which then works as an unintended sink.
The model card says each attention head has a learned bias in the denominator of the softmax, similar to off-by-one attention and attention sinks, which lets the attention mechanism pay no attention to any tokens. In effect each head computes weight for token i = exp(score i) divided by (exp(sink) + the sum of exp(score j) over all visible tokens). The sink is one learned number per head that belongs to no token. When every score is low, the weights on real tokens shrink toward zero instead of being rescaled to 1.
OpenAI's reference implementation does exactly this: it appends the sink as an extra column before the softmax and drops that column afterwards, so no value is attached to it. Each of the 64 query heads in a layer has its own sink.
Sinks are also a natural fit for sliding windows. Research on streaming attention (Xiao et al., 2023) found that models park surplus attention on the first tokens of a text, and a window that slides past them breaks that habit. A learned sink gives the surplus a place to go that never leaves the window. The model card does not spell out this motivation, so treat it as a plausible explanation.
Go deeper: details for practitioners
- The sink costs almost nothing: one number per head per layer, which for 64 heads is 64 numbers per layer.
- In the figure the five scores and the sink value are made up. Their only purpose is to show how a sink changes the shape of the softmax.
- Because nothing is attached to the sink, the attention output is a weighted sum of real values only, and it gets smaller when more weight goes to the sink.
What is a softmax?
A function that turns a list of scores into positive weights that add up to 1. Bigger scores get bigger weights.
What is off-by-one attention?
A softmax with an extra 1 added to the denominator, which lets a head output nearly nothing when all its scores are very low. gpt-oss uses a learned version of the same idea.
Position information: RoPE and YaRN
In simple words: Attention needs to know which word came first. gpt-oss encodes position by rotating vectors, and stretches that scheme with YaRN so the model can handle 131,072 tokens.
Think of it like this: Give every token a set of clock hands. The angle between two tokens' hands tells attention how far apart they are. YaRN re-spaces the slowest hands so a clock built for 4,096 hours can keep track of 131,072.
Rotary position embedding (RoPE) encodes where a token sits by rotating its query and key vectors by an angle that grows with position. Because attention compares queries with keys, the comparison naturally depends on how far apart two tokens are. The configuration sets the base frequency, rope_theta, to 150,000.
A position scheme only works well up to the lengths it saw in training, and the configuration records an initial context length of 4,096 tokens. To reach 131,072, which is 32 times as many, gpt-oss uses YaRN, which rescales the rotation frequencies. The model card says the context length of the dense layers is extended with YaRN. The configuration lists a scaling factor of 32.
Sliding-window layers only ever compare tokens within 128 positions of each other, far inside the range the model was trained on. The model card names the dense layers as the ones that are extended; OpenAI's reference implementation builds the same rotary embedding, with the same scaling, for every layer.
Go deeper: details for practitioners
- The configuration lists rope_scaling with type yarn, factor 32, beta_fast 32, beta_slow 1 and original_max_position_embeddings 4,096. 4,096 × 32 equals the 131,072 token maximum.
- In general, YaRN leaves the fast-turning rotations alone, stretches the slowest ones, and blends the two in between. The beta values set where those boundaries lie.
- Gemma 4 takes another route to long context: it rotates only a quarter of the frequency pairs on its global layers (p-RoPE). The Gemma 4 guide covers that scheme.
What is RoPE?
Rotary position embedding. It tells attention how far apart two tokens are by rotating their vectors by an angle that depends on position.
What is YaRN?
A method for stretching a RoPE-based model to a much longer context than it was trained on, by rescaling the rotation frequencies in a careful way.
Normalisation: plain pre-norm RMSNorm
In simple words: gpt-oss normalises the numbers once before each attention block and once before each mixture-of-experts block, and nowhere else inside a layer. It is the simplest common layout, and the opposite of Gemma 4's sandwich.
Think of it like this: It is like adjusting the volume as a signal enters each room of a house, but not again when it leaves.
The model card says both models apply root mean square normalisation to the activations before each attention and mixture-of-experts block, and that they use Pre-LN placement, as GPT-2 did. RMSNorm rescales a vector by its root-mean-square. It is a simpler cousin of LayerNorm that skips mean-centering and is cheaper to compute.
That makes two norms per layer. Gemma 4 uses four per layer, before and after each block, and also normalises queries and keys. The gpt-oss model card and configuration describe neither of those extras.
One more RMSNorm sits after the last layer, before the output head. The configuration sets the epsilon of every RMSNorm to 1e-5.
Go deeper: details for practitioners
- In OpenAI's reference implementation each block computes its output from a normalised copy of its input and then adds that to the un-normalised input, which is what pre-norm with a residual connection means.
- Pre-norm is easy to train at depth because the residual stream is never rescaled, which is one reason it is the most common layout.
Pre-norm vs post-norm?
Pre-norm normalises the input of a sub-layer; post-norm normalises its output. gpt-oss uses pre-norm only.
Normalization and residual connections explained simply and technically
What is the residual stream?
The running list of numbers that every layer reads from and adds to. It is the baton in the relay race.
Normalization and residual connections explained simply and technically
Mixture-of-experts: 128 experts, four per token
In simple words: Each gpt-oss layer replaces one big feed-forward network with many smaller experts. A router sends every token to only 4 of them, so only a slice of the model does any work for each word.
Think of it like this: A hospital with 128 specialists. A triage nurse, the router, sends each patient to the 4 who fit best, never to all 128.
After attention gathers context, a feed-forward network processes each token on its own. In gpt-oss that network is a mixture of experts: 128 experts per layer in gpt-oss-120b and 32 in gpt-oss-20b, plus a router. The model card describes the router as a standard linear projection that maps the residual activations to one score per expert. The top 4 experts are selected for each token, and each expert's output is weighted by a softmax over only those 4 scores.
There is no shared expert. OpenAI's reference implementation simply adds up the weighted outputs of the four chosen experts and adds the result to the residual stream. Gemma 4's 26B model, by contrast, always runs one shared expert next to its routed ones.
Each expert is a gated feed-forward network with the SwiGLU activation: the 2,880 input numbers go through two parallel projections of 2,880 numbers each, a gate and a linear one, which are combined and projected back to 2,880. Both steps have bias terms. The model card notes that the SwiGLU is unconventional because it includes clamping and a residual connection. The reference code clamps the gate input at 7, clamps the linear input between -7 and 7, and multiplies the gate by the linear input plus 1, so the output keeps a built-in skip path.
The trade-off is compute against memory. Per token, gpt-oss-120b does the work of a model with about 5.1B parameters, so it generates quickly. But any token can be routed to any expert, so all 116.83B parameters must be loaded. Mixture-of-experts saves compute, not memory. The experts make up 114.71B of those parameters, which is why the next section matters.
Go deeper: details for practitioners
- Table 1 of the model card counts 114.71B parameters in the mixture-of-experts blocks of the 120B model and 19.12B in the 20B model, which is 98.2% and 91.4% of the totals.
- The 20B model keeps the same 4 experts per token but has only 32 experts to choose from, so 12.5% of its experts run per token, against 3.1% on the 120B.
- The configuration lists router_aux_loss_coef as 0.9 and output_router_logits as false. Neither the model card nor the configuration says whether a load-balancing loss was used in training, so this page makes no claim about it.
- Gemma 4's 26B-A4B uses 128 smaller experts (width 704), routes each token to 8 and adds a shared expert. gpt-oss uses 128 wider experts (width 2,880) and routes to 4.
What is a router?
A small network that scores every expert for the current token and picks the top few. Different tokens usually go to different experts.
What is SwiGLU?
A gated activation. Two parallel projections are computed; one passes through a smooth gate that decides, number by number, how much of the other to let through. gpt-oss also clamps the values to keep them in a safe range.
Do I need all the experts in memory?
Yes. Only 4 run per token, but any expert can be chosen, so all of the weights should be loaded to run at full speed.
MXFP4: how 117 billion parameters fit on one GPU
In simple words: Almost all of gpt-oss is expert weights, and those were trained to work in a 4-bit format. That shrinks the 120B model from about 218 GiB to 60.8 GiB, and the 20B model to 12.8 GiB.
Think of it like this: Instead of writing every number with sixteen digits, you write four digits and share one note on the scale with the thirty-one neighbours beside it.
Memory is the main cost of a mixture-of-experts model, because every expert has to be loaded. OpenAI post-trained the models with the expert weights quantised to the MXFP4 format, in which the model card says weights take 4.25 bits each. The expert weights are more than 90% of all parameters, so shrinking them is what lets the larger model fit on a single 80 GB GPU and the smaller one run in 16 GB of memory.
The 4.25 comes from sharing. In a microscaling format, a block of 32 weights each stores 4 bits and shares one 8-bit scale. That is (32 × 4 + 8) / 32 = 4.25 bits per weight. The scale lets 4-bit numbers cover very different ranges in different blocks.
Only the experts are quantised. The configuration excludes the attention layers, the router, the embedding table and the output layer, which stay in a higher-precision format. The published sizes fit this picture: the 120B model's experts at 4.25 bits come to about 56.8 GiB and its other 2.1B parameters at 16 bits to about 4 GiB, close to the 60.8 GiB checkpoint. For the 20B model the same sum gives about 12.8 GiB, which matches the published size.
OpenAI says all of its evaluations were run with the same MXFP4 quantisation, so the released form is the one the reported results describe.
Go deeper: details for practitioners
- Plain 16-bit weights would need about 217.6 GiB for the 120B model (116.83B × 2 bytes) and about 39 GiB for the 20B, so MXFP4 cuts the checkpoint by about 3.6 times and 3.0 times.
- The estimate in the figure leaves out small tensors such as biases and norm weights, which is why it is slightly below the published 120B checkpoint size.
- The “higher precision” of the non-expert weights is not named in the model card. The sizes above work out if it is 16 bits, and OpenAI's reference implementation stores those layers in bfloat16.
- The microscaling formats are defined by the Open Compute Project and described in the paper Microscaling Data Formats for Deep Learning, which the model card cites.
What is quantisation?
Storing each weight with fewer bits so the model takes less memory, at the cost of some precision.
What is a shared scale?
One extra number stored for a whole block of weights. Each weight is read as its small 4-bit value multiplied by that scale.
The output head
In simple words: At the top of the stack, gpt-oss turns each vector into a score for every possible next token and picks from the highest scores. Unlike Gemma 4 it does not limit how large a score can get.
Think of it like this: A buzzer round on a game show: every one of the 201,088 possible words rings in with a score, and the loudest ones win.
After the final block, one more RMSNorm is applied and the result is multiplied by the output matrix to produce one score, called a logit, per token in the vocabulary. Those scores become probabilities, and the model samples or picks the next token.
The output matrix is a separate set of weights from the embedding table, and it has no bias. The configuration lists no logit soft-capping, so the scores are used as they come.
Go deeper: details for practitioners
- In the reference implementation the output matrix is a bias-free linear layer called unembedding. Its 0.58B parameters count toward the active parameters because every token multiplies through it.
- Both models are sampled with the usual temperature and softmax over the scores.
What is a logit?
The raw score a model assigns to a token before it is turned into a probability.
Harmony format and reasoning effort: what the architecture does not show
In simple words: Two things that shape how gpt-oss behaves are not part of its layer design at all: a chat format called harmony, and a setting that decides how long the model thinks before answering.
Think of it like this: The architecture is the engine; harmony is the gearbox protocol and reasoning effort is the gas pedal.
Both models were trained on OpenAI's harmony chat format and, according to the model card on Hugging Face, should only be used with it, because they will not work correctly otherwise. The format uses special tokens to mark message boundaries and gives every message an author role. When instructions conflict, the models follow a hierarchy: System, then Developer, then User, then Assistant, then Tool.
Harmony also adds channels that say who may see a message: analysis for the model's chain of thought, commentary for tool calls, and final for the answer shown to users. The model card says the reasoning traces from past assistant turns should be removed in multi-turn conversations, and the chain of thought is not intended to be shown to end users.
Reasoning effort has three levels, low, medium and high, set in the system prompt with a keyword such as “Reasoning: low”. Raising the level makes the average chain of thought longer. The model card reports that gpt-oss-20b uses over 20,000 chain-of-thought tokens per problem on average on AIME, and that accuracy rises smoothly as effort increases. Longer thinking means more tokens to generate, so cost and latency rise with it.
Go deeper: details for practitioners
- The models were also trained to use a browsing tool, a Python tool and developer-defined functions, which can be interleaved with the chain of thought.
- OpenAI's open-source harmony package and reference harnesses show the proper usage. Serving stacks that translate harmony into another chat format can change behaviour, so check that yours follows the format.
- None of this changes the parameter counts or the layer layout above.
What is a chat template?
The exact text layout, with special marker tokens, that a model was trained on for conversations. Using a different layout can make a model behave worse.
What is chain of thought?
The step-by-step reasoning a model writes before its final answer. In gpt-oss it goes into the analysis channel.
gpt-oss next to Gemma 4
In simple words: Both families are open-weight transformers that save memory with local attention and mixture-of-experts, but they make almost opposite choices about windows, normalisation, experts and number formats.
Think of it like this: Two efficient delivery companies: one adds many short local routes with a few long hauls, the other alternates evenly, and each packs its boxes differently.
Attention: gpt-oss alternates windows and dense layers 1:1 with a 128-token window. Gemma 4's larger models use five local layers for every global one with a 1,024-token window. Gemma 4 gives its global layers fewer KV heads and larger heads and reuses keys as values; gpt-oss keeps the same 8 key/value heads of size 64 everywhere, and adds attention sinks.
Normalisation and position: gpt-oss uses pre-norm RMSNorm only, with RoPE at a base of 150,000 stretched by YaRN. Gemma 4 normalises before and after each block, normalises queries and keys, and applies p-RoPE on its global layers.
Experts: both have a 128-expert model. gpt-oss routes each token to 4 experts of width 2,880 and has no shared expert. Gemma 4's 26B-A4B routes to 8 experts of width 704 and adds one shared expert. gpt-oss has no dense variants, while Gemma 4 mixes dense and mixture-of-experts sizes.
Number format: gpt-oss was post-trained with its expert weights in MXFP4, so the released checkpoint is already 4-bit for the experts. Memory follows: with the same estimate, a single 128K-token sequence needs about 4.84 GB of KV cache on gpt-oss-120b, against about 6.21 GB on the smaller Gemma 4 31B. Small 64-number heads and a 128-token window keep the cache of the larger model low.
Neither guide ranks quality. Training data and methods matter as much as layout, which is why this page sticks to what the models are built from.
Go deeper: details for practitioners
- Every Gemma 4 size accepts images and several accept audio; gpt-oss is text-only.
- Sebastian Raschka's article From GPT-2 to gpt-oss compares the gpt-oss layout with GPT-2 and with other open models, and is a useful side-by-side read.
Why compare architectures if training matters more?
Architecture decides memory use, speed and how long a context fits. Those are the things you can plan around before you ever run the model.
Which size should you pick?
In simple words: Start from your memory budget. The 120B is the stronger model and fits on one 80 GB GPU; the 20B runs in 16 GB and is the one for laptops and local experiments.
Think of it like this: Choosing a size is like choosing a vehicle: the 120B is a delivery truck that needs a proper garage, and the 20B is a van that fits almost anywhere.
gpt-oss-120b is the larger model, aimed at general-purpose, high-reasoning use. Its 60.8 GiB checkpoint is about 65 GB, which leaves headroom on an 80 GB GPU for roughly 5 GB of KV cache at the full 128K context, before activations and runtime overhead. The model card says it fits on a single 80 GB GPU, such as an NVIDIA H100 or AMD MI300X.
gpt-oss-20b has a 12.8 GiB checkpoint and, according to the model card, runs on systems with as little as 16 GB of memory. It has the same layout with fewer, shallower layers and only 32 experts, and it is the better fit for lower latency and local or specialised use. Its KV cache at 128K is about 3.2 GB.
Both models have the same 128K context and the same text-only inputs, so choose on memory and on how much reasoning quality you need. Use the compare tool for the full spec table, and check each model's page in the LatestLLM catalog for pricing, benchmarks and hosting options.
Go deeper: details for practitioners
- Real memory use also depends on the runtime, batch size and how it pages the cache, so treat these figures as lower bounds for planning.
- If you run the models through a different serving stack, confirm that it supports MXFP4 and the harmony format, because the model card describes both as part of the intended setup.
Do the sizes share any weights?
No. They are separate models trained from scratch with the same overall design, not one model cut down.
gpt-oss variants compared
| Spec | gpt-oss-120b | gpt-oss-20b |
|---|---|---|
| Parameters | 116.83B total · 5.13B active | 20.91B total · 3.61B active |
| Layers | 36 | 24 |
| Hidden size | 2,880 | 2,880 |
| Normalisation | before each block (pre-norm) | before each block (pre-norm) |
| Query heads | 64 | 64 |
| KV heads (local layers) | 8 | 8 |
| KV heads (global layers) | 8 | 8 |
| Sliding window | 128 tokens | 128 tokens |
| Layer mix | 18 local + 18 global | 12 local + 12 global |
| Attention sinks | yes | yes |
| Type | Mixture-of-experts | Mixture-of-experts |
| Activation | SwiGLU (clamped) | SwiGLU (clamped) |
| Experts (active / total) | 4 / 128 | 4 / 32 |
| Expert size | 2,880 | 2,880 |
| Max context | 131,072 tokens | 131,072 tokens |
| Position encoding | RoPE, base 150,000 + YaRN ×32 (4,096 to 131,072) | RoPE, base 150,000 + YaRN ×32 (4,096 to 131,072) |
| Weight precision | MXFP4 expert weights, higher precision elsewhere | MXFP4 expert weights, higher precision elsewhere |
| Published checkpoint size | 60.8 GiB | 12.8 GiB |
| Tied embeddings | no | no |
| Input types | text | text |
| Vocabulary | 201,088 | 201,088 |
Frequently asked questions
Is gpt-oss a transformer model?
Yes. gpt-oss models are autoregressive mixture-of-experts transformers that build on the GPT-2 and GPT-3 architectures, according to OpenAI's model card. Each layer has an attention block and a mixture-of-experts feed-forward block.
Is gpt-oss a mixture-of-experts model?
Yes. gpt-oss-120b has 128 experts per layer and gpt-oss-20b has 32. A router picks the top 4 experts for each token and weights them with a softmax over only those 4. There is no shared expert.
How many parameters does gpt-oss activate per token?
gpt-oss-120b has 116.83B parameters in total and activates 5.13B per token. gpt-oss-20b has 20.91B in total and activates 3.61B. The model card counts the unembedding matrix as active but not the embedding table.
What is sliding-window attention in gpt-oss?
Every other layer attends only to the previous 128 tokens. The layers in between are dense and attend to the whole context. The 120B model has 18 of each and the 20B model has 12 of each.
What are attention sinks in gpt-oss?
Every attention head has a learned extra term in the denominator of its softmax. It lets the head give little or no attention to any real token when none is relevant, instead of forcing its weights to add up to 1 across the tokens.
How long is gpt-oss's context window?
Both models support 131,072 tokens (128K). They use RoPE with a base of 150,000 and extend the dense layers from 4,096 to 131,072 tokens with YaRN, using a scaling factor of 32.
What is MXFP4 and why does gpt-oss use it?
MXFP4 is a 4-bit format in which a block of 32 weights shares one 8-bit scale, for 4.25 bits per weight. The expert weights, over 90% of the parameters, were post-trained in this format, so the 120B checkpoint is 60.8 GiB and the 20B checkpoint is 12.8 GiB.
How much memory does gpt-oss need?
The published checkpoints are 60.8 GiB for gpt-oss-120b and 12.8 GiB for gpt-oss-20b, and OpenAI says they fit on one 80 GB GPU and in 16 GB of memory. On top of that, one sequence needs KV cache: under the assumptions on this page (bfloat16), about 0.31 GB at 8K tokens, 1.21 GB at 32K and 4.84 GB at 128K on the 120B, and 0.20 GB, 0.81 GB and 3.22 GB on the 20B. These are estimates from the published configs, and real inference engines can differ.
Does gpt-oss support images or audio?
No. gpt-oss models are text-only, according to the model card.
How is gpt-oss different from Gemma 4 architecturally?
gpt-oss alternates 128-token sliding-window and dense layers 1:1, has attention sinks, uses pre-norm only, routes to 4 of 128 experts with no shared expert and stores its expert weights in MXFP4. Gemma 4 uses a 5:1 mix with a 1,024-token window, sandwich normalisation and p-RoPE, and its 26B model routes to 8 of 128 experts plus one shared expert.
Which license does gpt-oss use?
gpt-oss is released under the Apache 2.0 license together with OpenAI's gpt-oss usage policy, according to the model card.
Sources
Specs last verified November 21, 2026.
- gpt-oss-120b & gpt-oss-20b Model Card (OpenAI, arXiv:2508.10925)
- openai/gpt-oss-120b: model card and config.json (Hugging Face)
- openai/gpt-oss-20b: model card and config.json (Hugging Face)
- openai/gpt-oss: reference implementation (GitHub)
- Introducing gpt-oss (OpenAI)
- openai/harmony: the harmony response format (GitHub)
- From GPT-2 to gpt-oss: Analyzing the Architectural Advances (Sebastian Raschka)
- Microscaling Data Formats for Deep Learning (arXiv:2310.10537)
- Efficient Streaming Language Models with Attention Sinks (arXiv:2309.17453)
- Attention Is Off By One (Evan Miller)
- YaRN: Efficient Context Window Extension of Large Language Models (arXiv:2309.00071)
- GQA: Training Generalized Multi-Query Transformer Models (arXiv:2305.13245)
- Longformer: The Long-Document Transformer (arXiv:2004.05150)
- Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer (arXiv:1701.06538)
- GLU Variants Improve Transformer (arXiv:2002.05202)
- Root Mean Square Layer Normalization (arXiv:1910.07467)