MoE 模型推理科普:为什么总参数 26B 反而比 14B 稠密模型快

你在模型下载站经常看到 Qwen3-30B-A3BGemma-4-26B-A4B 这种「双数字」命名,前面的数字很大、后面带个 A 的很小。这就是 MoE(Mixture of Experts,混合专家)架构。这篇讲透:为什么它总参数那么大、跑起来反而快,以及它和核显/纯 CPU 用户的缘分。

稠密模型的问题:每次都要搬全部权重

传统稠密模型(如 Qwen3-14B)推理时,每一个 token 都要读一遍全部 14B 参数。大模型的生成瓶颈基本是内存带宽:算得快不重要,把权重从内存搬到计算单元的速度才是上限。所以稠密模型越大,每个 token 越慢。

MoE 的思路:每次只搬一小部分

MoE 把模型拆成一个路由器 + 一大堆专家(expert)。每次生成 token 时,路由器只挑其中一部分专家干活。于是激活参数(active params)= 实际参与计算的专家规模(如 4B);总参数= 所有专家的总和(如 26B,30 层 × 128 routed experts + 1 shared)。

生成时内存带宽只按激活参数算账,所以 MoE 生成快得多。实测对比(本机纯 CPU,详见纯 CPU 实测):

生成速度 tok/s(纯 CPU 6 线程 Q4)
LFM2-24B-A2B15.5
Qwen3-30B-A3B11.4
Gemma-4-26B9.6
Qwen3-14B(稠密)3.6

激活 2~4B 的 MoE 比稠密 14B 快 2~4 倍。这也是核显 / 纯 CPU 用户最关心的一点——MoE 是没独显机器的版本答案

三个反直觉的真相

1. 总参数大 ≠ 跑得慢,但加载/prefill 要吃全量

生成只看激活参数,但权重文件还是全部专家的总和(26B 的 Q4 文件约 15.6GB)。加载模型、以及 prefill(解析长提示词)都要读全部权重。所以 30B-A3B 别想在 8G 内存机上跑——文件就放不下。

2. 核显友好:小激活 = 小搬运量

核显共享系统内存,带宽本来就有限。MoE 激活参数小,每个 token 搬运量小,正好对路。实测 Gemma-4-E4B 在 Intel 核显上 Vulkan 生成 20.3 t/s,与 26B(21.4)几乎打平——激活参数量级相近,速度就相近(详见E4B vs 26B)。

3. llama.cpp 按层整层分配,专家不能拆开

有个常见的误解:以为可以把「被激活的专家放 GPU、没激活的放 CPU」。实测(--n-cpu-moe)说明 llama.cpp 按整层分配权重,专家张量位置加载时固定。且开 --n-cpu-moe 有固定同步开销,生成降速 ~30%,Intel 核显上尤其明显。

MoE 的代价

  • 显存/内存占用大:总参数摆在那,文件体积是稠密同级的 2~3 倍
  • prefill 没有速度优势:读全部权重,长提示词场景反而慢
  • 小模型上质量略糙:专家路由在小参数下偶尔不稳定(可见小模型 tool-calling

怎么读模型命名

命名总参数激活参数含义
Gemma-4-26B-A4B25.23 B~4 BMoE:总 26B,每 token 激活 4B
Qwen3-30B-A3B30 B~3 BMoE:总 30B,激活 3B
Qwen3-14B14 B14 B稠密:全部参数都激活

选型口诀:看激活参数选速度,看总参数选内存。A 后面的数字决定生成速度档次,总参数决定你的机器放不放得下。

结论:MoE 用「文件大、激活小」换速度,是带宽受限场景(纯 CPU、核显)的首选。想跑大模型又没独显,认准带 A 的 MoE 型号就对了。

On model sites you'll see names like Qwen3-30B-A3B or Gemma-4-26B-A4B — a big number and a small one after 'A'. That's MoE (Mixture of Experts). This post explains: why such models have huge total params yet run faster, and why they're a gift for iGPU/CPU users.

The dense problem: every token moves all weights

A traditional dense model (e.g. Qwen3-14B) reads all 14B parameters for every single token. LLM generation is essentially memory-bandwidth-bound: compute speed matters less than how fast weights stream from RAM to the compute unit. Bigger dense model → slower per token.

The MoE idea: move only a slice

MoE splits the model into a router + a pool of experts. For each token, the router picks only a subset of experts to run. Hence active params = the experts actually computing (e.g. 4B) while total params = all experts combined (e.g. 26B: 30 layers × 128 routed + 1 shared).

Decode bandwidth only pays for active params, so MoE decodes much faster. Measured on pure CPU (see CPU-only tests):

Decode tok/s (pure CPU, 6 threads, Q4)
LFM2-24B-A2B15.5
Qwen3-30B-A3B11.4
Gemma-4-26B9.6
Qwen3-14B(稠密)3.6

MoE with 2-4B active beats dense 14B by 2-4×. That's the headline for iGPU/CPU users — MoE is the no-dGPU answer.

Three counter-intuitive truths

1. Big total params ≠ slow, but loading/prefill reads all of them

Decode only counts active params, but the weight file is still all experts combined (a 26B Q4 is ~15.6GB). Loading the model, and prefill (parsing a long prompt), read all weights. So don't try a 30B-A3B on an 8GB machine — the file alone won't fit.

2. iGPU-friendly: small active = small data movement

An iGPU shares system RAM with limited bandwidth. MoE's small active set means less data moved per token — a perfect fit. Measured: Gemma-4-E4B hits 20.3 t/s on an Intel iGPU (Vulkan), nearly tied with the 26B (21.4) — comparable active params give comparable speed (see E4B vs 26B).

3. llama.cpp assigns by layer; experts can't be split

A common myth: 'put active experts on GPU, idle ones on CPU'. Measurements with --n-cpu-moe show llama.cpp assigns weights per layer; expert tensor placement is fixed at load. Enabling --n-cpu-moe also adds a fixed sync cost, cutting decode ~30% — worse on Intel iGPUs.

The cost of MoE

  • Heavy memory footprint: total params mean files 2-3× a dense model of the same class
  • No prefill advantage: reads all weights; long prompts are actually slower
  • Quality can be rougher at small scale: routing gets unstable under a few hundred MB (see small-model tool-calling)

How to read the naming

NameTotal paramsActive paramsMeaning
Gemma-4-26B-A4B25.23 B~4 BMoE: 26B total, ~4B active per token
Qwen3-30B-A3B30 B~3 BMoE: 30B total, 3B active
Qwen3-14B14 B14 Bdense: all params active

Rule of thumb: active params → speed, total params → memory. The number after 'A' sets decode class; the total decides whether your machine can hold it.

Bottom line:MoE trades 'big file, small active' for speed — the top choice for bandwidth-limited setups (CPU-only, iGPU). No dGPU? Look for the 'A' models.
返回文章列表