[B, T, 4096]to [B, T, 4096]
Parameters176,160,768 × 32 layers
176,160,768 parameters per instance, across its learned components
| Component | Calculation | Parameters |
|---|---|---|
| Gate projection | 4,096 × 14,336 | 58,720,256 |
| Up projection | 4,096 × 14,336 | 58,720,256 |
| Down projection | 14,336 × 4,096 | 58,720,256 |
| Per-instance total | 176,160,768 | |
MLP width, derived from the configuration
One in each of the 32 layers, each with its own weights.
Not checked against a checkpoint.
Sources
In codeself.feed_forward(self.ffn_norm(h))
Based on Meta’s pinned catalogue and reference implementation. Direct checkpoint configuration and tokenizer assets remain unverified.
Direct evidence
Meta's Llama 3.1 8B base catalogue entry supplies dimensions, head counts, the vocabulary (LLAMA3_VOCAB_SIZE, line 19), MLP rounding, epsilon, rope_theta and use_scaled_rope: True.
sku_list.py 19–248 ↗ · meta-llama/llama-models @ 0e0b8c519242
Excerpt
LLAMA3_VOCAB_SIZE = 128256… lines 20–230 omitted …
Model(
core_model_id=CoreModelId.llama3_1_8b,
description="Llama 3.1 8b model",
huggingface_repo="meta-llama/Llama-3.1-8B",
arch_args={
"dim": 4096,
"n_layers": 32,
"n_heads": 32,
"n_kv_heads": 8,
"vocab_size": LLAMA3_VOCAB_SIZE,
"ffn_dim_multiplier": 1.3,
"multiple_of": 1024,
"norm_eps": 1e-05,
"rope_theta": 500000.0,
"use_scaled_rope": True,
},
pth_file_count=1,
),The layer passes four times model width; FeedForward truncates, applies the configured multiplier and rounds to the configured multiple.
model.py 193–234 ↗ · meta-llama/llama3 @ a0940f9cf706
Excerpt
class FeedForward(nn.Module):
def __init__(
self,
dim: int,
hidden_dim: int,
multiple_of: int,
ffn_dim_multiplier: Optional[float],
):
super().__init__()
hidden_dim = int(2 * hidden_dim / 3)
# custom dim factor multiplier
if ffn_dim_multiplier is not None:
hidden_dim = int(ffn_dim_multiplier * hidden_dim)
hidden_dim = multiple_of * ((hidden_dim + multiple_of - 1) // multiple_of)… lines 207–228 omitted …
self.feed_forward = FeedForward(
dim=args.dim,
hidden_dim=4 * args.dim,
multiple_of=args.multiple_of,
ffn_dim_multiplier=args.ffn_dim_multiplier,
)The MLP owns three bias-free projections. Its forward expression applies SiLU to w1(x), multiplies w3(x) element-wise and projects through w2.
model.py 208–219 ↗ · meta-llama/llama3 @ a0940f9cf706
Excerpt
self.w1 = ColumnParallelLinear(
dim, hidden_dim, bias=False, gather_output=False, init_method=lambda x: x
)
self.w2 = RowParallelLinear(
hidden_dim, dim, bias=False, input_is_parallel=True, init_method=lambda x: x
)
self.w3 = ColumnParallelLinear(
dim, hidden_dim, bias=False, gather_output=False, init_method=lambda x: x
)
def forward(self, x):
return self.w2(F.silu(self.w1(x)) * self.w3(x))Attention receives attention_norm(x) and its update is added to x; the MLP receives ffn_norm(h) and its update is added to h.
model.py 236–248 ↗ · meta-llama/llama3 @ a0940f9cf706
Excerpt
self.attention_norm = RMSNorm(args.dim, eps=args.norm_eps)
self.ffn_norm = RMSNorm(args.dim, eps=args.norm_eps)
def forward(
self,
x: torch.Tensor,
start_pos: int,
freqs_cis: torch.Tensor,
mask: Optional[torch.Tensor],
):
h = x + self.attention(self.attention_norm(x), start_pos, freqs_cis, mask)
out = h + self.feed_forward(self.ffn_norm(h))
return out