Final RMSNorm

×

Rescale each position’s features using their root mean square, then apply learned gain.

m2(x)=1d∑j=1dxj2y=wfinal⊙xm2(x)+εε=10−5\begin{aligned}m_2(x)&=\frac{1}{d}\sum_{j=1}^d x_j^2\\y&=w_{\mathrm{final}}\odot\frac{x}{\sqrt{m_2(x)+\varepsilon}}\\\varepsilon&=10^{-5}\end{aligned}
in
h36h_{36} [B batch, T positions, 2880 d]
out
zz [B batch, T positions, 2880 d]

Computed in float32 and cast back after the scale multiplies (model.py 43–47).

Parameters2,880

2,880 parameters per instance.

ComponentParameters
Learned gain2,880
Sources

In codeself.norm(x) · 386

Open pinned code ↗

Direct evidence

RMSNorm: a float32 scale initialised to ones; the input taken to float32, divided by the root of its mean square plus ε (10⁻⁵ by default), multiplied by the scale and cast back.

model.py 32–47 ↗ · openai/gpt-oss @ 5681a6b65526

Excerpt
class RMSNorm(torch.nn.Module):
    def __init__(
        self, num_features: int, eps: float = 1e-05, device: torch.device | None = None
    ):
        super().__init__()
        self.num_features = num_features
        self.eps = eps
        self.scale = torch.nn.Parameter(
            torch.ones(num_features, device=device, dtype=torch.float32)
        )

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        assert x.shape[-1] == self.num_features
        t, dtype = x.float(), x.dtype
        t = t * torch.rsqrt(torch.mean(t**2, dim=-1, keepdim=True) + self.eps)
        return (t * self.scale).to(dtype)

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