本手册如何处理数据官方 表示直接来自模型报告、模型卡或配置;推导 表示根据公开参数计算;规划假设 表示用于早期架构探索,必须用目标 runtime 的 profile 替换。不会把 checkpoint 文件大小、模型参数量和运行时 HBM 占用混为一谈。
建议阅读路径
1固定模型事实先读模型参数总表和三个模型解剖,理解注意力、MoE、KV 以及量化格式。
→2建立负载模型分别推导 prefill、decode、长上下文和专家并行的算力/访存/通信。
→3映射到卡与集群决定矩阵/向量/稀疏引擎、SRAM、HBM、NoC 和 scale-up/scale-out。
→4完成软件闭环以 GPU baseline 为黄金参考,把权重、图、Kernel、runtime 和服务逐层移植。
先记住这四个判断
01模型能放下,不代表能服务。权重之外还要留出 KV、workspace、通信 buffer、runtime graph 与碎片余量。
02MoE 减 FLOPs,不必然减容量与通信。所有专家权重仍需驻留;top-k 增大还会放大 token dispatch。
031M context 不是一个单一数字。要分别核算全局 KV、局部状态、稀疏索引、KDA recurrent state 和可持久化前缀。
04卡架构必须由 Kernel shape 驱动。大 GEMM 峰值只覆盖 prefill 的一部分;decode 更依赖小批 grouped GEMM、带宽、collective 与调度。
架构参数对照
| 字段 | DeepSeek V4.1 Flash | DeepSeek V4 Pro | Kimi K3 |
| 模型类型 | 多模态 CED MoE | 文本 MoE | 原生多模态 MoE |
| 总 / Backbone 参数 | 552B backbone + 196B Engram HF 页面统计约 763B | 1.6T | 2.78T |
| 激活参数 / token | Prefill 8B / Decode 16B | 49B | 104.2B |
| 层数 / Hidden | 40(20 encoder + 20 decoder)/ 5120 | 61 / 7168 | 93 / 7168 |
| 注意力 | CSA2 + SWA Full / Reindex / Reuse | CSA / HCA 交替 + SWA | 69 KDA + 24 Gated MLA |
| 专家 | 1 shared + 384 routed top-6 | 1 shared + 384 routed top-6 | 2 shared + 896 routed top-16 |
| MoE 中间维度 | 2304 | 3072 | 3072;LatentMoE 维度 3584 |
| 上下文 | 1,048,576 | 1,048,576 | 1,048,576 |
| 原生数值格式 | 路由专家 FP4;其余主要 FP8;embedding/head BF16;FP4 global KV | 路由专家 FP4;其余主要 FP8 | MXFP4 expert weights / MXFP8 activations |
| 官方仓库载荷 实测 | 475.2 GiB | 805.3 GiB runtime recipe 注记约 960 GB | 1,453.7 GiB |
| 主要硬件新负载 | Engram lookup、CSA2 indexer、DSpark、CED KV projection | 稀疏索引、混合压缩 KV、mHC、超大 expert pool | KDA scan/state、Block AttnRes、16-way dispatch、混合 cache |
来源:官方模型卡、官方 config.json、Kimi K3 Technical Report;仓库载荷通过 Hugging Face Models API 的 blob size 汇总,快照日期见页顶。
不要用一个 “TOPS” 比较三者
权重容量475 GiB
805 GiB
1,454 GiB
V4.1 FlashV4 ProKimi K3
架构含义V4.1 Flash 的主要挑战是异构 memory access 与新型 sparse-attention pipeline;V4 Pro 是容量和混合精度 grouped GEMM;Kimi K3 则把容量、MoE 网络流量、线性注意力状态和 multimodal 全部推到高位。三者共享“低精度 + 大 HBM + 高速互联”的需求,但最优卡内资源比例不同。
权重能否装入一组卡:第一轮筛选
仅按 checkpoint / HBM4 × 141 GiB8 × 141 GiB8 × 192 GiB8 × 288 GiB
V4.1 Flash · 475 GiB可放入*可放入可放入可放入
V4 Pro · 805 GiB不足容量紧*可放入可放入
Kimi K3 · 1,454 GiB不足不足几乎无余量*可放入
* 这里只是静态容量门槛未扣除 10–20% runtime/碎片余量,也未计入 KV cache、通信 buffer 与 graph capture。V4.1 Flash 还可把 Engram offload 到 host DRAM;Kimi K3 在 8×192 GiB 上即便文件勉强装入,也没有可用服务余量。
论文地图:只沿推理主线阅读
ARXIV · 2609.19969 · 51 PAGESDeepSeek-V4.1-Flash: Pushing the Limits of KV Cache Compression
重点对应论文 §2.2 CED、§2.3 CSA2、§2.4 高效扩展、§3.2 推理系统。训练与能力评测不展开,除非它解释了量化格式或推理近似为何成立。
打开原论文 PDF ↗
01 · PREFILL20 层 Encoderprompt 仅完整经过下半模型
→02 · MATERIALIZEDecoder Global KV由 H20 分层投影产生
→03 · REPLAY128-token SWA只恢复 decoder 局部状态
→04 · DECODE40 层 + DSpark逐 token,权重/通信受限
| 阶段 | 主要 Kernel | 常驻/产生状态 | 首要硬件瓶颈 |
|---|
| 长 prompt prefill | MoE grouped GEMM、CSA2 index、chunked attention | encoder hidden、global KV、index | FP8/FP4 矩阵吞吐、SRAM 复用、HBM 写带宽 |
| decoder KV 投影 | H20 × WKVl / WZl | 20 层 decoder global KV | 高扇出读、投影融合、量化写回 |
| SWA bounded replay | 20 层 × 最近 128 token | layer-local SWA KV | 短序列小 GEMM、launch/同步开销 |
| decode + verify | sparse gather attention、MoE、DSpark verify | 890 B/token global KV + 热 SWA | HBM/互联、非规则 gather、动态 batch |
CED 原理:Prompt 不再走完整 Decoder
40 层 causal Transformer 被重写为 20 层 causal encoder 与 20 层 autoregressive decoder。关键不是普通 encoder-decoder cross attention,而是 decoder 各层的 global KV 都从 encoder 最终状态 H20 直接产生;decoder 自身仍保留逐层 SWA,所以 decode 的表达深度没有被简单砍半。
论文 Eq. 1:decoder global state\[C^{l} = \mathrm{H\_}{L/2}W^{\mathrm{KV}}_{l}, Z^{l} = \mathrm{H\_}{L/2}W^{Z}_{l}, l > L/2\]
C 是主 KV 条目,Z 是压缩权重;每个 decoder 层仍有独立投影参数。
Prompt / Vision TokensN tokens
→CAUSAL ENCODER20 Layers8B active / token产生 H20 + encoder caches
→ layer-wise KV projection↘ last-128 replay
AUTOREGRESSIVE DECODER20 Layers16B active / output tokenglobal KV from H20 + local SWA
→Next TokenDSpark verify
Prefill 复杂度\[O(\mathrm{NL}) \to O(\mathrm{NL}/2 + \mathrm{n\_}{\mathrm{win}}L/2) \approx O(\mathrm{NL}/2), N \gg 128\]
节省来自长 prompt 不经过完整 decoder;不是所有 decoder 工作都消失。
对架构的直接含义
GRAPH两张执行图Prefill 与 decode 的活跃权重、layer schedule 和状态输出不同。编译器必须支持 phase-specialized graph,而不能只改变 sequence length。
SRAMH20 高扇出同一 encoder tile 被多个 decoder KV 投影消费;需要 persistent tile、multicast 或 projection fusion,避免从 HBM 重读 20 次。
RUNTIME三类生命周期encoder intermediate、global KV 与 SWA state 必须独立分配、迁移、回收,P/D 分离时 payload 也不同。
CSA2 原理:同时压缩 Token 维与 Layer 维
普通稀疏注意力只减少被读出的 token;CSA2 还让多层共享 main KV、indexer K 和 Top-K 结果。每层仍生成自己的 query 与 128-token SWA KV,因此“共享”只发生在 global branch,不破坏局部细粒度路径。
模式Main KVIndexer KTop-K本层实际工作
FULL生成由 main KV 投影全上下文扫描完整压缩、index、Top-K、gather attention
REINDEX复用复用候选池重算新 query + bounded index + gather attention
REUSE复用复用复用新 query + sparse gather attention
论文给出的实际层编排
ENCODER L0–1SWA only无 global branch
ENCODER L2–193 × [Full + 5 Reuse]compression ratio = 2
DECODER GROUP 0Full + 3 Reuse首次扫全局
DECODER GROUP 1–4Reindex + 3 Reusecompression ratio = 1
Global attention 使用 64 个 query heads、head dimension 512;indexer 为 32 heads × 128 dimension,最终选择 Top-512。首个 decoder Full 层还按 block 内最大 score 选 2,048 个 block,每块 8 个 position,形成最多 16,384 position 的共享候选池。后续 Reindex 层只在这 16K 项上评分,因此 1M context 下深层 indexer 的计算量不再随上下文长度增长。
① COMPRESS / PROJECTHidden → Main KVencoder ratio 2;decoder ratio 1
→② INDEXQI · KI首层全扫,后续扫 candidate
→③ SELECTTop-512block max + partial selection
→④ GATHERFP4 Main KV离散地址聚合读取
→⑤ ATTENDSparse + SWA输出融合
芯片不能缺的 primitive- Top-K/partial sort:支持 1M→block candidates→16K→512 的分层选择,避免把完整 score 写回 HBM。
- Gather engine:512 个离散 FP4 KV 的地址合并、scale 读取和片上重排;仅有高顺序带宽不够。
- 跨层状态句柄:KV/index ownership 必须进入 graph IR,防止共享状态被错误复制或提前释放。
- 小矩阵效率:Reuse 层减少了 index work,decode 越发受 sparse attention 与 MoE 小 M grouped GEMM 支配。
FP4 Main KV:重点是解码路径,不是 FP4 GEMM
论文选择 E2M1 数据配每 16 channel 一个 E4M3 scale,省去二级 global scale;main KV 在 RoPE 之后量化,attention 之前反量化。也就是说,硬件无需用这种格式直接做矩阵乘,但必须能以极低代价完成 load → unpack → scale → sparse attention。SWA KV 因精度更敏感仍保留 FP8。
HBM · GLOBAL HOT SETMain Global KV
890 B / token1M token 单序列约 0.87 GiB;32 条满长序列约 27.8 GiB,尚未计 index、scale、页表和 allocator 碎片。
HOST DRAM · SHORT TTLSWA KV
10% host DRAM pool生产设计不再长期写 SSD;活跃 session 以分钟级 TTL 在分布式 host pool 周转。
SSD · ≥72HPersistent Global KV
≈ V4 的 1/4global KV 有长尾复用价值;叠加去除 persistent SWA 后,总持久化缓存约为 V4 的 1/8。
Global KV capacity\[\mathrm{C\_}{\mathrm{global}} = 890 \times \mathrm{context\_tokens} \times \mathrm{live\_sequences}\]
容量只是一层约束;真实带宽由每步 Top-512 gather、cache locality 与 page mapping 决定。
Bounded Replay:用固定重算换掉海量持久化 SWA
SWA 状态跨层传播,数学上精确恢复 40 层 SWA 需要回放 L × nwin token。V4.1 接受训练感知的近似:只回放命中点前最近 128 token,并截断到 replay segment。这样 persistent cache 只需保存 global KV。
| 场景 | 恢复动作 | 重用内容 | 硬件/Runtime 意义 |
|---|
| Encoder SWA miss | 最近 128 token 与 uncached suffix 合并执行 | 命中的 global KV 只读、不覆盖 | 要求 cache alias、只读共享与双输出 mask |
| Decoder prefill | H20 的最后 128 token 通过 20 层 decoder | decoder global KV 已由投影产生 | 短 M、连续 20 层,launch latency 比峰值 FLOPS 更关键 |
| 正常 active session | 直接从 host DRAM pool 取 SWA | global + SWA 全命中 | PCIe/CXL/RDMA tail latency 进入 TTFT |
Engram:196B 参数变成随机查表系统
两处 Engram 位于第 1、14 层,每处使用 n-gram 阶数 {2,3,4}、8 个 hash heads,每 head 约 16M entries,每个阶数总 embedding dimension 为 2048;table 与 KV projection 都是 FP8。地址只由输入 token 决定,因此可以在 backbone 计算前预取,但其性能取决于地址分布而非 GEMM 峰值。
TOKENIZERn-gram keys2 / 3 / 4-gram
→HASH × 8prime-sized tablesdeterministic address
→HOST DRAMFP8 embeddingbackground RDMA prefetch
→GATE / MERGEcontext-aware与 layer 计算重叠
CAPACITY可 offload 的权重196B FP8 仅原始表就约 196 GB;从 HBM 移出可显著降卡数,但必须保证 pinned/registered host memory。
LATENCY随机访存尾延迟看 P50 带宽没有意义,应测 batch size、hash collision、page locality 下的 P99 lookup,并设预取深度。
I/O计算掩盖条件只有当 lookup transfer 小于前序 block 的可重叠计算窗口时,offload 才近似“免费”;否则直接拉长 TTFT/TPOT。
Single-Pass mHC:Residual 也必须按字节优化
mHC 维护 n=4 条 residual streams。原 V4 的多 pass 实现需要 residual update、系数预测和 input mixing 三次 kernel;V4.1 将 input mixing 系数错后一层,使所有输出可在一次遍历中产生。
论文 Eq. 6\[\mathrm{X\_}{l+1} = \mathrm{B\_}{l}\mathrm{X\_}{l} + \mathrm{C\_}{l}\mathrm{F\_}{l}(\mathrm{A\_}{l-1}\mathrm{X\_}{l})\]
A 使用上一层系数,解除“先完成全 hidden reduction 才能 mixing”的依赖。
V4 MULTI-PASS(4n + 4)dactivation read/write;3 个串行 kernel
→MEGA-mHC(2n + 2)d理论下界;一次读写 residual
FUSED EPILOGUEmix + coeff + norm + FP8 cast要求跨 tile reduction 与低开销同步
DSpark:验证长度是一个在线调度问题
DSpark 用 3 个带 128-token sliding window 的 Transformer block,一次并行给出 5 个 draft position 的 base logits;轻量 Markov head 补回块内依赖,confidence head 估计每个位置的条件接受率。调度器把 prefix survival probability 与实测 engine throughput curve 结合,为每条请求选择不同 verification length。
Parallel backbone5 positions / pass
→Markov headintra-block dependency
→Confidence headP(accept position i)
→Load-aware schedulerchoose verify length
→Target verifyaccept prefix / compact
| 需要支持 | 为什么 | 建议计数器 |
|---|
| 变长 verify batch | 每个 request 的最佳验证长度不同 | verify tokens/request、padding ratio |
| mask + prefix compaction | 拒绝位置之后的 token 不再有效 | accepted length、rollback ratio |
| draft/target 并发资源隔离 | draft 省延迟但会抢占 batch 与 HBM | SM/HBM/NoC overlap、accepted tok/J |
| 权重常驻与低 launch overhead | draft block 很小,易被固定开销支配 | kernel count、host gap、graph replay hit |
最终形成的算力卡需求
子系统最低能力为什么验收 workload
矩阵阵列FP8 主路径;FP4 权重/scale 友好;ragged grouped GEMMMoE 与 KV projectionprefill M=chunk、decode M=batch 的 shape sweep
向量/选择单元Top-K、block max、prefix scan、mask/compactCSA2 index 与 DSpark1M→16K→512 selection,测 P99
SRAMH20 multicast、FP4 scale、Top-K candidate、mHC residual 常驻避免中间量反复落 HBM测 bytes/token 与 spill ratio
HBM高容量 + 高离散读效率,而非只报顺序 TB/s890 B/token cache 与 MoE 权重流随机 512-entry gather + grouped GEMM 并发
Host fabricRDMA/UVA、page fault 可控、QoSEngram 与短 TTL SWA offloadlookup P99、prefetch miss、host BW
RuntimeEPD 分离、异构 cache、跨层共享状态、动态 verify模型并非普通 decoder-onlyprefix hit/miss、SWA miss、mixed-length trace
论文给出的 production kernel 数值得关注通过融合,CSA2 为 Reuse Mode 的大多数层在 prefill 只需约 15 个 kernel、decode 约 11 个 kernel。自研卡验收不应只对齐算子数值,还要以“每层 launch 数、HBM round-trip、同步点”对齐这一系统目标。
论文地图与单 token 执行图
ARXIV · 2606.19348 · 58 PAGESDeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence
本页精读 §2.2 mHC、§2.3 CSA/HCA、§3.1 EP overlap、§3.5 KV 管理与 §5.2.1 FP4 QAT。训练配方与能力评测不作为重点。
打开原论文 PDF ↗
RESIDUAL IN4-stream mHC
→ATTENTIONCSA or HCA + SWAcompress / index / gather
→RESIDUALdynamic mix
→MOETop-6 + shareddispatch / GEMM / combine
↺ 61
| 结构 | 论文参数 | Decode 主要数据运动 | 硬件主矛盾 |
|---|
| CSA | m=4;Top-1024;64×128 indexer | 扫 compressed index → 离散读 1024 KV | 低精度 index GEMM、Top-K、gather |
| HCA | m′=128;128 heads × 512 | 顺序读约 L/128 个摘要 | 中小型 dense attention、片上流水 |
| SWA | window=128 | 逐层连续读最近 KV | 短序列 kernel 固定开销 |
| MoE | 384 routed / Top-6 + 1 shared;dff=3072 | FP8 token dispatch、专家权重流、BF16 combine | HBM 与 all-to-all 重叠 |
| mHC | 4 residual streams;20 次 Sinkhorn | 多流 residual 读写与动态系数 | 融合,否则 activation traffic 放大 |
mHC:为什么 Residual 从加法变成受约束路由
标准 residual 只有一条宽度 d 的状态;mHC 将其扩为 nhc × d,在进入 block 前用 A 混成一条输入,block 输出再由 C 写回多条流,同时 B 在流之间搬运旧信息。V4 Pro 中 nhc=4。
论文 Eq. 1\[\mathrm{X\_}{l+1} = \mathrm{B\_}{l}\mathrm{X\_}{l} + \mathrm{C\_}{l}\mathrm{F\_}{l}(\mathrm{A\_}{l}\mathrm{X\_}{l})\]
X∈R4×7168;F 是 attention 或 MoE 子层。
稳定性的关键是把 B 投影到双随机矩阵的 Birkhoff polytope:所有元素非负,且每行、每列和为 1。这样谱范数不超过 1,多层相乘也保持在同一集合内;A 用 sigmoid 约束在 [0,1],C 用 2·sigmoid 约束在 [0,2]。B 通过 exp 后执行 20 次 Sinkhorn 行/列归一化得到。
4 × 7168Residual streams
→ A1 × 7168Block input
→ Fl1 × 7168Block output
→ C + B4 × 7168Next residual
推理硬件含义- 系数矩阵很小,但依赖当前 token;单独 launch、写 HBM 会让低算术强度路径吞掉收益。
- 需要把 RMSNorm、A/B/C projection、Sinkhorn、小矩阵 mixing、FP8 cast 融入相邻 attention/MoE epilogue。
- SRAM 需同时容纳 4 条 residual tile;仅按 hidden=7168 估 activation 工作集会低估。
CSA:先把 1M Token 压成 250K,再只读 1024
CSA 不是简单 block pooling。每个压缩条目由当前 4-token block 的 A 分支与前一 block 的 B 分支共同贡献,两个分支各自产生 KV 与逐 channel compression weights,经 softmax 后加权形成共享的 compressed KV。相邻输出存在重叠,最终序列长度仍是原来的 1/4。
KV 压缩概念式(论文 Eq. 9–12)\[C^{\mathrm{comp}}_{i} = Σ S^{a}_{j}\odot C^{a}_{j} + Σ S^{b}_{j}\odot C^{b}_{j}, m=4\]
S 来自 Z 与可学习位置 bias 的 row-wise softmax;压缩是逐 channel 加权而非标量平均。
Lightning Indexer 将 query 先下投影到 1536,再升到 64×128 的 indexer heads。每个 head 做 Q·K,ReLU 后由 token-dependent head weight 加权求和,得到每个 compressed position 的 score,随后 Top-1024 进入主 attention。
Indexer score(论文 Eq. 16)\[\mathrm{I\_}{t,s} = Σ_{h=1..64} w^{I,h}_{t} \cdot \mathrm{ReLU}(q^{I,h}_{t} \cdot K^{\mathrm{IComp}}_{s})\]
1M context 下约 250K compressed keys;FP4 QK 计算之后仍需完成全局 Top-1024。
1M ORIGINAL1,048,576
÷4INDEX DOMAIN262,144 entries
Top-KCORE ATTENTION1,024 entries
+LOCAL128 SWA
→GROUPED OUT16 × 1024 → 7168
为什么是 Shared KV MQA 与 grouped output
被选中的每个 compressed entry 同时作为 key 和 value,供 128 个 query heads 共享。直接把 128×512=65,536 维 attention output 投回 7,168 代价过高,所以先分 16 组、每组投到 1,024 维,再做最终 projection。算力阵列必须覆盖这类“宽输入、分组中间层”的非标准 GEMM。
HCA:压到 1/128 后做 Dense Attention
HCA 去掉 indexer 和稀疏选择,每 128 个 token 以逐 channel 权重合并成一个条目;1M context 只留下 8,192 个左右的 global summaries。它保留全局覆盖,弥补 CSA Top-K 可能漏掉的信息,但分辨率较低。
HCA 压缩(论文 Eq. 22–23)\[S = \mathrm{Softmax\_}{\mathrm{row}}(Z + B), C^{\mathrm{comp}}_{i} = Σ_{j=128i..128(i+1)-1}\mathrm{S\_}{j}\odot \mathrm{C\_}{j}\]
无重叠、无 indexer;decode 时主路径是连续读取全部 compressed summaries。
Recent 128 tokensSWA连续、细粒度局部信息
+
compress ×4CSA262K index → Top-1024 sparse read
compress ×128HCA≈8K summaries dense read
不同层交替使用 CSA / HCA;两者都与 SWA 拼接并经过 grouped output projection
| 路径 | 随 context 增长 | 访问形态 | 芯片优化方向 |
|---|
| SWA | 固定 128 | 连续热数据 | persistent kernel / fused QKV-attention |
| CSA index | L/4 score,attention 固定 1024 | scan + Top-K + random gather | FP4 dot、片上 selection、scatter/gather coalescing |
| HCA | L/128 | 顺序 compressed stream | 小型 dense attention 与预取 |
论文的效率结论在 1M context 下,V4 Pro 的 single-token inference FLOPs 约为 V3.2 的 27%,KV cache 约为 10%;若以 BF16 GQA8、head dimension 128 为基准,V4 hybrid attention 的 KV 约为其 2%。这些是模型结构带来的量级变化,不等于任意 runtime 都能自动兑现。
FP4 推理:专家权重与 Indexer QK 是两条不同路径
Post-training QAT 把 MXFP4 用在两处:占据绝大多数容量的 MoE expert weights,以及 CSA indexer 的 Q/K cache 与乘法;index score 随后从 FP32 压到 BF16。论文报告这一 score 优化使 Top-K selector 获得约 2× 加速,同时保持 99.7% KV recall。
MOE WEIGHT PATHMXFP4 → FP8 compute
1×32 sub-block scale 可被 E4M3 更大 exponent range 吸收;推理时直接使用 native FP4 权重,避免先完整展开到 HBM。
INDEXER PATHFP4 Q/K → BF16 score
目标是降低 1M context 全域 index scan 的带宽与乘法成本;Top-K 单元仍需处理 BF16 score。
ACCUMULATIONMixed precision
scale unpack、dot、activation、accumulate 与 epilogue 的精度边界必须可编程,不能只有一种“FP4 mode”。
反量化落地会抹掉收益如果 FP4 expert 或 indexer K 先解成 FP8/BF16 tensor 再由第二个 kernel 消费,HBM 流量和 launch 会反弹。正确实现是 tile load 时解码,scale 在 SRAM/register 广播,直接进入 MAC。
MoE:通信应被计算完全覆盖,而不是单独排队
HIDDEN7168
→ROUTER√Softplusaux-loss-free bias
→TOP-6 / 384pull dispatch+ 1 shared expert
→EXPERT3072FP4 W / FP8 A
→COMBINEBF16
论文的 MegaMoE 将专家切成 waves:当前 wave 做 Linear-1/2 时,同时拉取下一 wave 的 token,并发送上一 wave 的结果。与只在两端重叠的做法相比,通信、GEMM、activation/combine 在稳态同时工作;论文在多平台上报告 1.50–1.73× 一般推理加速,延迟敏感场景最高 1.96×。
论文给出的隐藏通信条件\[C / B ≤ \mathrm{V\_}{\mathrm{comp}} / \mathrm{V\_}{\mathrm{comm}} = 2d = 6144 \mathrm{FLOP}/\mathrm{Byte}\]
每 token-expert 对约 6hd FLOPs,通信约 3h bytes(FP8 dispatch + BF16 combine);d=3072。
FABRIC带宽按配平点设计每 1 GB/s 可掩盖约 6.1 TFLOP/s expert compute。超过配平点继续堆带宽收益递减,低于则 MoE 暴露通信。
NoC / NIC细粒度 pull论文使用 GPU 主动读取远端 activation,绕过细粒度 push notification 的高延迟;自研互联应提供低延迟 doorbell 或高效 remote read。
POWER并发功耗墙融合后矩阵阵列、HBM 和网络同时高负载。TDP/VRM/温控若触发降频,理论 overlap 会变成互相争抢。
异构 KV:PagedAttention 的同构假设已经失效
每个 request 同时有固定大小的 state cache 与可增长的 classical KV cache。state cache 保存各层 SWA 最近 128 项,以及 CSA/HCA 尚不足一个 compression block 的 uncompressed tail;classical cache 保存已经压缩完成的 CSA/HCA 条目和 indexer KV。
FIXED / REQUESTState CacheSWA 128 × layers
CSA/HCA uncompressed tails
+PAGED / PREFIXCompressed KV CacheCSA main + indexer KV
HCA summaries
→BLOCK UNIT128 original tokenslcm(4,128)
32 CSA entries + 1 HCA entry
持久化到 SSD 时,CSA/HCA 完整压缩块可以直接复用,尾部不完整块必须重算。SWA 有三种策略:全量存储、周期 checkpoint 或完全不存;它们分别交换写放大、尾部重算和恢复延迟。runtime 的 cache policy 必须按状态类型配置,不能用一个统一 LRU。
容量、并行与单 token 下界
参数路径计算下界2 × 49B≈ 98 GFLOP/token未计 CSA index、HCA、mHC、router 与 MTP
100 system tok/s98 GFLOP × 100≈ 9.8 TFLOP/sdecode 通常不是峰值计算受限
无复用权重带宽示例49B × 0.75B × 100≈ 3.68 TB/s需用真实 expert working set 修正
规划问题论文/配置给出的约束硬件决定必须实测
权重容量1.6T total;仓库约 805.3 GiB,runtime recipe 约 960 GB 级HBM/卡、EP shard、reservepeak allocation 与碎片
TP 粒度expert d=3072;FP8 block_k=128优先 TP8;TP16 得到 192,不能整除 128padding、fallback kernel
Decode49B active + sparse index + all-to-allHBM bytes/token、fabric 配平batch 1→SLO 上限 sweep
Long contextCSA/HCA/SWA 三种 cacheheterogeneous pager、SSD tier1M prefix hit/miss TTFT
V4 Pro 算力卡签核表
子系统硬件/软件能力核心指标失败表现
Matrix CoreMXFP4 load、FP8 GEMM、mixed accumulate、ragged grouped GEMMshape-weighted effective TFLOPSdecode 小 M 只有峰值的零头
Selection EngineFP4 dot、ReLU weighted reduce、BF16 Top-10241M index latency / queryindexer 比主 attention 更慢
Memory随机 sparse gather + 顺序 HCA stream 并发useful bytes / transferred bytes标称 HBM 高,实际 gather 效率低
Scale-uppull remote read、wave-level barrier、FP8/BF16 payloadexposed EP time、tail waveall-to-all 串行暴露
On-chip NetworkMAC/HBM/NIC 三方并发与 QoSinjection、backpressure、power throttle融合 kernel 互相抢资源
Runtime异构 cache page、state cache、partial-block recoveryhit rate、recompute、SSD write amplification1M prefix 命中仍产生高 TTFT
3 KDA + 1 Gated MLA:重复 23 次的基本节拍
93 层由 69 个 KDA 层和 24 个 Gated MLA 层构成。KDA 用固定大小 recurrent state 表达长历史,MLA 保留随序列增长的 KV cache,二者的分配、分页、prefix hit 和跨节点迁移语义完全不同。
L1KDArecurrent state
L2KDArecurrent state
L3KDArecurrent state
L4Gated MLApaged KV
× 23 + tail
KDA STATE固定 / request
每序列保存一份大 recurrent state。prefill 需要 chunkwise scan,decode 是 state update;prefix cache 只在保存 state checkpoint 的边界可恢复。
MLA KV线性增长 / token
24 层 latent KV 随长度增长,可使用 PagedAttention。官方系统将 KDA state 与 MLA KV 装入统一 page pool,但 page type 与恢复语义不同。
对自研卡的最低要求- 高效的 associative scan / chunk scan,不能只靠通用 vector loop。
- recurrent state load-update-store 应在片上 SRAM 完成,避免每 token 反复写 HBM。
- 支持异构 page type、KDA checkpoint 和 MLA block 的原子引用计数与迁移。
Stable LatentMoE:通信维度下降,fan-out 上升
Hidden size 为 7168,LatentMoE routing/专家交换维度为 3584;896 routed experts 中每 token 激活 16 个,另有 2 个 shared experts。相比直接在 hidden 维度 dispatch,latent 表示降低单份 activation 大小,但 top-16 仍显著放大网络数据。
Hidden7168
projectLatent3584
route ×16Expert pool896MXFP4 W / MXFP8 A
combineHidden7168
以 1,024 tokens、EP8、MXFP8 activation 粗算单层跨卡流量\[2 \times 1024 \times 16 \times 3584 \times 1B \times (1 - 1/8) \approx 98 \mathrm{MiB}\]
这是 dispatch + combine 的逻辑上界近似;实际实现会受 token locality、packing、量化 scale 和网络协议影响。
如果 92 个 MoE 层都发生同等级交换,collective engine、NoC injection rate 和拓扑拥塞将直接决定 tokens/s。Kimi K3 特别适合用来检验算力卡是否真的为 MoE 设计,而不只是有一个高峰值 Tensor Core。
MXFP4 是架构能力,不是文件格式复选框
| 环节 | 模型语义 | 卡级要求 | 常见退化 |
|---|
| Expert weights | MXFP4,group size 32 | 原生 FP4 unpack / scale broadcast / dot product | 解到 BF16 后 GEMM,带宽优势丢失 |
| Expert activation | MXFP8 | 在线量化、UE8M0 scale、FP32/BF16 accumulate | 量化单独 kernel,增加 HBM round-trip |
| Shared experts / attention | 更高精度或不同路径 | 同一 fused block 支持 mixed dtype | shared/routed 两次 launch,额外同步 |
| Grouped GEMM | 动态 expert token count | ragged shape、零 token expert 快速跳过 | padding 到统一 M,浪费算力和 SRAM |
容量现实
官方仓库 blob 总量1,453.7 GiB不含 runtime KV / workspace / graph / fragmentation
8 × 192 GiB 总 HBM1,536 GiB只剩 82 GiB,扣除 runtime 后不可作为稳健配置
8 × 288 GiB 总 HBM2,304 GiB更合理的单节点级容量起点
官方 vLLM recipe 将 B300 作为默认硬件,并提供 H200/B200/B300/GB200/GB300/MI355X 等配置。部署到自研卡时,应优先保证 8 卡域内权重与 runtime state 可完全驻留;如果必须跨节点,expert placement 和 all-to-all fabric 需要成为系统设计中心。
Serving runtime 还需要理解 thinking history
Kimi K3 始终启用 thinking,并要求多轮对话把先前 assistant message 的 reasoning_content 与 tool_calls 原样带回。这会增加上下文增长速度,改变 prefix cache 命中和 admission control;不能只按用户可见 content 估算 session token。
容量规划要使用 wire-level token trace记录实际 chat template 后 token、图像 token、reasoning history、tool result 和上下文压缩事件。仅用业务输入字数会系统性低估 K3 的 KV 与 prefill 负载。
四层分析框架
01模型图layer type、active params、expert top-k、KV/state layout、speculation。
02请求形状ISL、OSL、batch、并发、图像 token、thinking token、prefix hit。
03执行策略chunked prefill、TP/EP/DP/CP、P/D 分离、量化、kernel fusion。
04硬件效率有效 TOPS、HBM BW、collective BW、launch latency、SRAM reuse。
参数路径计算下界
单次 forward 的一阶估算\[\mathrm{F\_}{\mathrm{param}} \approx 2 \cdot \mathrm{P\_}{\mathrm{active}} \cdot \mathrm{tokens}\]
矩阵乘一次乘加按 2 FLOPs。它不包含 attention score、Top-K、scan、router、vision、DSpark/MTP verify,也不代表实际执行效率。
| 模型 | Prefill 参数路径 | Decode 参数路径 | 解释 |
|---|
| V4.1 Flash | ≈16 GFLOP/token | ≈32 GFLOP/token | CED 使 prompt token 只激活 8B |
| V4 Pro | ≈98 GFLOP/token | ≈98 GFLOP/token | 未计 CSA/HCA 与 indexer |
| Kimi K3 | ≈208 GFLOP/token | ≈208 GFLOP/token | 未计 KDA scan/state 与 MLA |
Prefill:算力、SRAM 复用与长序列调度
Prefill 的 GEMM M 维约等于 token 数,矩阵阵列容易获得高利用率;但 1M context 不会作为一个 GEMM 一次执行。runtime 使用 chunked prefill,把请求切成固定 token budget,与 decode batch 混排。
架构师需要收集的 trace
- 每个 chunk 的 token 数与 padding 比例;
- 每层 GEMM 的 M/N/K 分布,而不是平均 shape;
- CSA candidate 数、Top-K、实际 gather cache-line utilization;
- KDA chunk size、scan depth、state bytes 与 SRAM residency;
- prefill 与 decode 混排时的队列等待和抢占成本。
Decode:先画 bandwidth roof,再画 compute roof
无 batch 复用时的保守带宽下界\[\mathrm{BW\_}{\mathrm{weights}} \ge \mathrm{W\_}{\mathrm{touched}/\mathrm{step}} \cdot \mathrm{system\_tokens\_per\_second}\]
MoE 的 Wtouched 取决于一个 step 内 expert union,而不是简单等于单 token active parameters。
Perf
Arithmetic intensity
DecodePrefillHBM boundCompute bound
| 优化 | 改变哪一项 | 副作用 |
|---|
| 增大 continuous batch | 提高同一权重 tile 的 token reuse | TPOT、KV 容量与 expert imbalance 上升 |
| FP4/MXFP4 权重 | 降低 HBM bytes / parameter | 需要 scale、unpack、QAT 兼容 kernel |
| Expert cache / placement | 提高本地权重命中 | 路由不均衡时需要迁移或复制 |
| Speculative decoding | 一次 target pass 验证多个 token | 接受率低时浪费计算并增加控制复杂度 |
以 accepted token 为最终归一化单位
开启 DSpark/MTP 后,“模型 forward token”和“用户得到的 token”不再相等。所有计数器都应同时提供 per step、per drafted token、per accepted token 三种归一化。
HBM B / accepted tok权重 + KV + workspaceFabric B / accepted tokTP reduce + EP all-to-allCycles / accepted tok含 rollback 与 bubbleJ / accepted tok板级能耗最终指标
完整容量方程
\[\mathrm{C\_}{\mathrm{usable}} \ge \mathrm{W\_}{\mathrm{resident}} + \mathrm{KV\_}{\mathrm{live}} + \mathrm{A\_}{\mathrm{workspace}} + \mathrm{B\_}{\mathrm{collective}} + \mathrm{G\_}{\mathrm{graphs}} + \mathrm{F\_}{\mathrm{fragmentation}}\]
早期规划至少预留总 HBM 的 12–20%;支持动态 shape、多个 graph bucket 或 multimodal 时取更高值。Resident weightscheckpoint 转换后的设备格式;含 scale、对齐、复制的 shared weights静态
Live KV / state请求长度 × 活跃序列;KDA state、SWA state、global KV 分开动态
Workspaceattention logits、Top-K、grouped GEMM、vision encoder、spec verifyshape 相关
Collective buffersTP all-reduce、EP dispatch/combine、P/D KV transfer staging拓扑相关
Runtimegraph capture、allocator metadata、page table、driver/context实现相关
四级存储不是“自动分层”
ON-CHIP SRAMµs 内反复使用的 tile / state最高带宽,编译器显式管理
HBM权重 shard + live KVdecode 性能屋顶
HOST DRAMEngram / warm prefix / stagingUVA 或 DMA;tail latency 敏感
NVMe / CACHE POOLcold prefix / checkpoint吞吐可高,随机延迟不可忽略
每一级迁移都必须由 runtime 的可观测状态驱动。仅把 tensor 标成 “offload” 会把平均延迟问题变成 P99 抖动问题。
互联流量的三种来源
| 并行 | 主要 collective | 消息特征 | 硬件优化点 |
|---|
| Tensor Parallel | all-reduce / reduce-scatter / all-gather | 每层、规则、对延迟敏感 | 片间 scale-up、collective offload、低延迟 barrier |
| Expert Parallel | all-to-all dispatch + combine | ragged、突发、路由不均衡 | 硬件 scatter/gather、credit flow、QoS、in-network reduction |
| P/D Disaggregation | KV/state transfer | 大块、单向、可 pipeline | RDMA、zero-copy、异构 TP re-layout |
Kimi K3 的 EP 是网络设计基准top-16 routed experts 即使使用 3584 latent dimension,也比 top-6 模型产生更大的 dispatch fan-out。网络必须同时保证高双向带宽、低小包延迟和热点 expert 的拥塞隔离。
卡级接口建议
HBM channels以 sustained bandwidth 而非 pin rate 建模;加入 bank conflict、read/write turnaround 与 ECC。
Scale-up links优先承载 TP 与 EP;支持 GPU/NPU direct load/store、RDMA atomic 和拓扑感知 routing。
PCIe / CXLEngram 与 KV offload 需要稳定 read bandwidth;page fault 式按需迁移通常不可控。
NIC跨节点 P/D transfer 与 DP;应支持多队列、GPUDirect/RDMA 等价能力和 congestion telemetry。
并行维度速查
TPTensor Parallel
切分单个矩阵。每层 collective,要求最高带宽和最低延迟;通常限制在单个 scale-up domain。
适合:dense/attention 必须切分EPExpert Parallel
专家按 rank 放置,token 动态 all-to-all。降低每卡 expert 容量,但引入路由与负载不均衡。
适合:V4 Pro / K3 大专家池DPData Parallel
复制 dense 权重,分摊请求。通信少、吞吐扩展好,但容量成本高;可与 EP 组合。
适合:多 replica servingPPPipeline Parallel
按层切分,减少单卡权重;在线 decode 容易产生 bubble,需 microbatch 与 continuous batching。
适合:跨节点容量扩展CPContext Parallel
按序列维度切 attention/state。长 prefill 有效;decode 需控制通信,K3 可用 DCP/A2A。
适合:1M prefillP/DPrefill / Decode 分离
两种负载独立扩缩、使用不同 TP/EP;代价是 KV/state 传输与 re-layout。
适合:CED 与长上下文服务
拓扑优先的 rank 布局
NODE 0 · SCALE-UP DOMAINCard 0Card 1Card 2Card 3
TP4 or EP4 · high-bandwidth links RDMA / scale-outNODE 1 · SCALE-UP DOMAINCard 4Card 5Card 6Card 7
PP stage / DP replica / extended EP - TP collective 不应无意跨越低带宽 NIC;
- EP expert placement 要结合真实路由共现矩阵,而不是轮询分配;
- shared expert、embedding、LM head 的复制成本要单独记账;
- 多 rail 网络需要 rank-to-NIC affinity,避免所有 all-to-all 落到同一 rail。
三个模型的起始映射
| 模型 | 单 replica 起点 | 扩展方向 | 风险 |
|---|
| V4.1 Flash | TP4;Engram host offload;GPU-resident KV | Blackwell 可试 TP2;高吞吐用 DP+EP | CSA2 backend、Engram tail、DSpark acceptance |
| V4 Pro | TP8,或 DP+EP8 | P/D 分离;多 replica DP | TP16 block shape、跨节点 TP latency |
| Kimi K3 | 8×大容量卡域,TP8 / TEP / DEP | DCP + P/D;必要时 PP 跨节点 | top-16 all-to-all、KDA state transfer、1.45 TiB 权重 |
这不是通用最佳配置,而是用于建立第一个可工作的 baseline。最终布局必须由目标卡容量、scale-up 拓扑和生产请求 trace 驱动。
参考卡级框图
HOST IFPCIe / CXL / DMA
CONTROLQueue + MMU + Scheduler
FABRICScale-up + RDMA
COHERENT / EXPLICIT-MEMORY NoC
MATRIX CLUSTERSBF16 · FP8 · MXFP8 · MXFP4dense GEMM / grouped GEMM / batched GEMMper-cluster scratchpad + async DMA
VECTOR / SFUNorm · RoPE · SiTU · Softmax
SPARSE ENGINETop-K · gather · index scan
SCAN ENGINEKDA recurrence · prefix state
COLLECTIVEreduce · all-to-all · re-layout
SHARED SRAM / LLCexpert tiles · KV pages · state
HBM CONTROLLERScapacity + sustained BW
数值数据通路
| 格式 | 必须支持的操作 | 累加 / scale | 受益负载 |
|---|
| BF16 | GEMM、vector、norm、residual | FP32 或 BF16 受控累加 | embedding/head、敏感路径、fallback |
| FP8 E4M3 | block-scaled GEMM、dynamic quant | UE8M0 / per-block scale | DeepSeek dense/shared、attention |
| MXFP8 | micro-scaling quant/dequant | scale broadcast 与 fused epilogue | Kimi K3 expert activation |
| MXFP4 / E2M1 | packed load、native dot、FP4 KV unpack | group 16/32 scale,避免中间展开 | 三模型 routed experts;V4.1 global KV |
| INT32 / FP32 | index、address、reduce、统计 | 精确控制路径 | Top-K、page table、router、counters |
微架构判断- 若 FP4 只能先解包到 BF16 SRAM,再送矩阵阵列,HBM 节省仍在,但 SRAM 容量和带宽可能翻倍;
- scale 应在 load pipeline 中广播并与 dot product 融合;
- grouped GEMM 需要硬件 work descriptor,不能每个 expert 由 host 单独 launch;
- 对 ragged M,阵列需支持细粒度 occupancy 或多 expert 并发填充。
片上存储应该缓存什么
Decode当前 layer 热 expert tileKDA recurrent state sliceSWA recent windowrouter/scale metadata
Prefillactivation tilesCSA index tilespartial sumsdouble-buffered weight blocks
Collectivedispatch stagingreduce-scatter fragmentscredit / routing tableKV re-layout buffer
专家权重总体不可能放入片上 SRAM,但 decode batch 内的 expert temporal locality 可以形成小型 victim cache。是否值得加入,要从 router trace 测量重复命中,而不是凭直觉。
按模型检查 primitive 覆盖
PrimitiveV4.1 FlashV4 ProKimi K3
MXFP4 grouped GEMM必需必需必需 / 极高压力
Block sparse attention + gatherCSA2CSA—
Top-K indexer512 + candidate1024router top-16
Associative scan——KDA 必需
Random embedding lookupEngram 必需——
Speculative verifyDSpark block-5MTP optionalruntime dependent
Vision encoder32-layer ViT—27-layer MoonViT-V2
建议的分层 IR
GRAPH IRCED / KDA / MLA / MoE / Vision保留模型语义与动态 shape
↓DISTRIBUTED TENSOR IRTP / EP / CP / P-D placementshard、collective、state ownership
↓TILE & MEMORY IRlayout / tiling / page / double bufferSRAM 生命周期与异步 DMA
↓KERNEL / ISA IRmatrix / vector / sparse / scan / collective设备命令与依赖事件
过早 lowering 会锁死优化空间如果在 graph import 阶段就把 KDA 展开成 elementwise loop,或把 MoE 展开成数百个独立 GEMM,后续无法恢复 scan、grouped GEMM、expert packing 和通信重叠语义。
Kernel 优先级
| P0 Kernel | 输入 shape 特征 | 融合边界 | 验收指标 |
|---|
| MXFP4 grouped MoE GEMM | ragged M;N/K 固定;expert 数 384/896 | quant + gate/up + activation + down + weighted combine | 有效 TFLOPS、padding%、HBM B/token |
| CSA/CSA2 sparse attention | Top-K 512/1024;irregular blocks | index score + top-k + gather + softmax + AV | gather utilization、Top-K cycles、cache miss |
| KDA prefill | 长 chunk、多 head、scan dependency | projection + recurrence + output gate | tokens/s、state spill、scan occupancy |
| KDA decode | M≈batch;固定 recurrent state | state read/update/write + gate | state residency、TPOT |
| mHC / AttnRes | 多 residual stream / block residual | norm + coefficient + combine | 额外 HBM round-trip 必须接近 0 |
| KV page / re-layout | 异构 block、不同 TP 度 | quant + pack + RDMA staging | GB/s、CPU involvement、P99 |
Runtime 与编译器的边界
COMPILE TIME确定不变的东西
- 权重 layout 与 shard 规则
- 层类型与静态融合
- 量化 group / scale 格式
- 最大 tile 与 SRAM plan 模板
RUNTIME处理变化的东西
- batch / token budget / sequence length
- expert routing 与 ragged packing
- KV page 分配与 prefix hit
- speculation acceptance / rollback
一个实用实现是预编译 shape bucket 与 kernel family,runtime 根据当前 token 数、expert histogram、cache 状态选择 variant,而不是 JIT 整张模型。
自研卡接入现有 serving engine
- Platform backend
设备枚举、allocator、stream/event、P2P、collective 与 graph capture 能力声明。
- Tensor / operator backend
PyTorch device 或独立 runtime;实现 dtype、storage、view、copy 与必要 fallback。
- Attention backend
Paged KV、CSA2/KDA/MLA 自定义 backend;暴露 block size 与 metadata builder。
- MoE backend
router、token permutation、grouped GEMM、combine;与 EP communicator 对接。
- Worker executor
rank 启动、模型加载、健康检查、profile run 与 memory snapshot。
- Model parser
chat template、reasoning/tool parser、multimodal processor 不能被遗漏。
九阶段闭环
01Artifact freeze模型 revision、文件 hash、tokenizer、remote code、license。
02GPU golden固定 vLLM/SGLang commit、容器 digest、启动参数、请求集。
03Weight converter读取 safetensors,重排 TP/EP shard,验证 MXFP4/FP8 scale。
04Op reference为 CSA2、KDA、MoE、mHC/AttnRes 建立高精度参考。
05Kernel bring-up单 kernel 数值、边界 shape、性能屋顶和计数器。
06Single layer完整 block 对齐 hidden、KV/state、router 与 expert output。
07Single card/rank小 checkpoint 或切片执行;验证 runtime、page allocator、graph。
08DistributedTP/EP/CP collective、拓扑映射、fault/timeout。
09Servingcontinuous batch、prefix cache、tool/reasoning parser、P99 与 soak。
Artifact contract
model_bundle/
├── manifest.json # revision, hashes, license, source URLs
├── config.json # 原始配置,不在转换时“顺手修改”
├── tokenizer/ # vocab, merges, chat template
├── processor/ # vision / multimodal preprocessing
├── weights.index.json # tensor → source shard
├── device_weights/ # layout + TP/EP placement + scales
├── graph_manifest.json # layer types, custom ops, state schema
└── validation/
├── golden_inputs.npz
├── golden_intermediates.npz
└── tolerances.yaml
converter 必须可重复、可版本化、可逆向追踪:设备 tensor 的每一段都能映射回原始 safetensors key 和量化 scale。
先建立 GPU baseline
版本策略这些新架构通常依赖 vLLM/SGLang nightly 或特定分支。生产 baseline 要记录 Git SHA、容器 digest、driver/firmware、kernel backend 和生成后的完整命令;“latest” 不能成为验收环境。
逐层数值验证
Tensor formatbit exact pack/unpack
→PrimitiveGEMM / top-k / scan
→Fused kerneldtype-aware tolerance
→Transformer blockhidden + cache/state
→Logitstoken rank agreement
→Generationfixed seed / greedy
| 对象 | 比较方法 | 注意事项 |
|---|
| FP4/FP8 GEMM | 反量化参考 + ULP/relative error | scale round、saturation、subnormal |
| Router Top-K | indices bit-exact,weights tolerance | tie-break 顺序必须固定 |
| KDA state | 每 chunk checkpoint 比较 | 误差会随序列累计 |
| KV cache | page content + logical token mapping | prefix reuse / COW / eviction |
| Spec decode | 关闭 speculation 对照 | 接受路径必须与 target logits 一致 |
完成定义
- 目标模型 revision 的完整权重可加载,不依赖未记录的 host fallback;
- 至少覆盖 greedy、thinking、tool call、多轮、长上下文和多模态(适用时);
- 固定 workload 下 token 输出与 golden 满足定义的数值准则;
- 每个主要 kernel 有 roofline 与硬件计数器解释,性能差距可归因;
- OOM、collective timeout、坏页、设备 reset 有明确错误路径;
- 连续 24–72 小时 soak 无泄漏、无 page corruption、无 silent hang。
建议的硬件计数器
MATRIX- active / issued cycles
- dtype × shape histogram
- tile padding / bubble
- accumulator stall
MEMORY- HBM read/write bytes
- channel / bank conflict
- SRAM hit / spill
- DMA overlap ratio
SPARSE / MoE- expert token histogram
- Top-K cycles
- gather useful bytes
- zero-token expert skip
FABRIC- per-link bytes / stall
- collective latency
- all-to-all imbalance
- credit starvation
RUNTIME- queue depth / idle gap
- page alloc / eviction
- graph miss / recapture
- preemption / recompute
SPECULATION- draft length
- accepted length
- rollback tokens
- verify utilization
性能分解模板
Useful math54%
HBM stall18%
Collective12%
Padding / imbalance9%
Launch / scheduler7%
上图是格式示例,不是任何目标模型的实测值。实际报告应按 prefill、decode、vision、cache-hit/miss 分组,并同时给均值和 P99。
必须覆盖的异常路径
Expert overload单 rank token 超限、reroute、drop、backpressure
KV exhaustionpreemption、recompute、CPU/NVMe spill、admission reject
Collective timeoutrank failure、link degradation、partial completion
Quantization edgeNaN/Inf、scale saturation、all-zero block、tie-breaking
Long-run stateKDA state drift、page UAF、prefix hash collision、COW corruption
Multimodal extremes极端宽高比、多图、空图、视觉 token 上限