Why a 30B MoE takes 30B of VRAM, streams like a 3B model, and slows down as chats pile up
A 30-billion-parameter Mixture-of-Experts (MoE) model such as Qwen3-30B-A3B activates only 3.3 billion parameters per token. That single sentence trips up GPU sizing in two opposite ways: buying too little VRAM because you sized for 3B instead of 30B, or promising single-chat speeds to 16 concurrent users without counting how fast dormant experts wake up. By the end of this guide you can:
- Compute total parameters, active parameters, and BF16 KV cache per token straight from a model's config.json for dense and Mixture-of-Experts (MoE) transformers.
- Derive how many unique experts wake up at batch size B with E * (1 - (1 - k / E)^B), verify it against 20,000 Monte Carlo draws, and find the exact chat count where a 7B dense model overtakes a 30B MoE on one 24 GiB GPU.
- Separate decode memory reads from per-token compute on long-prompt prefill, skewed routing, and looped MoE models such as Inkling 2 Mini.
You need Python 3.12 or newer. No GPU, no API key, no network, and no packages to install.

B = 1) at Q4_0: Qwen2.5-32B stores 17.16 GiB (rounded to 17.2 GiB) and streams 31.98B weights per token, while Qwen3-30B-A3B stores all 128 experts per layer in 15.99 GiB (16.0 GiB) yet streams only 8 routed experts plus shared layers (3.04B weights). Schematic grid; exact 128-tile counts across batch sizes are plotted below.Before you start
You should know Python dataclasses, loops, and basic probability, plus the KV cache, quantization, and bandwidth ceiling formulas from our earlier serving guides. If any piece feels rusty, open these first. The first three links open a Topic Breakdown roadmap (sign in to generate one), and the rest open public guides here.
- Feedforward (MLP) layers vs attention layers in transformers. MoE splits each layer's feedforward network into routed experts while keeping attention shared.
- Top-k softmax routing and load balancing in Mixture of Experts. Each token picks k experts per layer, and balanced routers spread batches across the full pool.
- Linearity of expectation in probability. Expected active experts sum the chance that each expert is picked by at least one token in the batch.
- Will 32 chats fit on one GPU? Size the KV cache in Python. Where 56 KiB, 96 KiB, and 256 KiB of BF16 KV cache per token come from.
- Will 8-bit weights fit 32 chats on one GPU? Size 16, 8 and 4-bit in Python. Why Q4_0 uses 18 bytes per 32 weights (0.5625 bytes per parameter) on a 24 GiB card.
- You fit 32 chats on one GPU. How fast will each one decode? Estimate it in Python. The memory-bandwidth ceiling formula and the 1,000 GB/s reference card reused here.
- A long prompt makes your chat wait before the first word. Why? Size prefill and decode in Python. Why decode is memory bound at small batch while an 8,192-token prefill turns compute bound.
The question
You have one 24 GiB GPU for a local team server or one 80 GiB GPU in production. Should you deploy Qwen3-30B-A3B (30.5B total, 3.3B active), Mixtral-8x7B (46.7B total, 12.9B active), a dense Qwen2.5-32B, or a dense Qwen2.5-7B? How many 4,096-token chats actually fit alongside the weights, how fast does each chat stream at B = 1 versus B = 16, and what changes in a looped MoE like Inkling 2 Mini?
| Model | Total | B=1 read | Q4_0 VRAM | BF16 KV/tok | 4K chats (24 GiB) | B=1 tok/s | B=8 tok/s/chat |
|---|---|---|---|---|---|---|---|
| Qwen2.5-7B (dense) | 7.62B | 7.07B | 3.99 GiB | 56 KiB | 82 | 244.2 | 203.4 |
| Qwen3-30B-A3B (128E top-8) | 30.53B | 3.04B | 15.99 GiB | 96 KiB | 16 | 522.9 | 112.6 |
| Qwen2.5-32B (dense) | 32.76B | 31.98B | 17.16 GiB | 256 KiB | 4 | n/a (BF16 in Step 5) | n/a (4 chats fit) |
| Mixtral-8x7B (8E top-2) | 46.70B | 12.75B | 24.47 GiB | 128 KiB | 0 | does not fit | does not fit |
All rows come from moe_sizing.py below (24 GiB card with 22.00 GiB usable, 1,000 GB/s bandwidth ceiling, 2,048-token cache in the speed columns).
Five words we use
- Total parameters
- Every weight stored in VRAM across embeddings, shared attention, routers, and all E experts in every layer. VRAM is paid up front on total parameters because any token might route to any expert.
- Active parameters
- The weights a single token multiplies on one pass: shared attention, routers, the output head, and the top-k chosen experts per layer. Model cards also count input embeddings; decode looks up one token row instead.
- Router (gate)
- A small hidden_size by E matrix in each MoE layer that scores all E experts for the current token and selects the top k.
- Unique active experts
- The union of experts woken by at least one chat in a batched decode step. Under uniform top-k routing without replacement, the expected count is E * (1 - (1 - k / E)^B).
- Looped MoE
- A transformer that reuses one block of stored layers for multiple sequential passes per token, such as Inkling 2 Mini running its middle 12 layers 3 times. Stored VRAM stays tied to unique layers while per-token reads multiply with passes.
Worked example
Follow one calculation from config.json dimensions to VRAM chat limits, the batch expert wake-up curve, the 24 GiB crossover against a 7B dense model, 80 GiB BF16 decode versus prefill, and skewed or looped MoE variants.
Read total vs active parameters and KV cache from config.json
Open the Hugging Face config.json files for four reference models: Qwen2.5-7B-Instruct (dense), Qwen3-30B-A3B (128 experts, top-8), Qwen2.5-32B-Instruct (dense), and Mixtral-8x7B-v0.1 (8 experts, top-2). Every SwiGLU feedforward expert holds 3 matrices of hidden_size by intermediate_size. For Qwen3-30B-A3B across 48 layers, one expert across all layers holds 48 * 3 * 2048 * 768 = 226.49M weights, so all 128 experts hold 28.99B weights while 8 active experts hold 1.81B. Adding shared GQA attention (0.91B), routers (0.01B), and embeddings plus lm_head (0.62B) gives 30.53B total parameters and 3.35B model-card active parameters (matching 30.5B and 3.3B on the Qwen3 README). During decode, input embedding looks up one row instead of reading the whole table, so B = 1 reads 3.04B weight parameters.
Notice the KV cache column too. Because attention is shared and never duplicated per expert, Qwen3-30B-A3B with 48 layers and 4 KV heads needs 2 * 48 * 4 * 128 * 2 = 96 KiB per token in BF16, versus 256 KiB per token on Qwen2.5-32B (64 layers, 8 KV heads) and 128 KiB per token on Mixtral-8x7B.
Fit weights and 4,096-token chats on one 24 GiB GPU at Q4_0
Use llama.cpp's Q4_0 block size from the quantization guide (18 bytes per 32 weights = 0.5625 bytes per weight) and keep 2.00 GiB of the 24 GiB card for runtime buffers and activations, leaving 22.00 GiB usable. Mixtral-8x7B needs 24.47 GiB for weights alone and fits 0 chats without offloading experts to system RAM. Qwen2.5-32B fits its 17.16 GiB weights, leaving 4.84 GiB, which holds only 4 chats of 4,096 tokens because each chat takes 1,024 MiB of KV cache. Qwen3-30B-A3B uses 15.99 GiB for weights, leaves 6.01 GiB, and fits 16 concurrent 4,096-token chats (384 MiB of KV cache per chat). Qwen2.5-7B uses 3.99 GiB for weights and fits 82 chats.
Count how many dormant experts wake up at batch size B
Suppose B concurrent chats each route one token independently and uniformly across E experts without replacement (k distinct experts per token). One chat misses a given expert with probability 1 - k / E. Across B independent chats, every chat misses that expert with probability (1 - k / E)^B, so the expert wakes up with probability 1 - (1 - k / E)^B. By linearity of expectation, the expected number of unique experts read from VRAM in that step is E * (1 - (1 - k / E)^B), even though the k choices within each token are dependent.
Step 3 checks that exact formula against 20,000 Monte Carlo draws with random.Random(42), and the two match to two decimal places. Coarse 8-expert Mixtral-8x7B saturates almost immediately: B = 1 reads 2.00/8 experts (25.0%, 12.75B params), B = 4 reads 5.47/8 (68.4%, 32.30B), and B = 8 reads 7.20/8 (90.0%, 42.06B). Fine-grained 128-expert Qwen3-30B-A3B stays sparse longer, yet still climbs steeply: B = 1 reads 8.00/128 (6.2%, 3.04B), B = 4 reads 29.12/128 (22.8%, 7.83B), B = 8 reads 51.62/128 (40.3%, 12.92B), B = 16 reads 82.42/128 (64.4%, 19.90B), B = 32 reads 111.77/128 (87.3%, 26.55B), and B = 64 reads 125.94/128 (98.4%, 29.75B).
Watch a 7B dense model overtake a 30B MoE on one 24 GiB card
Put Qwen3-30B-A3B and Qwen2.5-7B on the same 24 GiB reference card (1,000 GB/s memory bandwidth, 100 TFLOPS, Q4_0 weights, 2,048 tokens in each chat's KV cache). At B = 1 chat, Qwen3-30B-A3B reads 3.04B weight parameters plus one 192 MiB cache, giving a 522.9 tok/s theoretical ceiling versus 244.2 tok/s for Qwen2.5-7B. By B = 4 concurrent chats, Qwen3-30B-A3B wakes 29.12 experts per layer (7.83B weight parameters), so its per-chat ceiling drops to 192.0 tok/s while Qwen2.5-7B still reads its fixed 7.07B decode weights once and delivers 224.9 tok/s per chat. By B = 16 chats, Qwen3-30B-A3B falls to 69.4 tok/s per chat (1,110 total) versus 170.8 tok/s per chat (2,732 total) on 7B dense.
Check that single-chat ceiling against a third-party RTX 4090 (1,008 GB/s) llama.cpp summary reported by RunAIHome: Qwen3-30B-A3B reaches about 120 to 196 tok/s (23% to 37% of its 527.1 tok/s ceiling), whereas a 7B dense model reaches about 135 tok/s (55% of its 246.2 tok/s ceiling). Gathering 8 non-contiguous expert slices at each of 48 layers achieves a lower share of peak memory bandwidth than streaming one contiguous dense matrix, so in real local runs the 7B dense crossover can happen even earlier than B = 4.
Compare equal-size 30B MoE vs 32B dense on an 80 GiB card
What if you compare models of similar total parameter count in BF16 on an 80 GiB server GPU (2,000 GB/s, 300 TFLOPS, 2,048 tokens per chat)? At B = 1, Qwen3-30B-A3B has a 10.26x higher decode ceiling than Qwen2.5-32B (318.2 vs 31.0 tok/s/chat). As chats pile up and dormant experts wake, that decode advantage compresses to 4.02x at B = 4 (121.5 vs 30.2), 2.49x at B = 8 (72.9 vs 29.3), and 1.36x at B = 32 (33.6 vs 24.6) and B = 64 (27.6 vs 20.3). At B = 128, Qwen3-30B-A3B widens back slightly to 1.54x (23.2 vs 15.1 tok/s/chat) because its 4-head GQA KV cache is 96 KiB/tok instead of 256 KiB/tok.
Price one 8,192-token prompt prefill on the 80 GiB card
Switch from single-token decode to prefilling one 8,192-token prompt on that same 80 GiB, 300 TFLOPS card. Both models read almost all stored weights once (30.2 ms for Qwen3-30B-A3B and 32.0 ms for Qwen2.5-32B), so prefill is compute bound. Because each prompt token still multiplies only 8 experts in Qwen3-30B-A3B, its compute floor is 166.1 ms versus 1,746.8 ms for Qwen2.5-32B, a 10.52x speedup that does not fade even when every expert is loaded.
Check skewed routing and looped MoE passes (Inkling 2 Mini)
Real batch traffic is not purely uniform. Step 7 compares uniform routing at B = 16 against a Zipf s = 0.9 distribution water-filled so probabilities sum to 8. Skewed tokens cluster on popular experts, waking only 58.3/128 unique experts instead of 82.4/128 (saving memory reads), while slamming the busiest expert with all 16.0 of 16 tokens instead of the 1.0-token uniform mean. That tension explains why Switch Transformer (arXiv:2101.03961) and DeepSeek-V3 (arXiv:2412.19437) enforce load balancing: balanced routers cost more memory reads at medium batch so no single expert becomes a compute bottleneck at large batch.
Finally, check Thinking Machines' Inkling 2 Mini (released 20 November 2026). Its config.json stores 24 MoE layers (128 experts, top-8, intermediate_size 1152), giving 24.92B non-embedding block parameters (26.4B total with vocabulary layers on the model card) and 1.99B unique active block parameters across those 24 layers (3.4B on the card). However, loop_config runs the middle 12 layers (6 through 17) 3 times sequentially per token, executing 48 layer passes. That adds +1.99B extra block parameter activations per token (3.98B non-embedding, matching 5.4B effective active parameters on the model card) and doubles KV cache from 96 KiB/tok for 24 passes to 192 KiB/tok across all 48 passes. Size VRAM from stored layers, and size single-chat decode time from executed passes.
Run it yourself
Save the script below as moe_sizing.py. The output shown here was captured on 23 November 2026 on Windows with Python 3.12.16. It uses only the Python standard library (dataclasses and random), needs no GPU or API key, and finishes in about a second.
To test your own hardware, edit BW_24G_GBPS, TFLOPS_24G, or usable_bytes. To test another MoE or dense checkpoint, add a ModelSpec row from its Hugging Face config.json.
"""Size MoE vs dense LLM VRAM, active experts, and batch decode speed.
Standard library Python only. No GPU, no API key, no network.
Model dimensions read from Hugging Face config.json files on 23 November 2026.
"""
from dataclasses import dataclass
import random
GIB = 1024**3
MIB = 1024**2
KIB = 1024
# Reference cards chosen for comparison (same 24 GiB card as earlier serving guides,
# plus one 80 GiB server card for full-precision BF16).
BW_24G_GBPS = 1000.0
TFLOPS_24G = 100.0
BW_80G_GBPS = 2000.0
TFLOPS_80G = 300.0
# ggml block_q4_0: 16 bytes of 4-bit nibbles + 2-byte fp16 scale per 32 weights.
Q4_0_BYTES = 18.0 / 32.0
BF16_BYTES = 2.0
@dataclass(frozen=True)
class ModelSpec:
name: str
vocab_size: int
hidden_size: int
num_layers: int
num_q_heads: int
num_kv_heads: int
head_dim: int
intermediate_size: int
num_experts: int
top_k: int
@property
def embed_and_head_params(self) -> int:
return 2 * self.vocab_size * self.hidden_size
@property
def lm_head_params(self) -> int:
# Decode looks up 1 input token row (negligible) and multiplies lm_head once.
return self.vocab_size * self.hidden_size
@property
def attn_params(self) -> int:
q_dim = self.num_q_heads * self.head_dim
kv_dim = self.num_kv_heads * self.head_dim
per_layer = self.hidden_size * (q_dim + 2 * kv_dim) + q_dim * self.hidden_size
return self.num_layers * per_layer
@property
def router_params(self) -> int:
if self.num_experts <= 1:
return 0
return self.num_layers * self.hidden_size * self.num_experts
@property
def one_expert_all_layers(self) -> int:
return self.num_layers * 3 * self.hidden_size * self.intermediate_size
@property
def total_params(self) -> int:
return (
self.embed_and_head_params
+ self.attn_params
+ self.router_params
+ self.num_experts * self.one_expert_all_layers
)
@property
def active_card_params(self) -> int:
return (
self.embed_and_head_params
+ self.attn_params
+ self.router_params
+ self.top_k * self.one_expert_all_layers
)
@property
def active_decode_params(self) -> int:
return (
self.lm_head_params
+ self.attn_params
+ self.router_params
+ self.top_k * self.one_expert_all_layers
)
@property
def kv_bytes_per_token(self) -> int:
return 2 * self.num_layers * self.num_kv_heads * self.head_dim * 2
def unique_experts(self, batch_tokens: int) -> float:
if self.num_experts <= 1:
return 1.0
return self.num_experts * (1.0 - (1.0 - self.top_k / self.num_experts) ** batch_tokens)
def weights_read_params(self, batch_tokens: int) -> float:
return (
self.lm_head_params
+ self.attn_params
+ self.router_params
+ self.unique_experts(batch_tokens) * self.one_expert_all_layers
)
QWEN_7B = ModelSpec("Qwen2.5-7B (dense)", 152064, 3584, 28, 28, 4, 128, 18944, 1, 1)
QWEN3_30B_A3B = ModelSpec("Qwen3-30B-A3B (128E top-8)", 151936, 2048, 48, 32, 4, 128, 768, 128, 8)
QWEN_32B = ModelSpec("Qwen2.5-32B (dense)", 152064, 5120, 64, 40, 8, 128, 27648, 1, 1)
MIXTRAL_8X7B = ModelSpec("Mixtral-8x7B (8E top-2)", 32000, 4096, 32, 32, 8, 128, 14336, 8, 2)
def decode_step(
model: ModelSpec,
chats: int,
ctx_tokens: int,
bytes_per_param: float,
bw_gbps: float,
tflops: float,
) -> tuple[float, float, float, str]:
weight_bytes = model.weights_read_params(chats) * bytes_per_param
kv_bytes = chats * ctx_tokens * model.kv_bytes_per_token
mem_s = (weight_bytes + kv_bytes) / (bw_gbps * 1e9)
comp_s = (chats * 2.0 * model.active_decode_params) / (tflops * 1e12)
step_s = max(mem_s, comp_s)
bound = "compute" if comp_s > mem_s else "memory"
return step_s, mem_s, comp_s, bound
def main() -> None:
models = (QWEN_7B, QWEN3_30B_A3B, QWEN_32B, MIXTRAL_8X7B)
print("Step 1 total vs active parameters and BF16 KV cache per token (from config.json)")
for m in models:
bf16_gib = m.total_params * BF16_BYTES / GIB
q4_gib = m.total_params * Q4_0_BYTES / GIB
kv_kib = m.kv_bytes_per_token // KIB
print(
f" {m.name:26s} | total {m.total_params/1e9:5.2f}B | card active {m.active_card_params/1e9:5.2f}B"
f" | B=1 read {m.active_decode_params/1e9:5.2f}B | BF16 {bf16_gib:5.1f} GiB"
f" | Q4_0 {q4_gib:5.2f} GiB | KV {kv_kib:3d} KiB/tok"
)
print("\nStep 2 fit on one 24 GiB GPU at Q4_0 (2.00 GiB reserved for runtime, 4,096 tokens/chat)")
usable_bytes = int(22.0 * GIB)
ctx_fit = 4096
for m in models:
w_bytes = int(m.total_params * Q4_0_BYTES)
leftover = usable_bytes - w_bytes
chat_kv = ctx_fit * m.kv_bytes_per_token
max_chats = max(0, leftover // chat_kv)
print(
f" {m.name:26s} | weights {w_bytes/GIB:5.2f} GiB | room left {leftover/GIB:6.2f} GiB"
f" | KV/chat {chat_kv//MIB:4d} MiB | max 4K chats: {max_chats:2d}"
)
print("\nStep 3 unique experts woken per decode step: formula vs 20,000 Monte Carlo trials (seed 42)")
rng = random.Random(42)
for m in (MIXTRAL_8X7B, QWEN3_30B_A3B):
print(f" {m.name}:")
for b in (1, 2, 4, 8, 16, 32, 64):
exact = m.unique_experts(b)
trials = 20000
woken_sum = 0
for _ in range(trials):
seen = set()
for _ in range(b):
seen.update(rng.sample(range(m.num_experts), m.top_k))
woken_sum += len(seen)
mc = woken_sum / trials
pct = 100.0 * exact / m.num_experts
read_b = m.weights_read_params(b) / 1e9
print(
f" B={b:2d} | formula {exact:6.2f}/{m.num_experts:3d} ({pct:5.1f}%)"
f" | Monte Carlo {mc:6.2f} | weight params read {read_b:5.2f}B"
)
print("\nStep 4 24 GiB card crossover (1,000 GB/s, 100 TFLOPS, Q4_0, 2,048 tokens/chat)")
for b in (1, 4, 8, 16):
s_moe, _, _, b_moe = decode_step(QWEN3_30B_A3B, b, 2048, Q4_0_BYTES, BW_24G_GBPS, TFLOPS_24G)
s_7b, _, _, b_7b = decode_step(QWEN_7B, b, 2048, Q4_0_BYTES, BW_24G_GBPS, TFLOPS_24G)
moe_chat = 1.0 / s_moe
dense_chat = 1.0 / s_7b
print(
f" B={b:2d} chats | 30B-A3B MoE: {moe_chat:5.1f} tok/s/chat ({b*moe_chat:5.0f} total, {b_moe})"
f" | 7B Dense: {dense_chat:5.1f} tok/s/chat ({b*dense_chat:5.0f} total, {b_7b})"
)
# Community RTX 4090 (1,008 GB/s) single-chat llama.cpp check vs 1,008 GB/s ceiling:
s_4090_moe, _, _, _ = decode_step(QWEN3_30B_A3B, 1, 2048, Q4_0_BYTES, 1008.0, TFLOPS_24G)
s_4090_7b, _, _, _ = decode_step(QWEN_7B, 1, 2048, Q4_0_BYTES, 1008.0, TFLOPS_24G)
ceil_moe = 1.0 / s_4090_moe
ceil_7b = 1.0 / s_4090_7b
print(
f" RTX 4090 (1,008 GB/s) B=1 ceiling: 30B-A3B {ceil_moe:.1f} tok/s (measured 120 to 196, "
f"{100*120/ceil_moe:.0f}% to {100*196/ceil_moe:.0f}%) | 7B {ceil_7b:.1f} tok/s (measured 135, {100*135/ceil_7b:.0f}%)"
)
print("\nStep 5 equal-size showdown on 80 GiB card (2,000 GB/s, 300 TFLOPS, BF16, 2,048 tokens/chat)")
for b in (1, 4, 8, 16, 32, 64, 128):
s_moe, _, _, b_moe = decode_step(QWEN3_30B_A3B, b, 2048, BF16_BYTES, BW_80G_GBPS, TFLOPS_80G)
s_32b, _, _, b_32b = decode_step(QWEN_32B, b, 2048, BF16_BYTES, BW_80G_GBPS, TFLOPS_80G)
c_moe = 1.0 / s_moe
c_32b = 1.0 / s_32b
print(
f" B={b:3d} | 30B-A3B MoE: {c_moe:5.1f} tok/s/chat ({b*c_moe:5.0f} total, {b_moe:7s})"
f" | 32B Dense: {c_32b:4.1f} tok/s/chat ({b*c_32b:4.0f} total, {b_32b:7s})"
f" | MoE/Dense {c_moe/c_32b:5.2f}x"
)
prompt_toks = 8192
print(f"\nStep 6 prefill floor for one {prompt_toks:,}-token prompt on 80 GiB card (BF16, 300 TFLOPS)")
for m in (QWEN3_30B_A3B, QWEN_32B):
w_bytes = m.weights_read_params(prompt_toks) * BF16_BYTES
mem_ms = 1000.0 * w_bytes / (BW_80G_GBPS * 1e9)
comp_ms = 1000.0 * (2.0 * prompt_toks * m.active_decode_params) / (TFLOPS_80G * 1e12)
floor_ms = max(mem_ms, comp_ms)
bound = "compute" if comp_ms > mem_ms else "memory"
print(f" {m.name:26s} | memory {mem_ms:6.1f} ms | compute {comp_ms:6.1f} ms | floor {floor_ms:6.1f} ms ({bound})")
print("\nStep 7 skewed routing (Zipf s=0.9, sum=8) at B=16 and looped MoE passes (Inkling 2 Mini)")
raw = [1.0 / ((i + 1) ** 0.9) for i in range(128)]
lo, hi = 0.0, 100.0
for _ in range(60):
mid = 0.5 * (lo + hi)
lo, hi = (mid, hi) if sum(min(1.0, mid * w) for w in raw) < 8.0 else (lo, mid)
probs = [min(1.0, hi * w) for w in raw]
skew_u = sum(1.0 - (1.0 - p) ** 16 for p in probs)
unif_u = QWEN3_30B_A3B.unique_experts(16)
mean_tok = 16 * 8 / 128
hot_tok = 16 * max(probs)
print(f" Uniform B=16: {unif_u:5.1f}/128 experts read | busiest expert {mean_tok:4.1f}/16 tokens ({mean_tok/mean_tok:.1f}x mean)")
print(f" Skewed B=16: {skew_u:5.1f}/128 experts read | busiest expert {hot_tok:4.1f}/16 tokens ({hot_tok/mean_tok:.1f}x mean)")
# Inkling 2 Mini config.json: 24 stored layers, middle 12 layers (6..17) run 3 passes = 48 layer passes.
ink_attn_1l = 2304 * (24 * 128 + 2 * 8 * 128) + (24 * 128) * 2304
ink_router_1l = 2304 * 128
ink_exp_1l = 3 * 2304 * 1152
ink_stored_blocks = 24 * (ink_attn_1l + ink_router_1l + 128 * ink_exp_1l)
ink_unique_blocks = 24 * (ink_attn_1l + ink_router_1l + 8 * ink_exp_1l)
ink_looped_blocks = 48 * (ink_attn_1l + ink_router_1l + 8 * ink_exp_1l)
ink_kv_24 = 2 * 24 * 8 * 128 * 2 // KIB
ink_kv_48 = 2 * 48 * 8 * 128 * 2 // KIB
print(
f" Inkling 2 Mini blocks (24 stored layers, 48 passes): stored {ink_stored_blocks/1e9:.2f}B"
f" | unique active {ink_unique_blocks/1e9:.2f}B | 48-pass read {ink_looped_blocks/1e9:.2f}B"
f" (+{(ink_looped_blocks - ink_unique_blocks)/1e9:.2f}B loop passes, KV {ink_kv_24} to {ink_kv_48} KiB/tok)"
)
if __name__ == "__main__":
main()uv run --no-project --python 3.12 python moe_sizing.pyStep 1 total vs active parameters and BF16 KV cache per token (from config.json)
Qwen2.5-7B (dense) | total 7.62B | card active 7.62B | B=1 read 7.07B | BF16 14.2 GiB | Q4_0 3.99 GiB | KV 56 KiB/tok
Qwen3-30B-A3B (128E top-8) | total 30.53B | card active 3.35B | B=1 read 3.04B | BF16 56.9 GiB | Q4_0 15.99 GiB | KV 96 KiB/tok
Qwen2.5-32B (dense) | total 32.76B | card active 32.76B | B=1 read 31.98B | BF16 61.0 GiB | Q4_0 17.16 GiB | KV 256 KiB/tok
Mixtral-8x7B (8E top-2) | total 46.70B | card active 12.88B | B=1 read 12.75B | BF16 87.0 GiB | Q4_0 24.47 GiB | KV 128 KiB/tok
Step 2 fit on one 24 GiB GPU at Q4_0 (2.00 GiB reserved for runtime, 4,096 tokens/chat)
Qwen2.5-7B (dense) | weights 3.99 GiB | room left 18.01 GiB | KV/chat 224 MiB | max 4K chats: 82
Qwen3-30B-A3B (128E top-8) | weights 15.99 GiB | room left 6.01 GiB | KV/chat 384 MiB | max 4K chats: 16
Qwen2.5-32B (dense) | weights 17.16 GiB | room left 4.84 GiB | KV/chat 1024 MiB | max 4K chats: 4
Mixtral-8x7B (8E top-2) | weights 24.47 GiB | room left -2.47 GiB | KV/chat 512 MiB | max 4K chats: 0
Step 3 unique experts woken per decode step: formula vs 20,000 Monte Carlo trials (seed 42)
Mixtral-8x7B (8E top-2):
B= 1 | formula 2.00/ 8 ( 25.0%) | Monte Carlo 2.00 | weight params read 12.75B
B= 2 | formula 3.50/ 8 ( 43.8%) | Monte Carlo 3.51 | weight params read 21.20B
B= 4 | formula 5.47/ 8 ( 68.4%) | Monte Carlo 5.47 | weight params read 32.30B
B= 8 | formula 7.20/ 8 ( 90.0%) | Monte Carlo 7.20 | weight params read 42.06B
B=16 | formula 7.92/ 8 ( 99.0%) | Monte Carlo 7.92 | weight params read 46.12B
B=32 | formula 8.00/ 8 (100.0%) | Monte Carlo 8.00 | weight params read 46.57B
B=64 | formula 8.00/ 8 (100.0%) | Monte Carlo 8.00 | weight params read 46.57B
Qwen3-30B-A3B (128E top-8):
B= 1 | formula 8.00/128 ( 6.2%) | Monte Carlo 8.00 | weight params read 3.04B
B= 2 | formula 15.50/128 ( 12.1%) | Monte Carlo 15.50 | weight params read 4.74B
B= 4 | formula 29.12/128 ( 22.8%) | Monte Carlo 29.13 | weight params read 7.83B
B= 8 | formula 51.62/128 ( 40.3%) | Monte Carlo 51.62 | weight params read 12.92B
B=16 | formula 82.42/128 ( 64.4%) | Monte Carlo 82.40 | weight params read 19.90B
B=32 | formula 111.77/128 ( 87.3%) | Monte Carlo 111.77 | weight params read 26.55B
B=64 | formula 125.94/128 ( 98.4%) | Monte Carlo 125.94 | weight params read 29.75B
Step 4 24 GiB card crossover (1,000 GB/s, 100 TFLOPS, Q4_0, 2,048 tokens/chat)
B= 1 chats | 30B-A3B MoE: 522.9 tok/s/chat ( 523 total, memory) | 7B Dense: 244.2 tok/s/chat ( 244 total, memory)
B= 4 chats | 30B-A3B MoE: 192.0 tok/s/chat ( 768 total, memory) | 7B Dense: 224.9 tok/s/chat ( 900 total, memory)
B= 8 chats | 30B-A3B MoE: 112.6 tok/s/chat ( 901 total, memory) | 7B Dense: 203.4 tok/s/chat ( 1627 total, memory)
B=16 chats | 30B-A3B MoE: 69.4 tok/s/chat ( 1110 total, memory) | 7B Dense: 170.8 tok/s/chat ( 2732 total, memory)
RTX 4090 (1,008 GB/s) B=1 ceiling: 30B-A3B 527.1 tok/s (measured 120 to 196, 23% to 37%) | 7B 246.2 tok/s (measured 135, 55%)
Step 5 equal-size showdown on 80 GiB card (2,000 GB/s, 300 TFLOPS, BF16, 2,048 tokens/chat)
B= 1 | 30B-A3B MoE: 318.2 tok/s/chat ( 318 total, memory ) | 32B Dense: 31.0 tok/s/chat ( 31 total, memory ) | MoE/Dense 10.26x
B= 4 | 30B-A3B MoE: 121.5 tok/s/chat ( 486 total, memory ) | 32B Dense: 30.2 tok/s/chat ( 121 total, memory ) | MoE/Dense 4.02x
B= 8 | 30B-A3B MoE: 72.9 tok/s/chat ( 583 total, memory ) | 32B Dense: 29.3 tok/s/chat ( 234 total, memory ) | MoE/Dense 2.49x
B= 16 | 30B-A3B MoE: 46.5 tok/s/chat ( 744 total, memory ) | 32B Dense: 27.6 tok/s/chat ( 441 total, memory ) | MoE/Dense 1.69x
B= 32 | 30B-A3B MoE: 33.6 tok/s/chat ( 1075 total, memory ) | 32B Dense: 24.6 tok/s/chat ( 789 total, memory ) | MoE/Dense 1.36x
B= 64 | 30B-A3B MoE: 27.6 tok/s/chat ( 1768 total, memory ) | 32B Dense: 20.3 tok/s/chat (1302 total, memory ) | MoE/Dense 1.36x
B=128 | 30B-A3B MoE: 23.2 tok/s/chat ( 2970 total, memory ) | 32B Dense: 15.1 tok/s/chat (1929 total, memory ) | MoE/Dense 1.54x
Step 6 prefill floor for one 8,192-token prompt on 80 GiB card (BF16, 300 TFLOPS)
Qwen3-30B-A3B (128E top-8) | memory 30.2 ms | compute 166.1 ms | floor 166.1 ms (compute)
Qwen2.5-32B (dense) | memory 32.0 ms | compute 1746.8 ms | floor 1746.8 ms (compute)
Step 7 skewed routing (Zipf s=0.9, sum=8) at B=16 and looped MoE passes (Inkling 2 Mini)
Uniform B=16: 82.4/128 experts read | busiest expert 1.0/16 tokens (1.0x mean)
Skewed B=16: 58.3/128 experts read | busiest expert 16.0/16 tokens (16.0x mean)
Inkling 2 Mini blocks (24 stored layers, 48 passes): stored 24.92B | unique active 1.99B | 48-pass read 3.98B (+1.99B loop passes, KV 96 to 192 KiB/tok)Where you will see this
Several engineering posts explain the intuition behind MoE serving, and we checked each one on 23 November 2026. The NVIDIA Technical Blog explains why VRAM scales with total parameters while single-stream latency scales with active parameters, and notes that higher concurrency wakes most experts and narrows MoE's decode advantage. Jacek Trefon's notes on single-GPU MoE and dense vs MoE contrast resident weight size against per-token active reads and compare RTX 4090 bandwidth (1,008 GB/s) against offloading experts to dual-channel DDR5 (~80 GB/s) in llama.cpp, while LLMNet notes that large batches wake nearly all experts in Mixtral-8x7B. And Thinking Machines' Inkling 2 Mini model card plus Sebastian Raschka's architecture sheet document how looped MoE layers separate unique active weights (3.4B) from executed per-token activations (5.4B across 48 layer passes).
What this guide adds is one runnable standard-library Python script that connects config.json weight and KV-cache byte math, the exact E * (1 - (1 - k / E)^B) batch wake-up curve verified by Monte Carlo routing, the multi-chat speed crossover against a 7B dense model, 8,192-token prefill floors, skewed Zipf routing, and looped MoE passes in one place.
What this does not do
- These speeds are theoretical memory-bandwidth and FLOP ceilings on chosen GPU numbers (1,000 GB/s and 100 TFLOPS for the 24 GiB card; 2,000 GB/s and 300 TFLOPS for the 80 GiB card), not direct GPU timings. We ran Python 3.12 locally with no GPU.
- Real MoE decode kernels pay extra overhead for router top-k sorting, token permutation, small grouped GEMMs, and non-contiguous memory reads. As Step 4 showed on third-party RTX 4090 llama.cpp numbers, Qwen3-30B-A3B reaches 23% to 37% of its theoretical ceiling at B = 1 versus 55% for a 7B dense model.
- Our parameter counter sums embedding, attention, router, and SwiGLU expert matrices from config.json and omits small RMSNorm vectors and attention biases (under 0.1% of total weights). Real GGUF checkpoints such as Unsloth's Dynamic 2.0 files also mix bit widths across router, attention, and expert tensors rather than using uniform Q4_0 everywhere.
- Step 3 assumes independent routing across layers and tokens. Real prompts exhibit topic locality (tokens in one coding chat often reuse domain experts, lowering unique experts read) while load-balancing auxiliary losses or bias terms push marginal expert selection back toward 1 / E across diverse chats.
- We model single-GPU serving where all experts sit in local VRAM. Offloading dormant experts over PCIe or dual-channel DDR5 (such as llama.cpp's CPU-MoE flags at ~80 GB/s, noted by Jacek Trefon) or splitting experts across nodes with All-to-All network dispatch introduces a separate interconnect bottleneck not modeled here.
This guide extends our LLM serving series from dense models to sparse and looped Mixture-of-Experts models. Start with sizing the KV cache for concurrent chats and 8-bit vs 4-bit weight block math, then check dense memory-bandwidth ceilings, first-token prefill vs decode, and when speculative decoding speeds up low-batch streams. Browse every tutorial on the guides page.
Explore this topic in the workspace
Topic Breakdown builds a structured learning roadmap with a concise chapter guide and lets you highlight any phrase or formula to open side-by-side chats without losing your place. Sign in to create your own breakdown.
Open breakdownOr type Mixture of Experts LLMs: routing, GPU memory and batching into the topic box on the home page. Want to try the Horizon workspace before signing in? Open the sample breakdown on Machine Learning.
Sources
All sources were checked on 23 November 2026. Read each primary source for full model and benchmark details.
- Qwen/Qwen3-30B-A3B config.json and model card on Hugging Face
Checked 23 November 2026. Gives 48 hidden layers, hidden_size 2048, 32 attention heads, 4 KV heads, head_dim 128 (96 KiB/tok BF16 KV), moe_intermediate_size 768, 128 experts, top-8 routing, and vocab_size 151936 (30.5B total and 3.3B active on the model card).
- Qwen/Qwen2.5-32B-Instruct config.json on Hugging Face
Checked 23 November 2026. Gives 64 hidden layers, hidden_size 5120, 40 attention heads, 8 KV heads, head_dim 128 (256 KiB/tok BF16 KV), intermediate_size 27648, and vocab_size 152064.
- Qwen/Qwen2.5-7B-Instruct model card on Hugging Face
Checked 23 November 2026. Gives 28 hidden layers, hidden_size 3584, 28 Q heads, 4 KV heads (56 KiB/tok BF16 KV), intermediate_size 18944, and 7.61B reported parameters.
- Jiang et al.: Mixtral of Experts (arXiv:2401.04088) and mistralai/Mixtral-8x7B-v0.1 config.json
Checked 23 November 2026. Documents 32 layers, hidden_size 4096, 8 KV heads (128 KiB/tok BF16 KV), 8 experts per layer with top-2 routing, intermediate_size 14336, 46.7B total parameters, and 12.9B active parameters per token.
- Thinking Machines: Inkling 2 Mini model card and Hugging Face config.json
Published 20 November 2026, checked 23 November 2026. Documents 24 stored sparse MoE layers (8 of 128 experts, intermediate_size 1152) with loop_config running middle layers 6..17 three times (48 layer passes), yielding 26.4B total parameters, 3.4B unique active parameters, and 5.4B effective active parameter activations per token.
- Sebastian Raschka: Inkling 2 Mini in the LLM Architecture Gallery
Published 20 November 2026, checked 23 November 2026. Summarizes 24 weight layers vs 48 executed layer passes (5.4B weight activations from 3.4B unique active weights) and 192 KiB BF16 KV cache per token across the 48 passes.
- NVIDIA Technical Blog: Dense vs. MoE Models: Active Parameters, Throughput, and When to Choose Each
Published 15 September 2026, checked 23 November 2026. Explains how MoE pays VRAM on total parameters and single-stream compute on active parameters, why batch-1 decode is memory-bandwidth bound, and why higher concurrency activates most experts and narrows MoE's latency margin.
- Jacek Trefon: Running MoE Models on a Single GPU and Dense vs MoE
Published 27 October 2026, checked 23 November 2026. Contrasts resident MoE weight footprint (~21 GB) against single-token active reads (~1.8 GB), notes RTX 4090 (1,008 GB/s) vs dual-channel DDR5 (~80 GB/s) CPU expert offloading, and notes how larger batches wake more experts.
- LLMNet: Mixture of Experts versus Dense Models
Published 20 August 2026, checked 23 November 2026. Compares dense 8B and 70B models against Mixtral 8x7B and notes qualitatively that a batch of 64 prompts wakes almost every expert.
- Fedus, Zoph, and Shazeer: Switch Transformers (arXiv:2101.03961) and DeepSeek-V3 Technical Report (arXiv:2412.19437)
Checked 23 November 2026. Defines sparse expert routing and auxiliary or bias-based load balancing that pushes expert marginal probabilities toward uniform 1 / E so no single expert stalls high-batch compute.
- RunAIHome: Qwen3-30B-A3B Local AI Guide (community llama.cpp RTX 4090 benchmark summary)
Checked 23 November 2026. Reports single-chat community llama.cpp figures of 120 to 196 tok/s for 4-bit Qwen3-30B-A3B on an RTX 4090 (1,008 GB/s) versus ~135 tok/s for a 7B dense model; cited in Step 4 as a third-party reality check we did not re-measure.
- Our serving guides: KV cache concurrency, 8-bit vs 4-bit weights, tokens per second, first-token prefill, and speculative decoding
Establish the BF16 KV cache formula, the 0.5625 B/weight Q4_0 block size, the 1,000 GB/s reference GPU, and the max(memory, compute) step model extended to sparse experts here.