Layers

×

36 layers with independent weights, alternating from the first: a window layer, then a global layer, 18 times.

h′=h+Δattnh'=h+\Delta_{\mathrm{attn}}
hnext=h′+Δffnh_{\mathrm{next}}=h'+\Delta_{\mathrm{ffn}}
All 24 steps
Sliding-window layer:\text{Sliding-window layer:}
xattn=RMSNorm⁡(h)x_{\mathrm{attn}}=\operatorname{RMSNorm}(h)
KG[h]=K[⌊h/8⌋]{\htmlClass{vl-stream-k}{K_{\mathrm G}}}[h]={\htmlClass{vl-stream-k}{K}}\big[\lfloor h/8\rfloor\big]
VG[h]=V[⌊h/8⌋]{\htmlClass{vl-stream-v}{V_{\mathrm G}}}[h]={\htmlClass{vl-stream-v}{V}}\big[\lfloor h/8\rfloor\big]
S=QKGTS=QK_{\mathrm G}^{\mathsf T}
S′=S/64S'=S/\sqrt{64}
t−128<s≤tt-128<s\le t
Ah,t,s=eSh,t,s′eb+∑s′eSh,t,s′′A_{h,t,s}=\frac{e^{S'_{h,t,s}}}{e^{b}+\sum_{s'}e^{S'_{h,t,s'}}}
H=AVGH=AV_{\mathrm G}
h′=h+Δattnh'=h+\Delta_{\mathrm{attn}}
xffn=RMSNorm⁡(h′)x_{\mathrm{ffn}}=\operatorname{RMSNorm}(h')
Δffn=∑i=1128Gi Ei\Delta_{\mathrm{ffn}}=\sum_{i=1}^{128}G_i\,E_i
hnext=h′+Δffnh_{\mathrm{next}}=h'+\Delta_{\mathrm{ffn}}
Global layer:\text{Global layer:}
xattn=RMSNorm⁡(h)x_{\mathrm{attn}}=\operatorname{RMSNorm}(h)
KG[h]=K[⌊h/8⌋]{\htmlClass{vl-stream-k}{K_{\mathrm G}}}[h]={\htmlClass{vl-stream-k}{K}}\big[\lfloor h/8\rfloor\big]
VG[h]=V[⌊h/8⌋]{\htmlClass{vl-stream-v}{V_{\mathrm G}}}[h]={\htmlClass{vl-stream-v}{V}}\big[\lfloor h/8\rfloor\big]
S=QKGTS=QK_{\mathrm G}^{\mathsf T}
S′=S/64S'=S/\sqrt{64}
s≤ts\le t
Ah,t,s=eSh,t,s′eb+∑s′eSh,t,s′′A_{h,t,s}=\frac{e^{S'_{h,t,s}}}{e^{b}+\sum_{s'}e^{S'_{h,t,s'}}}
H=AVGH=AV_{\mathrm G}
h′=h+Δattnh'=h+\Delta_{\mathrm{attn}}
xffn=RMSNorm⁡(h′)x_{\mathrm{ffn}}=\operatorname{RMSNorm}(h')
Δffn=∑i=1128Gi Ei\Delta_{\mathrm{ffn}}=\sum_{i=1}^{128}G_i\,E_i
hnext=h′+Δffnh_{\mathrm{next}}=h'+\Delta_{\mathrm{ffn}}
in
h0h_0 [B batch, T positions, 2880 d]RR [B batch, T positions, 64 rotary features]
out
h36h_{36} [B batch, T positions, 2880 d]
Parameters115,670,886,912

115,670,886,912 parameters per instance, across its learned components

ComponentCalculationParameters
Sliding-window layer3,213,080,192 × 1857,835,443,456
Global layer3,213,080,192 × 1857,835,443,456
Per-instance total115,670,886,912
Explanation

A layer reads a window when its index, counted from zero, is even (model.py 187–188): layers 1, 3, …, 35 as the atlas counts them; the others read every earlier position.

The two kinds drawn here are kinds of layer; in the model they alternate, one of each in turn.

Sources

In codeself.block · 367–372

Open pinned code ↗

Direct evidence

The model: a token embedding of the vocabulary by the width; 36 layers; a final RMSNorm; an unembedding without bias, separate from the embedding; the forward embeds, applies the layers in order, normalises and projects to the vocabulary.

model.py 357–388 ↗ · openai/gpt-oss @ 5681a6b65526

Excerpt
class Transformer(torch.nn.Module):
    def __init__(
        self,
        config: ModelConfig,
        device: torch.device | None = None,
    ):
        super().__init__()
        self.embedding = torch.nn.Embedding(
            config.vocab_size, config.hidden_size, device=device, dtype=torch.bfloat16
        )
        self.block = torch.nn.ModuleList(
            [
                TransformerBlock(config, layer_idx, device)
                for layer_idx in range(config.num_hidden_layers)
            ]
        )
        self.norm = RMSNorm(config.hidden_size, device=device)
        self.unembedding = torch.nn.Linear(
            config.hidden_size,
            config.vocab_size,
            bias=False,
            device=device,
            dtype=torch.bfloat16,
        )

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        x = self.embedding(x)
        for block in self.block:
            x = block(x)
        x = self.norm(x)
        x = self.unembedding(x)
        return x

A layer is the attention block then the MLP block, each adding its output to what entered it.

model.py 339–354 ↗ · openai/gpt-oss @ 5681a6b65526

Excerpt
class TransformerBlock(torch.nn.Module):
    def __init__(
        self,
        config: ModelConfig,
        layer_idx: int,
        device: torch.device | None = None,
    ):
        super().__init__()
        self.layer_idx = layer_idx
        self.attn = AttentionBlock(config, layer_idx, device)
        self.mlp = MLPBlock(config, device)

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        x = self.attn(x)
        x = self.mlp(x)
        return x

The attention block: a window on the layers whose index, counted from zero, is even; one sink per query head, bfloat16; an RMSNorm; one fused query–key–value projection with bias to 64·(64 + 2·8) features; an output projection with bias from 64·64 features to the width; the scale 1/√64; its own rotary embedding with the configuration’s base, YaRN factor and NTK α and β.

model.py 176–215 ↗ · openai/gpt-oss @ 5681a6b65526

Excerpt
class AttentionBlock(torch.nn.Module):
    def __init__(
        self,
        config: ModelConfig,
        layer_idx: int = 0,
        device: torch.device | None = None,
    ):
        super().__init__()
        self.head_dim = config.head_dim
        self.num_attention_heads = config.num_attention_heads
        self.num_key_value_heads = config.num_key_value_heads
        # Only apply sliding window to every other layer
        self.sliding_window = config.sliding_window if layer_idx % 2 == 0 else 0
        self.sinks = torch.nn.Parameter(
            torch.empty(config.num_attention_heads, device=device, dtype=torch.bfloat16)
        )
        self.norm = RMSNorm(config.hidden_size, device=device)
        qkv_dim = config.head_dim * (
            config.num_attention_heads + 2 * config.num_key_value_heads
        )
        self.qkv = torch.nn.Linear(
            config.hidden_size, qkv_dim, device=device, dtype=torch.bfloat16
        )
        self.out = torch.nn.Linear(
            config.head_dim * config.num_attention_heads,
            config.hidden_size,
            device=device,
            dtype=torch.bfloat16,
        )
        self.sm_scale = 1 / math.sqrt(config.head_dim)
        self.rope = RotaryEmbedding(
            config.head_dim,
            config.rope_theta,
            torch.float32,
            initial_context_length=config.initial_context_length,
            scaling_factor=config.rope_scaling_factor,
            ntk_alpha=config.rope_ntk_alpha,
            ntk_beta=config.rope_ntk_beta,
            device=device,
        )

The Hugging Face configuration of the same checkpoint: attention_bias true; layer_types alternating sliding_attention and full_attention, beginning with sliding_attention; max_position_embeddings 131,072; rms_norm_eps 10⁻⁵; YaRN with factor 32 over 4,096 original positions, β_fast 32, β_slow 1; untied word embeddings; the MoE weights stored as MXFP4, attention, router, embedding and head not.

config.json 1–88 ↗ · openai/gpt-oss-120b @ b5c939de8f75

Excerpt
{
  "architectures": [
    "GptOssForCausalLM"
  ],
  "attention_bias": true,
  "attention_dropout": 0.0,
  "eos_token_id": 200002,
  "experts_per_token": 4,
  "head_dim": 64,
  "hidden_act": "silu",
  "hidden_size": 2880,
  "initial_context_length": 4096,
  "initializer_range": 0.02,
  "intermediate_size": 2880,
  "layer_types": [
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention",
    "sliding_attention",
    "full_attention"
  ],
  "max_position_embeddings": 131072,
  "model_type": "gpt_oss",
  "num_attention_heads": 64,
  "num_experts_per_tok": 4,
  "num_hidden_layers": 36,
  "num_key_value_heads": 8,
  "num_local_experts": 128,
  "output_router_logits": false,
  "pad_token_id": 199999,
  "quantization_config": {
    "modules_to_not_convert": [
      "model.layers.*.self_attn",
      "model.layers.*.mlp.router",
      "model.embed_tokens",
      "lm_head"
    ],
    "quant_method": "mxfp4"
  },
  "rms_norm_eps": 1e-05,
  "rope_scaling": {
    "beta_fast": 32.0,
    "beta_slow": 1.0,
    "factor": 32.0,
    "original_max_position_embeddings": 4096,
    "rope_type": "yarn",
    "truncate": false
  },
  "rope_theta": 150000,
  "router_aux_loss_coef": 0.9,
  "sliding_window": 128,
  "swiglu_limit": 7.0,
  "tie_word_embeddings": false,
  "transformers_version": "4.55.0.dev0",
  "use_cache": true,
  "vocab_size": 201088
}