Rust in Everything

Llama-3.1-8B-Instruct

LLM 语言模型
提示:左侧拓扑图支持「紧凑总览 / 标准观察 / 全展开+算子」及单个模块独立收起与展开

全球生态最广泛的 8.03B 稠密基准架构:32 层 × 4096 维、4:1 GQA (32Q:8KV) 与 3.5× SwiGLU,几乎所有推理引擎的首选对照基线。

01.推理框架黄金对照基线:32 层、D=4096、head_dim=128、32Q:8KV,结构工整无任何异构分支,适合与其他变体架构做逐算子对比。
02.3.5× 宽 FFN 扩展 (`intermediate_size = 14336`):相比 Qwen3-8B (3.0×),单层 FFN 更宽但层数更少(32 vs 36 层)。
03.独立 Embedding 与 LM Head 占总参数约 13.1%(`2 × 128256 × 4096 = 1.05B`),主干 FFN 占 70.3%。

meta-llama/Llama-3.1-8B-Instruct

Llama / GQA Densebfloat16
Source: Curated Model Atlas (Official Config)· Class: LlamaForCausalLM· L2: model.safetensors.index.json (4 shards, BF16)
总参数量 / 单 Token 激活
8.03B (100% Dense)
主干维度 (Layers × Hidden)
32L × 4096d
Vocab: 128256
KV Cache 压缩效率
4.0× vs MHA
2048 elems/tok/layer
上下文窗口 & 位置编码
128K ctx
RoPE θ=500K (llama3 ×8.0)
Embedding: 525.3M (6.5%)Attention / SSM: 1.34B (16.7%)Dense FFN: 5.64B (70.2%)Output Head: 525.3M (6.5%)
Macro Forward Pass (点击任意模块钻取细节)
视图粒度:
input_ids : int64 [B, S]
h_0 : [B, S, 4096]
Layers 0–31 (×32) · 当前观测 Layer #0
0/31
xResidual Skip #1
Self-Attention
KV ÷4.0×
GQA (32Q:8KV × 128d)
RoPE θ=500K (llama3 ×8.0) · 41.9M/layer
+h_mid = x + Mixer(Norm(x)) : [B, S, 4096]
hResidual Skip #2
Gated MLP (FFN)
176.2M/layer
Dense FFN (silu, I=14336)
+h_out = h_mid + FFN(Norm(h_mid)) : [B, S, 4096]
h_final : [B, S, 4096]
▾ Output & Decoding Stage
logits : float [B, S, 128256]
Operator Subgraph · Layer #0
x_norm [B, S, 4096]q_proj (no bias)[4096 → 4096] (32×128)k_proj (no bias)[4096 → 1024] (8×128)v_proj (no bias)[4096 → 1024] (8×128)Reshape + PosRoPE θ=500K (llama3 ×8.0)Reshape + PosQ:KV Group = 4:1★ KV Cache (K & V): 2 × [B, 8, S, 128] (2048 elems/tok/layer)Scaled Dot-Product Attention (1/√128 · Causal Mask)Softmax(Q · Kᵀ) · V → Concat [B, S, 4096]o_proj [4096 → 4096] (no bias)Output: [B, S, 4096] → Residual Add (+)
匹配该子模块的真实 Safetensors 权重张量 (4 项)Shape = [out, in]
Tensor PatternShapeDtypeCountParams
model.layers.[0..31].self_attn.q_proj.weight[4096, 4096]BF16×32536.9M
model.layers.[0..31].self_attn.k_proj.weight[1024, 4096]BF16×32134.2M
model.layers.[0..31].self_attn.v_proj.weight[1024, 4096]BF16×32134.2M
model.layers.[0..31].self_attn.o_proj.weight[4096, 4096]BF16×32536.9M
部署量化精度
上下文长度 (Context)
并发序列数 (Batch)
预估推理总显存:19.56 GiB
硬件建议:24 GB 级(1× RTX 3090 / 4090 / L4)
模型权重: 14.96 GiB
KV Cache: 4.00 GiB
激活/工作区: 612.7 MiB
★ 架构收益:在当前 B=1、Ctx=32768 配置下,相比标准多头注意力 (MHA 需 16.00 GiB) 节省了 12.00 GiB 缓存显存!