Rust in Everything

Qwen3-8B

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

第三代千问标准 8.2B 稠密主力模型:36 层深窄结构、移除 QKV 偏置并全面引入 QK-Norm,支持思考/非思考双模式无缝切换。

01.从 Qwen2.5 到 Qwen3 的关键架构演进:彻底移除 Q/K/V 线性偏置 (`attention_bias: false`),改用每头 QK-RMSNorm 提升训练与量化稳定性。
02.36 层 × 4096 维深窄配比:相比传统 32 层 8B 模型加深至 36 层,FFN 中间维收敛至 12288 (3×D),兼顾推理深度与显存占用。
03.4:1 GQA (32Q : 8KV × 128d) 搭配独立非绑定词表投影 (`V = 151,936`)。

Qwen/Qwen3-8B

Qwen Dense (GQA)bfloat16
Source: Curated Model Atlas (Official Config)· Class: Qwen3ForCausalLM· L2: model.safetensors.index.json (5 shards, BF16)
总参数量 / 单 Token 激活
8.19B (100% Dense)
主干维度 (Layers × Hidden)
36L × 4096d
Vocab: 151936
KV Cache 压缩效率
4.0× vs MHA
2048 elems/tok/layer
上下文窗口 & 位置编码
40K ctx
RoPE θ=1M
Embedding: 622.3M (7.6%)Attention / SSM: 1.51B (18.4%)Dense FFN: 5.44B (66.4%)Output Head: 622.3M (7.6%)
Macro Forward Pass (点击任意模块钻取细节)
视图粒度:
input_ids : int64 [B, S]
h_0 : [B, S, 4096]
Layers 0–35 (×36) · 当前观测 Layer #0
0/35
xResidual Skip #1
Self-Attention
KV ÷4.0×
GQA (32Q:8KV × 128d + QK-Norm)
RoPE θ=1M · 41.9M/layer
+h_mid = x + Mixer(Norm(x)) : [B, S, 4096]
hResidual Skip #2
Gated MLP (FFN)
151.0M/layer
Dense FFN (silu, I=12288)
+h_out = h_mid + FFN(Norm(h_mid)) : [B, S, 4096]
h_final : [B, S, 4096]
▾ Output & Decoding Stage
logits : float [B, S, 151936]
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)q_norm [128] + PosRoPE θ=1Mk_norm [128] + 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 权重张量 (6 项)Shape = [out, in]
Tensor PatternShapeDtypeCountParams
model.layers.[0..35].self_attn.q_proj.weight[4096, 4096]BF16×36604.0M
model.layers.[0..35].self_attn.k_proj.weight[1024, 4096]BF16×36151.0M
model.layers.[0..35].self_attn.v_proj.weight[1024, 4096]BF16×36151.0M
model.layers.[0..35].self_attn.o_proj.weight[4096, 4096]BF16×36604.0M
model.layers.[0..35].self_attn.q_norm.weight[128]BF16×364.6K
model.layers.[0..35].self_attn.k_norm.weight[128]BF16×364.6K
部署量化精度
上下文长度 (Context)
并发序列数 (Batch)
预估推理总显存:20.37 GiB
硬件建议:24 GB 级(1× RTX 3090 / 4090 / L4)
模型权重: 15.26 GiB
KV Cache: 4.50 GiB
激活/工作区: 624.9 MiB
★ 架构收益:在当前 B=1、Ctx=32768 配置下,相比标准多头注意力 (MHA 需 18.00 GiB) 节省了 13.50 GiB 缓存显存!