Strip the names off a 2026 frontier model and what is left is a short list of numbers. DeepSeek-V3 is d=7168, L=61, MLA(128 heads, d_c=512), 256 experts top-8 + 1 shared, f=2048. Kimi K2 is the same list with two numbers changed. Kimi K3, Nemotron 3 Ultra and Qwen3.8-Flash-Next change which kind of layer some entries are. This track asks, for every entry on that list, why it has the value it has. Before we can answer “why”, we need to know exactly what each knob costs.
This lesson does that accounting once, carefully, and checks it against released configs. Every later lesson in Track VII (MoE, attention and KV, sparse attention, linear attention and SSMs) moves one or two of these knobs and argues from the same three bills.
Three bills
A model costs us in three currencies, and different knobs land on different bills.
- Memory for weights: the total parameter count . It decides how many GPUs the model needs before it can run at all.
- FLOPs per token: the active parameter count plus the attention core. It decides training cost and the compute-bound part of serving.
- Cache per sequence: the KV cache plus any recurrent state. It decides how many sequences fit next to the weights, i.e. batch size and long-context feasibility.
A fourth bill, communication, appears once the model is spread over many GPUs; the MoE lesson prices it.
Parameters, knob by knob
Count only matrices (norms and biases are noise at this scale). With hidden size , vocabulary :
- Embedding and LM head: each, so untied and tied. At – and K–9K this is 1–2B, a rounding error in the total but up to ~11% of the active count of a small-active model (gpt-oss-120b, Qwen3.8-Flash-Next).
- Token mixer, per layer. GQA with query heads, KV heads and head size :
MLA (DeepSeek-V2/V3, Kimi K2/K3) replaces by a down-projection to a latent of width plus a decoupled RoPE key of width , and up-projections back to the heads; the query is also low-rank with rank :
Linear-attention and SSM layers (KDA, Gated DeltaNet, Mamba-2) are a handful of projections; their cost shows up in the cache bill as a constant state instead of a growing KV.
- FFN. A SwiGLU FFN of intermediate width is (two matrices for a relu² FFN, as in Nemotron). An MoE layer with routed experts of width , shared experts, a router and, for LatentMoE, a down/up projection to a latent of width :
(with and no projection for an ordinary MoE). This is the whole trick of MoE in one line: appears only in the total, only in the active count.
FLOPs per token
A matrix–vector product costs 2 FLOPs per weight, so the linear layers cost per token in the forward pass (the embedding lookup is free; the LM head is not). The attention core has no weights. For one new token at context , a full-attention layer computes dot products of length against every cached key and the same again for the values:
The MLA form is larger per key because, in decode, MLA runs as multi-query attention over the 576-wide latent (derived in the attention lesson). A sliding-window layer replaces by ; a linear-attention layer replaces the whole term by a constant. Training costs about three forward passes, and averages the causal context to :
Cache per sequence
with bytes for BF16 GQA and for MLA. Only the first term grows with , and only the full-attention layers contribute to it. Every long-context architecture of 2025–26 is a way of shrinking that one sum: fewer bytes per entry (GQA, MLA), fewer full layers (sliding window, hybrids), or fewer entries per token (sequence compression in DeepSeek-V4).
Configure a frontier model
The calculator below implements exactly these formulas. Pick a preset: it loads the model’s released config.json (or the report’s table for MAI), and the grey tick shows the reported count.
2026년의 프론티어 모델에서 이름을 떼어 내면 짧은 숫자 목록이 남는다. DeepSeek-V3는 d=7168, L=61, MLA(head 128, d_c=512), expert 256개 중 top-8 + shared 1, f=2048이다. Kimi K2는 같은 목록에서 숫자 두 개를 바꾼 것이다. Kimi K3, Nemotron 3 Ultra, Qwen3.8-Flash-Next는 일부 항목의 종류를 바꾼다. 이 트랙은 목록의 항목마다 그 값이 왜 그 값인지 묻는다. “왜”에 답하려면 먼저 각 손잡이의 비용을 정확히 알아야 한다.
이 레슨은 그 회계를 한 번 꼼꼼하게 하고, 공개된 config로 검증한다. Track VII의 이후 레슨(MoE, attention과 KV, sparse attention, linear attention과 SSM)은 이 손잡이 한두 개를 움직이고, 같은 세 장의 청구서로 논증한다.
청구서 세 장
모델은 세 가지 통화로 비용을 청구하고, 손잡이마다 찍히는 청구서가 다르다.
- 가중치 메모리: 총(total) 파라미터 . 모델을 아예 돌리려면 GPU가 몇 장 필요한지를 정한다.
- 토큰당 FLOPs: 활성(active) 파라미터 와 attention core. 학습 비용과 서빙의 compute-bound 부분을 정한다.
- 시퀀스당 cache: KV cache와 순환 state. 가중치 옆에 시퀀스가 몇 개 들어가는지, 즉 batch 크기와 긴 문맥의 가능 여부를 정한다.
네 번째 청구서인 통신은 모델을 여러 GPU에 펼치는 순간 나타난다. 값은 MoE 레슨에서 매긴다.
파라미터, 손잡이별로
행렬만 센다(이 규모에서 norm과 bias는 잡음이다). hidden 크기 , 어휘 일 때:
- 임베딩과 LM head: 각각 , 묶지 않으면(untied) , 묶으면 . –, K–9K이면 1–2B로 총량에서는 반올림 오차지만, 활성 파라미터가 작은 모델(gpt-oss-120b, Qwen3.8-Flash-Next)에서는 활성의 ~11%까지 된다.
- 토큰 믹서, 층마다. query head , KV head , head 크기 인 GQA는
MLA(DeepSeek-V2/V3, Kimi K2/K3)는 를 폭 인 latent로의 down-projection, 폭 인 분리된 RoPE key, 그리고 head로 되돌리는 up-projection으로 바꾼다. query도 rank 로 저차원화한다.
linear attention·SSM 층(KDA, Gated DeltaNet, Mamba-2)은 projection 몇 개이고, 비용은 cache 청구서에 커지는 KV 대신 고정 state로 나타난다.
- FFN. 중간 폭 인 SwiGLU FFN은 (Nemotron처럼 relu² FFN이면 행렬 2개). routed expert 개(폭 ), shared expert 개, router, 그리고 LatentMoE라면 폭 인 latent로의 down/up projection을 가진 MoE 층은
이다(보통 MoE는 이고 projection이 없다). MoE의 요령 전체가 이 한 줄에 있다. 는 총량에만, 는 활성량에만 나온다.
토큰당 FLOPs
행렬–벡터 곱은 가중치 하나당 2 FLOPs이므로 선형층은 forward에서 토큰당 다(임베딩 조회는 공짜, LM head는 아니다). attention core에는 가중치가 없다. 문맥 에서 새 토큰 하나에 대해 full attention 층은 캐시된 모든 key와 길이 인 내적을 번, value에 대해 같은 양을 더 한다.
MLA가 key당 더 큰 이유는 decode에서 MLA가 폭 576인 latent 위의 multi-query attention으로 돌기 때문이다(attention 레슨에서 유도한다). sliding window 층은 를 로, linear attention 층은 항 전체를 상수로 바꾼다. 학습은 forward 약 세 번이고 causal 문맥을 평균 로 본다.
시퀀스당 cache
BF16 GQA면 바이트, MLA면 바이트다. 에 따라 커지는 것은 첫 항뿐이고, 거기에 기여하는 것은 full attention 층뿐이다. 2025–26년의 모든 긴 문맥 아키텍처는 이 합 하나를 줄이는 방법이다. 항목당 바이트를 줄이거나(GQA, MLA), full 층을 줄이거나(sliding window, 하이브리드), 토큰당 항목 수를 줄인다(DeepSeek-V4의 시퀀스 압축).
프론티어 모델 설정해 보기
아래 계산기는 정확히 이 식들을 구현한다. 기준 모델을 고르면 공개된 config.json(MAI는 보고서 표)을 불러오고, 회색 눈금이 보고된 값이다.
Things to try.
- DeepSeek-V3, untouched. The calculator gives 671B / 36.6B against the reported 671B / 37B. The routed experts are 97% of the total and 56% of the active count; attention is 11.4B. Move T from 4K to 128K: the share of decode FLOPs spent in the attention core goes from about half to 97%. That single number is the motivation for DeepSeek-V3.2’s DSA — switch the preset to V3.2 and at 128K it falls to 69%.
- Kimi K2. Drag E from 384 down to 256 and back: the total moves by about 340B, the active count by nothing. Then compare the decode FLOPs at 128K with V3: K2 has half the heads (64), and its attention FLOPs halve.
- Kimi K3. The latent is on (ℓ = 3584 = d/2). Turn it off (drag ℓ to the right end) and the routed experts double in size: the total goes from 2.78T to about 5.5T for the same E and k. Now set the full-KV share to 100%: the KV per token goes from 27 KiB to 104 KiB.
- Nemotron 3 Ultra, MAI-Base-2, gpt-oss. Three different cheap mixers (Mamba-2 state, a 512-token window, a 128-token window). In all three the KV per token is set only by the few full layers, and the fixed part is visible at short context.
- Any preset: push T to 1M. Wherever attention is dense, the “attention core” segment swallows the FLOPs bar. Wherever the full layers are few or sparse, it does not.
Where the calculator is off, it is off for a reason we can name: Kimi K2’s reported 1.04T includes its MTP layer, which the config’s num_hidden_layers does not, and the MAI-Base-2 row needs three dimensions the report does not state (head size, window and where the shared expert sits); we assume Base-1’s values and still land within 2% of 2.8T / 80B.
Why each knob has the value it has
The bills explain most choices directly. A few worth deriving:
Sparsity . At fixed and , raising buys parameters (capacity) without FLOPs. Kimi K2 fitted this as a “sparsity scaling law” with 8 active experts fixed: reaching the same validation loss took 1.69×, 1.39× and 1.15× fewer FLOPs at sparsity 48 than at 8, 16 and 32 (K2 report, Figure 5). The price is the memory bill and the communication bill, which is why K2 stopped at 48 and why K3’s sparsity 56 needed a latent projection to keep communication flat (see MoE).
Number of heads. In MLA the head count multiplies the attention-core FLOPs and not the cache (the latent is shared by all heads). K2 halved the heads from 128 to 64 because at 128K, 128 heads cost +83% inference FLOPs for a 0.5–1.2% validation-loss gain (K2 report, Figure 6). The code below recomputes that +83% from the config; depending on whether you count decode with absorbed MLA, decode in MHA mode, or a prefill average, you get +96%, +86% or +77%, which brackets the report’s number.
KV width and full-layer share. These only enter the cache bill and the attention term. That is why they are the knobs every long-context design moves (MLA for width, hybrids and windows for the share, V4’s CSA/HCA for entries per token).
Vocabulary. is negligible in the total, but it is in the active count of every token, and the softmax over is a non-trivial part of small-active models. Qwen3.8-Flash-Next’s 248K vocabulary costs 10.6% of its 6B active parameters by our count — and the model adds a 51B n-gram table in host memory instead of a bigger vocabulary (MTP and embeddings).
import numpy as np
def mixer_params(d, a):
t = a['type']
if t == 'gqa':
return d*a['nh']*a['dh'] + 2*d*a['nkv']*a['dh'] + a['nh']*a['dh']*d
if t == 'mla':
nh, qr, dc, dn, dr, dv = a['nh'], a['qr'], a['dc'], a['dn'], a['dr'], a['dv']
p = d*qr + qr*nh*(dn+dr) + d*(dc+dr) + dc*nh*(dn+dv) + nh*dv*d
return p + (d*nh*dv if a.get('gate') else 0) # K3: full-rank output gate
if t == 'kda': # q, k, v, output gate, output
return 5*d*a['nh']*a['dh']
if t == 'mamba': # in_proj (x,z,B,C,dt) + out_proj
di = a['H']*a['P']
return d*(2*di + 2*a['G']*a['N'] + a['H']) + di*d
def count(m):
d, nmat = m['d'], (3 if m.get('gated', True) else 2) # SwiGLU: 3 matrices, relu^2: 2
emb = m['V']*d*(1 if m.get('tied') else 2)
mix = sum(n*mixer_params(d, a) for n, a in m['mixers'])
dense = m.get('n_dense', 0)*nmat*d*m.get('f_dense', 0)
lat = m.get('latent', 0)
e1 = nmat*(lat or d)*m['f'] # one routed expert
shared = m.get('n_shared', 0)*nmat*d*m.get('f_shared', m['f'])
extra = d*m['E'] + (2*d*lat if lat else 0) # router + latent down/up
L = m['n_moe']
total = emb + mix + dense + L*(m['E']*e1 + shared + extra)
active = m['V']*d + mix + dense + L*(m['k']*e1 + shared + extra) # LM head yes, lookup no
return total/1e9, active/1e9
MLA = lambda nh: dict(type='mla', nh=nh, qr=1536, dc=512, dn=128, dr=64, dv=128)
MODELS = { # config.json values (MAI: report Table 1). reported (total, active) in B
'DeepSeek-V3': (dict(d=7168, V=129280, mixers=[(61, MLA(128))], n_dense=3, f_dense=18432,
n_moe=58, E=256, k=8, f=2048, n_shared=1), (671, 37)),
'Kimi K2': (dict(d=7168, V=163840, mixers=[(61, MLA(64))], n_dense=1, f_dense=18432,
n_moe=60, E=384, k=8, f=2048, n_shared=1), (1040, 32.6)),
'Qwen3-235B-A22B': (dict(d=4096, V=151936, mixers=[(94, dict(type='gqa', nh=64, nkv=4, dh=128))],
n_moe=94, E=128, k=8, f=1536), (235, 22)),
'gpt-oss-120b': (dict(d=2880, V=201088, mixers=[(36, dict(type='gqa', nh=64, nkv=8, dh=64))],
n_moe=36, E=128, k=4, f=2880), (116.83, 5.13)),
'Kimi K3': (dict(d=7168, V=163840, mixers=[(69, dict(type='kda', nh=96, dh=128)),
(24, dict(MLA(96), gate=True))],
n_dense=1, f_dense=33792, n_moe=92, E=896, k=16, f=3072, latent=3584,
n_shared=2, f_shared=3072), (2780, 104.2)),
'Nemotron 3 Ultra':(dict(d=8192, V=131072, gated=False,
mixers=[(48, dict(type='mamba', H=256, P=64, G=8, N=128)),
(12, dict(type='gqa', nh=64, nkv=2, dh=128))],
n_moe=48, E=512, k=22, f=5120, latent=2048, n_shared=1, f_shared=10240), (550, 55)),
'MAI-Base-1': (dict(d=6656, V=200019, tied=True, mixers=[(78, dict(type='gqa', nh=80, nkv=8, dh=128))],
n_dense=39, f_dense=6656, n_moe=39, E=512, k=8, f=5120, latent=3072), (962, 34.7)),
}
print(f"{'model':17s} {'total':>8s} {'reported':>9s} {'active':>8s} {'reported':>9s}")
for name, (m, (rt, ra)) in MODELS.items():
T, A = count(m)
print(f"{name:17s} {T:7.1f}B {rt:8.1f}B {A:7.1f}B {ra:8.1f}B ({100*(T/rt-1):+.1f}%, {100*(A/ra-1):+.1f}%)")
# Kimi K2: 64 vs 128 heads at a 128K context (report: +83% inference FLOPs)
d, L, T = 7168, 61, 131072
lin = lambda nh: 2*count(dict(MODELS['Kimi K2'][0], mixers=[(61, MLA(nh))]))[1]*1e9
for mode, per_key, ctx in [('decode, absorbed MLA', lambda nh: 2*nh*(2*512+64), T),
('decode, MHA mode', lambda nh: 2*nh*(192+128), T),
('prefill average', lambda nh: 2*nh*(192+128), T/2)]:
f = {nh: lin(nh) + L*per_key(nh)*ctx for nh in (64, 128)}
print(f"{mode:22s} 64 heads {f[64]/1e9:7.0f} GFLOP/token, 128 heads {f[128]/1e9:7.0f} -> +{100*(f[128]/f[64]-1):.0f}%")Every total lands within 0.1% except Kimi K2, and the active counts are within 3% of the reported values (which are rounded: “37B”, “22B”). Kimi K2 is 1.3% short of the reported 1.04T, which is about one layer of 384 experts — the MTP layer, which num_hidden_layers = 61 does not include. Nothing here is fitted: the same four formulas, fed with config values, reproduce models built by five labs.
If you have PyTorch and transformers, you can get the exact count without allocating a byte by building the model on the meta device:
import torch
from transformers import AutoConfig, AutoModelForCausalLM
for repo in ["Qwen/Qwen3-235B-A22B", "openai/gpt-oss-120b"]:
cfg = AutoConfig.from_pretrained(repo)
with torch.device("meta"): # shapes only, no memory
model = AutoModelForCausalLM.from_config(cfg)
total = sum(p.numel() for p in model.parameters())
experts = sum(p.numel() for n, p in model.named_parameters() if ".experts." in n)
print(f"{repo}: total {total/1e9:.2f}B, of which routed experts {experts/1e9:.2f}B")The frontier on one chart
The same cost model, fed each released config unchanged, gives the chart below. It answers a question the parameter counts hide: which model is cheapest depends on the context length.
해 볼 것.
- DeepSeek-V3 그대로. 계산기는 보고값 671B / 37B에 대해 671B / 36.6B를 준다. routed expert가 총량의 97%, 활성의 56%이고 attention은 11.4B다. T를 4K에서 128K로 옮기면 decode FLOPs 중 attention core 비중이 절반쯤에서 97%로 간다. 이 숫자 하나가 DeepSeek-V3.2의 DSA의 동기다. 기준 모델을 V3.2로 바꾸면 128K에서 69%로 떨어진다.
- Kimi K2. E를 384에서 256으로 내렸다 올려 보자. 총량은 약 340B 움직이고 활성량은 그대로다. 그다음 128K의 decode FLOPs를 V3와 비교하자. K2는 head가 절반(64)이라 attention FLOPs가 절반이다.
- Kimi K3. latent가 켜져 있다(ℓ = 3584 = d/2). 끄면(ℓ을 오른쪽 끝까지) routed expert 크기가 두 배가 되어 같은 E, k로 총량이 2.78T에서 약 5.5T가 된다. 이제 전역 층 비율을 100%로 하면 토큰당 KV가 27 KiB에서 104 KiB가 된다.
- Nemotron 3 Ultra, MAI-Base-2, gpt-oss. 싼 믹서가 셋 다 다르다(Mamba-2 state, 512 토큰 window, 128 토큰 window). 셋 모두 토큰당 KV는 몇 안 되는 full 층만이 정하고, 짧은 문맥에서는 고정 부분이 보인다.
- 아무 모델이나 T를 1M으로. attention이 dense한 곳에서는 “attention core” 구간이 FLOPs 막대를 삼킨다. full 층이 적거나 sparse한 곳에서는 그렇지 않다.
계산기가 틀리는 곳은 이유를 댈 수 있는 곳이다. Kimi K2의 보고값 1.04T에는 MTP 층이 들어 있는데 config의 num_hidden_layers에는 없다. MAI-Base-2는 보고서에 없는 차원 세 개(head 크기, window, shared expert의 위치)가 필요해서 Base-1 값을 가정했고, 그래도 2.8T / 80B의 2% 안에 든다.
손잡이마다 그 값인 이유
청구서로 대부분의 선택이 바로 설명된다. 유도해 볼 만한 것 몇 개.
Sparsity . 와 를 고정하고 를 키우면 FLOPs 없이 파라미터(용량)를 산다. Kimi K2는 활성 expert 8개를 고정하고 이것을 “sparsity scaling law”로 적합했다. 같은 검증 손실에 도달하는 데 sparsity 48이 8, 16, 32보다 각각 1.69배, 1.39배, 1.15배 적은 FLOPs가 들었다(K2 보고서 Figure 5). 대가는 메모리와 통신 청구서이고, 그래서 K2는 48에서 멈췄으며 K3의 sparsity 56은 통신을 그대로 두려고 latent projection이 필요했다(MoE 참고).
head 수. MLA에서 head 수는 attention core FLOPs에 곱해지고 cache에는 곱해지지 않는다(latent는 모든 head가 공유한다). K2는 head를 128에서 64로 줄였다. 128K에서 128 head는 추론 FLOPs를 83% 늘리는데 검증 손실은 0.5–1.2%만 좋아지기 때문이다(K2 보고서 Figure 6). 아래 코드가 그 +83%를 config로 다시 계산한다. decode를 흡수된 MLA로 세는지, MHA 모드로 세는지, prefill 평균으로 세는지에 따라 +96%, +86%, +77%가 나오고, 보고값은 그 사이에 있다.
KV 폭과 full 층 비율. 이 둘은 cache 청구서와 attention 항에만 들어간다. 그래서 모든 긴 문맥 설계가 이 손잡이를 움직인다(폭은 MLA, 비율은 하이브리드와 window, 토큰당 항목 수는 V4의 CSA/HCA).
어휘. 는 총량에서는 무시할 만하지만 모든 토큰의 활성량에 들어가고, 에 대한 softmax는 활성이 작은 모델에서 무시할 수 없다. Qwen3.8-Flash-Next의 248K 어휘는 우리 계산으로 활성 6B의 10.6%다. 그리고 이 모델은 어휘를 더 키우는 대신 host 메모리에 51B짜리 n-gram 표를 붙였다(MTP와 임베딩).
import numpy as np
def mixer_params(d, a):
t = a['type']
if t == 'gqa':
return d*a['nh']*a['dh'] + 2*d*a['nkv']*a['dh'] + a['nh']*a['dh']*d
if t == 'mla':
nh, qr, dc, dn, dr, dv = a['nh'], a['qr'], a['dc'], a['dn'], a['dr'], a['dv']
p = d*qr + qr*nh*(dn+dr) + d*(dc+dr) + dc*nh*(dn+dv) + nh*dv*d
return p + (d*nh*dv if a.get('gate') else 0) # K3: full-rank 출력 gate
if t == 'kda': # q, k, v, 출력 gate, 출력
return 5*d*a['nh']*a['dh']
if t == 'mamba': # in_proj (x,z,B,C,dt) + out_proj
di = a['H']*a['P']
return d*(2*di + 2*a['G']*a['N'] + a['H']) + di*d
def count(m):
d, nmat = m['d'], (3 if m.get('gated', True) else 2) # SwiGLU: 행렬 3개, relu^2: 2개
emb = m['V']*d*(1 if m.get('tied') else 2)
mix = sum(n*mixer_params(d, a) for n, a in m['mixers'])
dense = m.get('n_dense', 0)*nmat*d*m.get('f_dense', 0)
lat = m.get('latent', 0)
e1 = nmat*(lat or d)*m['f'] # routed expert 하나
shared = m.get('n_shared', 0)*nmat*d*m.get('f_shared', m['f'])
extra = d*m['E'] + (2*d*lat if lat else 0) # router + latent down/up
L = m['n_moe']
total = emb + mix + dense + L*(m['E']*e1 + shared + extra)
active = m['V']*d + mix + dense + L*(m['k']*e1 + shared + extra) # LM head는 포함, 조회는 제외
return total/1e9, active/1e9
MLA = lambda nh: dict(type='mla', nh=nh, qr=1536, dc=512, dn=128, dr=64, dv=128)
MODELS = { # config.json 값 (MAI는 보고서 Table 1). 보고된 (총, 활성), 단위 B
'DeepSeek-V3': (dict(d=7168, V=129280, mixers=[(61, MLA(128))], n_dense=3, f_dense=18432,
n_moe=58, E=256, k=8, f=2048, n_shared=1), (671, 37)),
'Kimi K2': (dict(d=7168, V=163840, mixers=[(61, MLA(64))], n_dense=1, f_dense=18432,
n_moe=60, E=384, k=8, f=2048, n_shared=1), (1040, 32.6)),
'Qwen3-235B-A22B': (dict(d=4096, V=151936, mixers=[(94, dict(type='gqa', nh=64, nkv=4, dh=128))],
n_moe=94, E=128, k=8, f=1536), (235, 22)),
'gpt-oss-120b': (dict(d=2880, V=201088, mixers=[(36, dict(type='gqa', nh=64, nkv=8, dh=64))],
n_moe=36, E=128, k=4, f=2880), (116.83, 5.13)),
'Kimi K3': (dict(d=7168, V=163840, mixers=[(69, dict(type='kda', nh=96, dh=128)),
(24, dict(MLA(96), gate=True))],
n_dense=1, f_dense=33792, n_moe=92, E=896, k=16, f=3072, latent=3584,
n_shared=2, f_shared=3072), (2780, 104.2)),
'Nemotron 3 Ultra':(dict(d=8192, V=131072, gated=False,
mixers=[(48, dict(type='mamba', H=256, P=64, G=8, N=128)),
(12, dict(type='gqa', nh=64, nkv=2, dh=128))],
n_moe=48, E=512, k=22, f=5120, latent=2048, n_shared=1, f_shared=10240), (550, 55)),
'MAI-Base-1': (dict(d=6656, V=200019, tied=True, mixers=[(78, dict(type='gqa', nh=80, nkv=8, dh=128))],
n_dense=39, f_dense=6656, n_moe=39, E=512, k=8, f=5120, latent=3072), (962, 34.7)),
}
print(f"{'model':17s} {'total':>8s} {'reported':>9s} {'active':>8s} {'reported':>9s}")
for name, (m, (rt, ra)) in MODELS.items():
T, A = count(m)
print(f"{name:17s} {T:7.1f}B {rt:8.1f}B {A:7.1f}B {ra:8.1f}B ({100*(T/rt-1):+.1f}%, {100*(A/ra-1):+.1f}%)")
# Kimi K2: 128K 문맥에서 head 64 대 128 (보고서: 추론 FLOPs +83%)
d, L, T = 7168, 61, 131072
lin = lambda nh: 2*count(dict(MODELS['Kimi K2'][0], mixers=[(61, MLA(nh))]))[1]*1e9
for mode, per_key, ctx in [('decode, absorbed MLA', lambda nh: 2*nh*(2*512+64), T),
('decode, MHA mode', lambda nh: 2*nh*(192+128), T),
('prefill average', lambda nh: 2*nh*(192+128), T/2)]:
f = {nh: lin(nh) + L*per_key(nh)*ctx for nh in (64, 128)}
print(f"{mode:22s} 64 heads {f[64]/1e9:7.0f} GFLOP/token, 128 heads {f[128]/1e9:7.0f} -> +{100*(f[128]/f[64]-1):.0f}%")총량은 Kimi K2를 빼면 모두 0.1% 안에 들고, 활성량은 보고값(반올림된 “37B”, “22B”)의 3% 안이다. Kimi K2는 보고된 1.04T보다 1.3% 모자라는데, 이는 expert 384개짜리 층 하나 정도로 num_hidden_layers = 61에 들어 있지 않은 MTP 층이다. 여기에 적합(fit)한 것은 없다. 같은 식 네 개에 config 값을 넣었을 뿐인데 다섯 연구소의 모델이 재현된다.
PyTorch와 transformers가 있다면 meta device에서 모델을 만들어 메모리를 한 바이트도 쓰지 않고 정확한 수를 얻을 수 있다.
import torch
from transformers import AutoConfig, AutoModelForCausalLM
for repo in ["Qwen/Qwen3-235B-A22B", "openai/gpt-oss-120b"]:
cfg = AutoConfig.from_pretrained(repo)
with torch.device("meta"): # 모양만, 메모리 없음
model = AutoModelForCausalLM.from_config(cfg)
total = sum(p.numel() for p in model.parameters())
experts = sum(p.numel() for n, p in model.named_parameters() if ".experts." in n)
print(f"{repo}: total {total/1e9:.2f}B, of which routed experts {experts/1e9:.2f}B")한 장의 그림으로 본 프론티어
같은 비용 모델에 공개 config를 그대로 넣으면 아래 그림이 된다. 파라미터 수가 숨기는 질문에 답한다. 어느 모델이 가장 싼지는 문맥 길이에 달려 있다.
What the chart says, in numbers from the same model (BF16 KV, FP32 recurrent state, per sequence):
| Model | full-KV layers | KV per token | cache at 128K | cache at 1M | attention share of decode FLOPs at 128K |
|---|---|---|---|---|---|
| Qwen3-235B-A22B | 94 of 94 (GQA 64/4) | 188 KiB | 24 GiB | 188 GiB | 90% |
| DeepSeek-V3 | 61 of 61 (MLA) | 68.6 KiB | 8.6 GiB | 69 GiB | 97% |
| DeepSeek-V3.2 | 61 (MLA + DSA top-2048) | 76 KiB | 9.5 GiB | 76 GiB | 69% |
| gpt-oss-120b | 18 of 36 (other 18: window 128) | 36 KiB | 4.5 GiB | 36 GiB | 79% |
| MAI-Base-2 | 17 of 102 (other 85: window 512) | 17 KiB | 2.5 GiB | 17 GiB | 42% |
| Kimi K3 | 24 of 93 (other 69: KDA) | 27 KiB | 3.8 GiB | 27 GiB | 76% |
| Nemotron 3 Ultra | 12 of 60 (other 48: Mamba-2) | 12 KiB | 1.9 GiB | 12 GiB | 32% |
| DeepSeek-V4-Pro | 61, compressed 4× / 128× | 4.9 KiB | 0.6 GiB | 4.9 GiB | 26% |
Three remarks.
- The cache column is set by full-KV layers alone. V3 and V3.2 have the same cache (DSA reads less, it does not store less), while MAI-Base-2 is 4× smaller than V3 per token even though its full layers are plain GQA: there are only 17 of them and they have 2 KV heads. V4 is the only design that shrinks the number of entries.
- FLOPs are not time. In decode the GQA attention core is memory-bound (each KV byte is used for only a few FLOPs) while absorbed MLA is close to compute-bound; the attention lesson computes the arithmetic intensity, and Track VIII turns it into milliseconds.
- Our numbers for KDA and V4 carry assumptions (FP32 KDA state; V4’s 576-byte entries with a 68-byte FP4 indexer key per CSA entry, as in the V4 lesson). The V4-Pro figure of 4.97 KB/token matches that lesson’s derivation and the report’s “about 2% of a BF16 GQA8 baseline”.
Starting from DeepSeek-V3, you double the number of routed experts (256 → 512) and keep top-8. Which bills change?
appears only in (the total) and in the router ; the active count has . So the total roughly doubles its routed part (+650B) while active parameters grow only by the router (58 × 7168 × 256 ≈ 0.1B). FLOPs per token barely move; memory and the all-to-all fan-out over more GPUs are what you pay. KV is untouched.
Summary
- A block is a short list of knobs; each lands on specific bills: on memory only, and on FLOPs, head count on attention FLOPs, KV width and full-layer share on the cache.
- Parameters: ; active replaces by . Fed with configs, this reproduces reported counts within ~1–2%.
- FLOPs per token: plus an attention core that grows with only in full layers; at 128K, dense attention is 90–97% of the decode FLOPs of V3 or Qwen3.
- Cache per sequence grows only through full-KV layers. The long-context designs of 2025–26 attack bytes per entry (MLA), number of full layers (windows, hybrids) or entries per token (V4).
- Which model is cheapest depends on : active parameters rule short contexts, full-KV layers rule long ones.
그림이 말하는 것을 같은 모델의 숫자로 적으면 이렇다(BF16 KV, FP32 순환 state, 시퀀스 하나 기준).
| 모델 | full-KV 층 | 토큰당 KV | 128K cache | 1M cache | 128K decode FLOPs 중 attention |
|---|---|---|---|---|---|
| Qwen3-235B-A22B | 94층 중 94 (GQA 64/4) | 188 KiB | 24 GiB | 188 GiB | 90% |
| DeepSeek-V3 | 61층 중 61 (MLA) | 68.6 KiB | 8.6 GiB | 69 GiB | 97% |
| DeepSeek-V3.2 | 61 (MLA + DSA top-2048) | 76 KiB | 9.5 GiB | 76 GiB | 69% |
| gpt-oss-120b | 36층 중 18 (나머지 18: window 128) | 36 KiB | 4.5 GiB | 36 GiB | 79% |
| MAI-Base-2 | 102층 중 17 (나머지 85: window 512) | 17 KiB | 2.5 GiB | 17 GiB | 42% |
| Kimi K3 | 93층 중 24 (나머지 69: KDA) | 27 KiB | 3.8 GiB | 27 GiB | 76% |
| Nemotron 3 Ultra | 60층 중 12 (나머지 48: Mamba-2) | 12 KiB | 1.9 GiB | 12 GiB | 32% |
| DeepSeek-V4-Pro | 61, 4배 / 128배 압축 | 4.9 KiB | 0.6 GiB | 4.9 GiB | 26% |
세 가지를 짚어 두자.
- cache 열은 full-KV 층만이 정한다. V3와 V3.2는 cache가 같다(DSA는 덜 읽을 뿐 덜 저장하지 않는다). MAI-Base-2는 full 층이 평범한 GQA인데도 토큰당 V3보다 4배 작다. full 층이 17개뿐이고 KV head가 2개이기 때문이다. 항목 수를 줄이는 설계는 V4뿐이다.
- FLOPs는 시간이 아니다. decode에서 GQA의 attention core는 memory-bound(KV 바이트 하나당 FLOPs가 몇 개뿐)이고, 흡수된 MLA는 compute-bound에 가깝다. attention 레슨에서 산술 강도를 계산하고, Track VIII에서 밀리초로 바꾼다.
- KDA와 V4의 숫자에는 가정이 들어 있다(KDA state는 FP32, V4는 V4 레슨처럼 576바이트 항목 + CSA 항목마다 68바이트 FP4 indexer key). V4-Pro의 4.97 KB/토큰은 그 레슨의 유도, 그리고 보고서의 “BF16 GQA8 기준선의 약 2%“와 맞는다.
DeepSeek-V3에서 routed expert 수를 두 배(256 → 512)로 하고 top-8은 유지한다. 어느 청구서가 바뀌는가?
는 (총량)와 router 에만 나오고, 활성량에는 가 들어간다. 그래서 총량은 routed 부분이 거의 두 배(+650B)가 되고, 활성 파라미터는 router만큼(58 × 7168 × 256 ≈ 0.1B)만 는다. 토큰당 FLOPs는 거의 그대로이고, 대가는 메모리와 더 많은 GPU로 퍼지는 all-to-all이다. KV는 그대로다.
정리
- 블록은 짧은 손잡이 목록이고 손잡이마다 찍히는 청구서가 다르다. 는 메모리에만, 와 는 FLOPs에, head 수는 attention FLOPs에, KV 폭과 full 층 비율은 cache에.
- 파라미터: , 활성은 대신 . config를 넣으면 보고값을 ~1–2% 안으로 재현한다.
- 토큰당 FLOPs는 에 full 층에서만 와 함께 커지는 attention core를 더한 것이다. 128K에서 dense attention은 V3·Qwen3 decode FLOPs의 90–97%다.
- 시퀀스당 cache는 full-KV 층을 통해서만 커진다. 2025–26년의 긴 문맥 설계는 항목당 바이트(MLA), full 층 수(window, 하이브리드), 토큰당 항목 수(V4)를 공략한다.
- 어느 모델이 가장 싼지는 에 달려 있다. 짧은 문맥은 활성 파라미터가, 긴 문맥은 full-KV 층이 지배한다.
더 읽을거리Further reading
- DeepSeek-AI, DeepSeek-V3 Technical Report (2024) — MLA·DeepSeekMoE 설정의 기준점. 671B/37B를 이 레슨의 계산기로 재현한다.The reference point for MLA and DeepSeekMoE configs; the calculator in this lesson reproduces its 671B/37B.
- Kimi Team, Kimi K2: Open Agentic Intelligence (2025) — sparsity scaling law와 head 수를 절반으로 줄인 근거(128K에서 추론 FLOPs +83%).The sparsity scaling law and the case for halving the heads (+83% inference FLOPs at 128K).
- Kaplan et al., Scaling Laws for Neural Language Models (2020) — 토큰당 forward 2N + attention 항, 학습 6N의 회계.The accounting of 2N + attention per forward token and 6N per training token.
- Released configs: DeepSeek-V3, V3.2, V4-Pro/Flash, Kimi-K2, Kimi-K3, Qwen3-235B-A22B, Qwen3.8-Flash-Next, gpt-oss-120b, Nemotron-3-Ultra (Hugging Face config.json) — 계산기의 모든 기준값. 같은 경로(huggingface.co/<org>/<model>/blob/main/config.json)에서 각 모델의 값을 확인할 수 있다.Every preset value in the calculator; each model's file sits at the same path pattern (huggingface.co/<org>/<model>/blob/main/config.json).
- Microsoft AI, MAI-Thinking-1 (Table 1) and Frontier Pre-training at Microsoft AI (MAI-Base-2 table) (2026) — config가 공개되지 않은 MAI 모델의 층·hidden·latent·expert 폭. expert 폭은 SwiGLU 첫 층 출력(=중간 차원의 2배)으로 적혀 있다.Layers, hidden, latent and expert width for the MAI models, which have no public config. Expert widths are given as the output of the first SwiGLU layer (twice the intermediate size).
- NVIDIA, Nemotron 3 Ultra technical report (2026) — Mamba-2·attention·LatentMoE 하이브리드. relu² expert(행렬 2개)라 SwiGLU와 파라미터 회계가 다르다.The Mamba-2 / attention / LatentMoE hybrid. Its experts are relu² (two matrices), so the parameter accounting differs from SwiGLU.