Rust in Everything
← 模型架构图鉴·AI 工程板块/L1 Config + L2 Safetensors Live Sandbox

多模态模型架构可视化器

通过 HuggingFace 或 ModelScope 的 config.json / model_index.json 与 Safetensors 元数据,精确解析并可视化 LLM、VLM、ASR/TTS 语音、图像/视频扩散 (DiT/UNet)、线性注意力 SSM 及 Embedding 架构拓扑与推理显存。

经典架构基准:

deepseek-ai/DeepSeek-V3

DeepSeek MLA + MoEbfloat16FP8 · e4m3 · block 128×128
Source: Built-in Snapshot (HF/ModelScope Verified)· Class: DeepseekV3ForCausalLM· L2: model.safetensors.index.json (163 shards, FP8 + BF16)
总参数量 / 单 Token 激活
671.03B · 37.55B (5.6%)
主干维度 (Layers × Hidden)
61L × 7168d
Vocab: 129280
KV Cache 压缩效率
56.9× vs MHA
576 elems/tok/layer
上下文窗口 & 位置编码
160K ctx
RoPE θ=10K (yarn ×40.0)
Embedding: 926.7M (0.1%)Attention / SSM: 11.41B (1.7%)Dense FFN: 1.19B (0.2%)MoE Routed: 653.91B (97.4%)MoE Shared: 2.55B (0.4%)Output Head: 926.7M (0.1%)
Macro Forward Pass (点击任意模块钻取细节)
视图粒度:
input_ids : int64 [B, S]
h_0 : [B, S, 7168]
MLA (128H, c_KV=512d + k_R=64d)Dense FFN (silu, I=18432)
h_3 : [B, S, 7168]
Layers 3–60 (×58) · 当前观测 Layer #3
3/60
xResidual Skip #1
Self-Attention
KV ÷56.9×
MLA (128H, c_KV=512d + k_R=64d)
RoPE θ=10K (yarn ×40.0) · 187.1M/layer
+h_mid = x + Mixer(Norm(x)) : [B, S, 7168]
hResidual Skip #2
Sparse MoE Feed-Forward
398.2M / 11.32B
MoE (1 Shared + Top-8/256 Routed, I=2048)
Router [7168 → 256] · sigmoid · 8组选4组
★ Active ×8
I=2048 (参与计算)
Idle ×248
0 FLOPs (驻留显存)
常驻共享专家 ×1 (I=2048,100% Token 直通)
+h_out = h_mid + FFN(Norm(h_mid)) : [B, S, 7168]
h_final : [B, S, 7168]
▾ Output & Decoding Stage
logits : float [B, S, 129280]
Operator Subgraph · Layer #3
x_norm [B, S, 7168]q_a_proj [7168 → 1536] + RMSNormQuery Latent c_Q : [B, S, 1536]q_b_proj [1536 → 24576] (128×192)Split → q_nope[128] + RoPE(q_pe[64])kv_a_proj_with_mqa [7168 → 576]Split: c_KV [512] + Shared k_pe [64]★ Latent KV Cache: ONLY 576 dims/tok!RMSNorm(c_KV[512]) + RoPE(k_pe[64]) · 56.9× vs MHAkv_b_proj [512 → 32768]Unpack 128H: k_nope[128] + v[128] (Absorbable)MLA Attention (128 Heads, Scale 1/√192 + YaRN mscale)Score = q_nope·k_nopeᵀ + q_pe·k_peᵀ → Weighted V [B, S, 16384]o_proj [16384 → 7168]Output: [B, S, 7168] → Residual Add (+)
匹配该子模块的真实 Safetensors 权重张量 (7 项)Shape = [out, in]
Tensor PatternShapeDtypeCountParams
model.layers.[0..60].self_attn.q_a_proj.weight[1536, 7168]F8_E4M3×61671.6M
model.layers.[0..60].self_attn.q_a_layernorm.weight[1536]BF16×6193.7K
model.layers.[0..60].self_attn.q_b_proj.weight[24576, 1536]F8_E4M3×612.30B
model.layers.[0..60].self_attn.kv_a_proj_with_mqa.weight[576, 7168]F8_E4M3×61251.9M
model.layers.[0..60].self_attn.kv_a_layernorm.weight[512]BF16×6131.2K
model.layers.[0..60].self_attn.kv_b_proj.weight[32768, 512]F8_E4M3×611.02B
model.layers.[0..60].self_attn.o_proj.weight[7168, 16384]F8_E4M3×617.16B
部署量化精度
上下文长度 (Context)
并发序列数 (Batch)
预估推理总显存:670.51 GiB
硬件建议:多机集群(2+ 节点 × 8× H100/H200 RDMA)
模型权重: 643.69 GiB
KV Cache: 1.07 GiB
激活/工作区: 25.75 GiB
★ 架构收益:在当前 B=1、Ctx=32768 配置下,相比标准多头注意力 (MHA 需 61.00 GiB) 节省了 59.93 GiB 缓存显存!