Track VII · Architecture Deep Dives · 10/12

Kimi 계보: K2 → Kimi Linear → K3The Kimi lineage: K2 → Kimi Linear → K3

Moonshot이 DeepSeek-V3 골격에서 손잡이 두 개(head 수, expert sparsity)만 돌린 K2, 작은 규모에서 하이브리드를 검증한 Kimi Linear, 그리고 길이·깊이·폭 세 방향을 모두 넓힌 K3를 비용과 근거로 읽는다. head 수의 FLOPs, KDA 상태가 본전을 뽑는 문맥(약 10K), LatentMoE가 통신을 고정한 채 expert를 두 배로 만든 산수를 config로 다시 계산한다.How Moonshot turned just two knobs of the DeepSeek-V3 skeleton for K2 (head count, expert sparsity), validated a hybrid at small scale with Kimi Linear, then widened K3 along length, depth and width — read through costs and evidence. From the configs we recompute the head-count FLOPs, the context where KDA state pays off (~10K), and how LatentMoE doubled the experts at fixed traffic.

Moonshot’s line is the most explicit about method. K2 (July 2025) takes the DeepSeek-V3 skeleton and turns exactly two knobs, each justified by a fitted curve. Kimi Linear (October 2025) tests a new token mixer at 48B-A3B under a controlled comparison before betting a flagship on it. K3 (July 2026) then scales that mixer to 2.8T and widens the block in the two other directions — depth (Attention Residuals) and width (Stable LatentMoE). Read in order, the three reports are a small experiment → adopt loop.

The components live in their own lessons: MLA in attention and KV, the delta rule and KDA’s chunkwise form in linear attention and SSMs, sparsity scaling, LatentMoE and Quantile Balancing in MoE, QK-Clip, SiTU-GLU and attention residuals in stability components. Report-level details: K2 and K3.

Two knobs, two curves (K2)

K2 keeps V3’s 61 layers, d=7168d=7168, MLA with a 512 latent + 64 RoPE key, a shared expert and expert width 2,048. Two settings move.

Experts: 256 → 384, still 8 active. Define sparsity as total over active experts. With active experts — hence FLOPs per token — fixed, K2’s sparsity scaling law (fitted on Muon-trained MoEs, Fig. 5) says loss keeps falling as total experts grow: to reach validation loss 1.5, sparsity 48 needs 1.69×, 1.39× and 1.15× fewer FLOPs than sparsity 8, 16 and 32. The returns shrink, and every extra expert costs memory and all-to-all complexity, so K2 stops at 48 (384/8). Total parameters grow 671B → 1.04T while active parameters fall 37B → 32.6B.

Heads: 128 → 64. At decode in MLA’s absorbed (MQA) mode, attention MACs per cached token are nh(dc+dhR+dc)=nh×1,088n_h(d_c+d^R_h+d_c)=n_h\times1{,}088, linear in the head count; at prefill (MHA mode) they are nh(192+128)n_h(192+128). Both scale with nhn_h and with the context. The report measured that 128 heads cost +83% inference FLOPs at 128K for a validation-loss gain of only 0.5–1.2% at equal tokens (Fig. 6) — a bad trade for an agentic model that lives at long context. The NumPy block below recounts this from the config: +76% averaged over a 128K prefill and +86% for decode at 128K in MHA mode (the report does not state its exact accounting). K2 also uses only 1 dense layer (V3: 3) and drops expert grouping.

Stability got a new mechanism rather than a new block: MuonClip. Muon at 1T made attention logits grow without bound; QK-Clip rescales WqW_q and WkW_k per head after an update whenever the head’s maximum logit exceeds a threshold. 15.5T tokens, zero loss spikes.

Moonshot의 계보는 방법에 관해 가장 명시적이다. K2(2025년 7월)는 DeepSeek-V3 골격에서 손잡이를 딱 두 개 돌리고, 각각을 적합한 곡선으로 정당화한다. Kimi Linear(2025년 10월)는 플래그십을 걸기 전에 새 token mixer를 48B-A3B에서 대조 실험으로 검증한다. K3(2026년 7월)는 그 mixer를 2.8T로 키우고 나머지 두 방향 — 깊이(Attention Residuals)와 폭(Stable LatentMoE) — 으로도 블록을 넓힌다. 순서대로 읽으면 세 보고서는 “작게 실험 → 채택”의 고리다.

부품은 각자의 레슨에 있다. MLA는 attention과 KV, delta rule과 KDA의 chunkwise 형태는 linear attention과 SSM, sparsity 스케일링·LatentMoE·Quantile Balancing은 MoE, QK-Clip·SiTU-GLU·attention residual은 안정화 부품. 보고서 수준 세부는 K2와 K3.

손잡이 둘, 곡선 둘 (K2)

K2는 V3의 61층, d=7168d=7168, latent 512 + RoPE key 64의 MLA, shared expert, expert 폭 2,048을 유지한다. 두 설정이 움직인다.

Expert: 256 → 384, 활성은 여전히 8. sparsity를 총 expert / 활성 expert로 정의하자. 활성 expert — 곧 토큰당 FLOPs — 를 고정하면 K2의 sparsity 스케일링 법칙(Muon으로 학습한 MoE에 적합, Fig. 5)은 총 expert가 늘수록 loss가 계속 내려간다고 말한다. val loss 1.5에 닿는 데 sparsity 48은 sparsity 8, 16, 32보다 1.69배, 1.39배, 1.15배 적은 FLOPs가 든다. 이득은 줄어들고 expert마다 메모리와 all-to-all 복잡도가 들기 때문에 K2는 48(384/8)에서 멈춘다. 총 파라미터는 671B → 1.04T로 늘고 활성 파라미터는 37B → 32.6B로 준다.

Head: 128 → 64. MLA 흡수(MQA) 모드 디코드에서 캐시 토큰당 attention MAC은 nh(dc+dhR+dc)=nh×1,088n_h(d_c+d^R_h+d_c)=n_h\times1{,}088, head 수에 비례한다. prefill(MHA 모드)에서는 nh(192+128)n_h(192+128). 둘 다 nhn_h와 문맥에 비례한다. 보고서는 128 heads가 128K에서 추론 FLOPs +83% 인데 같은 토큰에서 val loss 이득은 0.5–1.2%뿐임을 측정했다(Fig. 6). 긴 문맥에서 사는 에이전트 모델에는 나쁜 거래다. 아래 NumPy 블록이 config로 다시 센다. MHA 모드에서 128K prefill 평균 +76%, 128K 디코드 +86%(보고서는 정확한 계산 방식을 밝히지 않는다). K2는 밀집층도 1개만 쓰고(V3: 3개) expert grouping을 없앴다.

안정성은 새 블록이 아니라 새 장치로 얻었다. MuonClip. 1T에서 Muon은 attention 로짓을 끝없이 키웠다. QK-Clip은 head의 최대 로짓이 문턱을 넘으면 갱신 뒤 그 head의 WqW_q·WkW_k를 다시 스케일한다. 15.5T 토큰, loss spike 0회.

통계를 볼 문맥 길이context for the stats

2025-07 · 1.04T / 32.6B · 61층 · d 71682025-07 · 1.04T / 32.6B · 61 layers · d 7168

×1
입력input
Embedding 163,840 × 7,168Embedding 163,840 × 7,168
untieduntied
residualresidual
Pre-norm residual (폭 1)Pre-norm residual (width 1)
RMSNormRMSNorm
토큰 혼합 (attention)token mixer
MLA · 64 heads (V3는 128)MLA · 64 heads (V3: 128)
latent 512 + RoPE key 64 → 층당 576 캐시; V3 골격 그대로latent 512 + RoPE key 64 → 576 cached per layer; V3 skeleton otherwise
채널 혼합 (FFN)channel mixer (FFN)
MoE · 1 shared + 384 routed, top-8MoE · 1 shared + 384 routed, top-8
expert dim 2,048; sparsity 48; 밀집층 1개; expert grouping 없음expert dim 2,048; sparsity 48; 1 dense layer; no expert grouping
학습 레시피training recipe
MuonClip (Muon + QK-Clip)MuonClip (Muon + QK-Clip)
head별 최대 로짓이 τ를 넘으면 W_q·W_k를 줄임per-head W_q, W_k shrunk when the max logit exceeds τ
출발점: 각 부품이 노린 병목 Starting point: the bottleneck each part targets
긴 문맥 FLOPslong-context FLOPs
MLA · 64 heads (V3는 128).MLA · 64 heads (V3: 128). head를 128로 늘리면 128K에서 추론 FLOPs +83%인데 같은 토큰에서 val loss 이득은 0.5–1.2%(Fig. 6). 에이전트용 긴 문맥 비용 때문에 64로 줄였다.128 heads would cost +83% inference FLOPs at 128K for a 0.5–1.2% val-loss gain at equal tokens (Fig. 6); halved for long-context agentic inference.
FLOP당 품질quality per FLOP
MoE · 1 shared + 384 routed, top-8.MoE · 1 shared + 384 routed, top-8. 활성 expert 수 고정, 총 expert만 늘리는 sparsity 스케일링: val loss 1.5 도달에 sparsity 8/16/32 대비 1.69×/1.39×/1.15× 적은 FLOPs(Fig. 5).Sparsity scaling at fixed active experts: reaching val loss 1.5 takes 1.69×/1.39×/1.15× fewer FLOPs than sparsity 8/16/32 (Fig. 5).
학습 안정성training stability
MuonClip (Muon + QK-Clip).MuonClip (Muon + QK-Clip). Muon으로 1T를 키우면 attention 로짓이 폭주한다. QK-Clip으로 15.5T 토큰 동안 loss spike 0회.Scaling Muon to 1T makes attention logits explode; with QK-Clip, 15.5T tokens with zero loss spikes.
Click a generation. The strip draws every layer from the model's config.json (top row: token mixer, bottom row: FFN); the block below highlights what changed against the previous generation, and the right column names the bottleneck each change attacked with the evidence its report gives. Stats are computed from the configs at the chosen context (decode of one token; FLOPs = 2 × (active params + attention MACs); KV in each model's shipped format). Watch two numbers move: KV per token and layers whose KV grows with context. 세대를 클릭하세요. 띠는 모델 config.json의 모든 층을 그린다(윗줄 token mixer, 아랫줄 FFN). 아래 블록은 직전 세대 대비 바뀐 부분을 강조하고, 오른쪽 열은 각 변경이 노린 병목과 보고서의 근거를 적는다. 통계는 고른 문맥에서 config로 계산한 값이다(토큰 하나 디코드, FLOPs = 2 × (활성 파라미터 + attention MAC), KV는 각 모델이 실제 쓰는 형식). 두 숫자가 어떻게 움직이는지 보라: 토큰당 KV와 문맥에 따라 KV가 자라는 층 수.

Kimi Linear: test the mixer small, under fair conditions

Between K2 and K3, Moonshot asked whether a hybrid could replace full attention without a quality cost. Kimi Linear (48B total, 3B active, 27 layers) interleaves three Kimi Delta Attention layers with one MLA layer (full_attn_layers: [4, 8, …, 24, 27]). KDA is Gated DeltaNet with a per-channel forget gate:

St=(I−βtktkt⊤)Diag⁡(αt) St−1+βtktvt⊤,αt∈(0,1)dk,\mathbf S_t=\big(\mathbf I-\beta_t\mathbf k_t\mathbf k_t^\top\big)\operatorname{Diag}(\boldsymbol\alpha_t)\,\mathbf S_{t-1}+\beta_t\mathbf k_t\mathbf v_t^\top,\qquad \boldsymbol\alpha_t\in(0,1)^{d_k},

so each key channel gets its own memory lifetime instead of GDN’s single scalar αt\alpha_t per head. The paper reads this per-channel decay as a learnable positional encoding — which is why the MLA layers can drop RoPE entirely (NoPE) and do purely content-based global retrieval.

The evidence is unusually clean because every comparison uses the same recipe and 1.4T tokens:

MLA (all layers)GDN-H (3:1)Kimi Linear (3:1)
MMLU-Pro (base)47.247.951.0
GPQA-Diamond (SFT, avg@8)57.158.662.1
RULER @128K81.380.584.3
MRCR22.623.929.6
Kimi Linear Tables 3–5.

The hybrid beats all-MLA, and the per-channel gate beats the per-head gate. A RoPE variant of Kimi Linear loses most of the long-context gain (RULER 78.8, average 51.8 vs 54.5), supporting the NoPE choice. And the ratio was chosen by a sweep (Table 1, small-scale): validation PPL 5.77 for 0:1 (pure MLA), 5.66 for 1:1, 5.65 for 3:1, 5.70 for 7:1, 5.82 for 15:1. On cost, with 7 of 27 layers holding KV, the cache is 26% of an all-MLA model of the same shape (“up to 75%” smaller), and decoding at 1M is 6.3× faster per output token (1.84 vs 11.48 ms).

K3: widen length, depth and width at once

K3 (2.78T total, 104.2B active, 93 layers, 1M context) takes Kimi Linear’s mixer to flagship scale and changes the two slots Kimi Linear left alone.

Length — 69 KDA + 24 Gated MLA. The config lists full_attn_layers 4, 8, …, 92, 93: the [KDA, KDA, KDA, MLA] block repeats 23 times and one more MLA layer closes the stack so the last layer is always global. Two K3-specific changes. The decay map gets a floor, g=gmin⁡σ(eAz)g=g_{\min}\sigma(e^{A}z) with gmin⁡=−5g_{\min}=-5 (gate_lower_bound: -5.0), so a 16-token tile’s cumulative log-decay stays above −80-80 and 1/Γ<e801/\Gamma<e^{80} fits in BF16 — the diagonal tiles of the chunk kernel, previously computed pair by pair, become Tensor Core matmuls. And the MLA layers get a full-rank sigmoid output gate (mla_use_output_gate) and stay NoPE, so 1M context needs no RoPE rescaling. Note a quiet consequence: with only 24 global layers, K3 can afford 96 heads — 1.5× K2’s — while its MLA attention cost per cached token, 24×96×1,08824\times96\times1{,}088, is still 59% of K2’s 61×64×1,08861\times64\times1{,}088. The hybrid bought back the head budget K2 had to give up.

Depth — Block Attention Residuals. At 93 layers, a plain pre-norm residual hands every layer one unit-weight sum of all previous outputs, and later layers’ contributions get diluted. AttnRes replaces that sum with a softmax over earlier outputs using a learned per-layer pseudo-query; the block variant (8 blocks of 12 layers, attn_res_block_size: 12) attends over block sums so memory and pipeline traffic stay O(Nd)O(Nd). The evidence is in the AttnRes paper (Kimi Linear 48B/3B, 1.4T tokens: less PreNorm dilution, every downstream task improves); the K3 report has no separate ablation.

Width — Stable LatentMoE. 896 routed experts with 16 active (sparsity 56) plus 2 shared. Sending each token’s 7,168-d vector to 16 experts would double K2’s dispatch traffic, so routed experts run in a 3,584-d latent: u=∑i∈TkpiEi(W↓x)\mathbf u=\sum_{i\in\mathcal T_k}p_iE_i(\mathbf W^{\downarrow}\mathbf x), y=∑jEjshared(x)+W↑RMSNorm(u)\mathbf y=\sum_jE^{\text{shared}}_j(\mathbf x)+\mathbf W^{\uparrow}\text{RMSNorm}(\mathbf u). Dispatch width 16×3,584=57,34416\times3{,}584=57{,}344 equals K2’s 8×7,1688\times7{,}168: twice the experts at the same traffic. The latent path is four matmuls in a row and its activations exploded at 2.8T, hence the RMSNorm before W↑\mathbf W^\uparrow and SiTU-GLU, which soft-caps both SwiGLU factors (β1=4,β2=25\beta_1=4,\beta_2=25; activation_situ_beta), bounding the output by 100. Balancing ~900 experts outgrew bias-nudging, so Quantile Balancing computes the bias that hits the target load exactly from one forward pass.

The optimiser splits Muon per head for Q/K/V (Per-Head Muon) with K2’s weight clipping. The report credits the combination — architecture, data and recipe together — with about 2.5× K2’s scaling efficiency (Fig. 7); there is no per-component breakdown at K3 scale.

Kimi Linear: mixer를 작게, 공정한 조건에서 시험

K2와 K3 사이에 Moonshot은 하이브리드가 품질 손해 없이 full attention을 대체할 수 있는지 물었다. Kimi Linear(총 48B, 활성 3B, 27층)는 Kimi Delta Attention 세 층과 MLA 한 층을 번갈아 둔다(full_attn_layers: [4, 8, …, 24, 27]). KDA는 채널별 forget gate를 가진 Gated DeltaNet이다.

St=(I−βtktkt⊤)Diag⁡(αt) St−1+βtktvt⊤,αt∈(0,1)dk,\mathbf S_t=\big(\mathbf I-\beta_t\mathbf k_t\mathbf k_t^\top\big)\operatorname{Diag}(\boldsymbol\alpha_t)\,\mathbf S_{t-1}+\beta_t\mathbf k_t\mathbf v_t^\top,\qquad \boldsymbol\alpha_t\in(0,1)^{d_k},

그래서 GDN의 head당 스칼라 αt\alpha_t 하나 대신 key 채널마다 기억 수명이 따로 있다. 논문은 이 채널별 decay를 학습 가능한 위치 인코딩으로 읽는다. 그래서 MLA 층은 RoPE를 통째로 빼고(NoPE) 순수하게 내용 기반 전역 검색을 한다.

모든 비교가 같은 레시피와 1.4T 토큰을 쓰기 때문에 근거가 유난히 깨끗하다.

MLA (전 층)GDN-H (3:1)Kimi Linear (3:1)
MMLU-Pro (base)47.247.951.0
GPQA-Diamond (SFT, avg@8)57.158.662.1
RULER @128K81.380.584.3
MRCR22.623.929.6
Kimi Linear 표 3–5.

하이브리드가 전부-MLA를 이기고, 채널별 gate가 head별 gate를 이긴다. Kimi Linear의 RoPE 변형은 긴 문맥 이득 대부분을 잃는다(RULER 78.8, 평균 51.8 vs 54.5). NoPE 선택을 뒷받침한다. 비율은 sweep으로 골랐다(표 1, 작은 규모). val PPL은 0:1(순수 MLA) 5.77, 1:1 5.66, 3:1 5.65, 7:1 5.70, 15:1 5.82. 비용 면에서는 27층 중 7층만 KV를 가지므로 캐시가 같은 모양의 전부-MLA 모델의 26%(“최대 75%” 감소)이고, 1M에서 출력 토큰당 디코드가 6.3배 빠르다(1.84 vs 11.48 ms).

K3: 길이·깊이·폭을 한꺼번에 넓힌다

K3(총 2.78T, 활성 104.2B, 93층, 1M 문맥)는 Kimi Linear의 mixer를 플래그십 규모로 가져가고, Kimi Linear가 건드리지 않은 두 자리를 바꾼다.

길이 — KDA 69 + Gated MLA 24. config의 full_attn_layers는 4, 8, …, 92, 93이다. [KDA, KDA, KDA, MLA] 블록이 23번 반복되고 MLA 한 층이 더 스택을 닫아서 마지막 층은 항상 전역이다. K3 고유의 변경 둘. decay 사상에 하한이 생겼다. g=gmin⁡σ(eAz)g=g_{\min}\sigma(e^{A}z), gmin⁡=−5g_{\min}=-5(gate_lower_bound: -5.0). 그래서 16토큰 tile의 누적 log-decay가 −80-80 위에 머물고 1/Γ<e801/\Gamma<e^{80}가 BF16에 들어간다. 이전에 위치 쌍마다 계산하던 chunk kernel의 대각 tile도 Tensor Core matmul이 된다. 그리고 MLA 층은 full-rank sigmoid 출력 gate(mla_use_output_gate)를 얻고 NoPE를 유지해 1M 문맥에 RoPE 재조정이 필요 없다. 조용한 결과 하나를 보라. 전역 층이 24개뿐이라 K3는 96 heads — K2의 1.5배 — 를 쓸 수 있는데, 캐시 토큰당 MLA attention 비용 24×96×1,08824\times96\times1{,}088은 여전히 K2의 61×64×1,08861\times64\times1{,}088의 59%다. 하이브리드가 K2가 포기해야 했던 head 예산을 되사 준 셈이다.

깊이 — Block Attention Residuals. 93층에서 평범한 pre-norm residual은 모든 층에 이전 출력 전부의 단위 가중 합 하나를 건네고, 뒤쪽 층의 기여는 희석된다. AttnRes는 그 합을 층마다 학습한 pseudo-query로 이전 출력들에 대한 softmax로 바꾼다. 블록 변형(12층 × 8블록, attn_res_block_size: 12)은 블록 합들에 attend해서 메모리와 pipeline 통신을 O(Nd)O(Nd)로 둔다. 근거는 AttnRes 논문에 있다(Kimi Linear 48B/3B, 1.4T 토큰: PreNorm 희석 감소, 모든 다운스트림 향상). K3 보고서에는 별도 ablation이 없다.

폭 — Stable LatentMoE. routed expert 896개 중 16개 활성(sparsity 56) + shared 2개. 토큰마다 7,168차원 벡터를 16개 expert에 보내면 K2의 dispatch 트래픽이 두 배가 되므로, routed expert는 3,584차원 latent에서 돈다. u=∑i∈TkpiEi(W↓x)\mathbf u=\sum_{i\in\mathcal T_k}p_iE_i(\mathbf W^{\downarrow}\mathbf x), y=∑jEjshared(x)+W↑RMSNorm(u)\mathbf y=\sum_jE^{\text{shared}}_j(\mathbf x)+\mathbf W^{\uparrow}\text{RMSNorm}(\mathbf u). dispatch 폭 16×3,584=57,34416\times3{,}584=57{,}344는 K2의 8×7,1688\times7{,}168과 같다. 같은 트래픽에 expert는 두 배. latent 경로는 matmul 넷이 연달아 있는 구조라 2.8T에서 활성이 폭주했다. 그래서 W↑\mathbf W^\uparrow 앞의 RMSNorm과, SwiGLU의 두 인수 모두에 soft cap을 거는 SiTU-GLU(β1=4,β2=25\beta_1=4,\beta_2=25; activation_situ_beta)로 출력을 100 이하로 묶는다. expert 약 900개의 균형은 bias 조금씩 밀기의 범위를 넘어서, Quantile Balancing이 forward 한 번으로 목표 부하를 정확히 맞추는 bias를 계산한다.

옵티마이저는 Q/K/V에 대해 Muon을 head별로 나누고(Per-Head Muon) K2의 weight clipping을 쓴다. 보고서는 이 조합 — 구조, 데이터, 레시피를 합친 것 — 이 K2 대비 약 2.5배의 스케일링 효율을 낸다고 한다(Fig. 7). K3 규모의 부품별 분해는 없다.

Drag the context length. K3 carries ~0.45 GB of KDA state, so per sequence it costs more memory than K2 below ~10K tokens and less above; in FLOPs its 3× larger active parameter count only pays off above ~40K. Set the what-if heads to 128 to reproduce the trade-off K2 rejected; change KDA : MLA (0 = all MLA) to move K3 and Kimi Linear along the ratio the Kimi Linear ablation chose (3:1). 문맥 길이를 끌어 보라. K3는 약 0.45 GB의 KDA 상태를 들고 다녀서 약 10K 토큰 아래에선 시퀀스당 메모리가 K2보다 크고 그 위에선 작다. FLOPs에서는 3배 큰 활성 파라미터가 약 40K 위에서야 본전을 뽑는다. what-if head 수를 128로 두면 K2가 버린 선택지가 재현되고, KDA : MLA를 바꾸면(0 = 전부 MLA) Kimi Linear ablation이 고른 비율(3:1)을 따라 K3·Kimi Linear가 움직인다.

Reading the crossover figure

  1. KV + state per sequence: K3 starts above K2 — 69 layers × 96 heads of 128×128 FP32 state is ~0.45 GB before the first token — and crosses below at ~10.5K tokens. At 1M, K2 would need ~74 GB of KV per sequence (beyond its 128K context: dimmed), K3 ~29 GB.
  2. FLOPs per token: K3’s 104B active parameters cost about 3× K2’s at short context; the attention savings only win above ~41K tokens. K3 is a bet on long context, which is exactly the agentic regime its RL post-training targets.
  3. Set what-if heads to 128 (default): the dashed K2 line is the alternative K2 rejected. The gap grows with context: about +12% at 1K, about +94% at 128K in this figure’s absorbed-decode accounting (the report’s +83% uses an accounting it does not state). Head count is cheap at short context and dominant at long context.
  4. Move KDA : MLA from 3:1 to 0 (all MLA): K3’s memory line jumps to the all-MLA slope (and to ×3.9 its KV per token); at 7:1 the KV shrinks further but recall rests on the fixed state for 7 of 8 layers. Kimi Linear’s sweep put the quality optimum at 3:1 (val PPL 5.65 vs 5.70 at 7:1 and 5.82 at 15:1), and the memory gain past 3:1 is small.
NumPy K2's head trade-off, K3's state crossover and LatentMoE's dispatch width
import numpy as np

# ---- 1. K2's head count: what does 64 -> 128 heads cost at 128K? (report Fig. 6: +83% inference FLOPs) ----
d, n_layers, act = 7168, 61, 32.6e9            # K2 config: hidden 7168, 61 layers; 32.6B active (report)
def extra_head_params(dh):                     # q_b (1536 -> heads*192), kv_b (512 -> heads*256), o (heads*128 -> d)
    return 1536 * dh * 192 + 512 * dh * 256 + dh * 128 * d
def k2_flops(heads, T=131072, mode='decode'):
    keys = T if mode == 'decode' else T / 2    # decode at position T, or average over a T-token prefill
    per_key = heads * (192 + 128)              # MHA-mode MLA: QK over 128+64 dims, AV over 128
    params = act + n_layers * extra_head_params(heads - 64)
    return 2 * params + 2 * per_key * keys * n_layers
for mode in ('prefill-average', 'decode'):
    r = k2_flops(128, mode=mode) / k2_flops(64, mode=mode)
    print(f"128 vs 64 heads at 128K, {mode:15s}: +{r - 1:.0%}   (report: +83%)")

# ---- 2. KV + state per sequence (config.json; MLA 576 numbers BF16; KDA state FP32, conv state BF16) ----
MLA = 576 * 2
def kda_state(heads, dk=128, dv=128, conv=4):
    return heads * dk * dv * 4 + 3 * heads * 128 * (conv - 1) * 2
def k3_layout(n=93, ratio=3):                  # config full_attn_layers = 4, 8, ..., 92, 93 (1-indexed)
    return ['mla' if ratio == 0 or (i + 1) % (ratio + 1) == 0 or i == n - 1 else 'kda' for i in range(n)]
lay = k3_layout()
print("K3 layout: MLA", lay.count('mla'), "KDA", lay.count('kda'), "(config: 24 / 69)")
M = {  # name: (MLA layers, KDA layers, KDA heads, MLA heads, active params)
    'K2':          (61, 0, 0, 64, 32.6e9),
    'Kimi Linear': (7, 20, 32, 32, 3e9),
    'K3':          (lay.count('mla'), lay.count('kda'), 96, 96, 104.2e9),
}
def mem(m, L):
    a, k, kh, h, _ = M[m]; return a * MLA * L + k * kda_state(kh)
def flops(m, L):
    a, k, kh, h, p = M[m]; return 2 * (p + a * h * (576 + 512) * L + k * 4 * kh * 128 * 128)   # absorbed MLA; KDA ~4 dk dv/head
for m in M:
    a, k, kh, h, _ = M[m]
    print(f"{m:12s} KV/token {a * MLA:6,d} B   fixed KDA state {k * kda_state(kh) / 1e6:6.1f} MB")
print(f"Kimi Linear KV vs an all-MLA 27-layer model: {7 / 27:.0%} -> {1 - 7 / 27:.0%} smaller (paper: up to 75%)")
Ls = np.unique(np.logspace(10, 20, 3000, base=2).astype(np.int64)).tolist()   # python ints (Pyodide is 32-bit)
x_mem = next(L for L in Ls if mem('K3', L) < mem('K2', L))
x_flp = next(L for L in Ls if flops('K3', L) < flops('K2', L))
print(f"K3 holds less memory than K2 above L ~ {x_mem:,}; costs fewer FLOPs per token above L ~ {x_flp:,}")
for L in (8192, 131072, 1 << 20):
    print(f"L={L:>7}: K2 {mem('K2', L) / 1e9:6.2f} GB {flops('K2', L) / 1e9:7.0f} GFLOP | K3 {mem('K3', L) / 1e9:6.2f} GB {flops('K3', L) / 1e9:7.0f} GFLOP")

# ---- 3. LatentMoE: twice the experts at K2's dispatch traffic ----
print("dispatch width per token per MoE layer: K2", 8 * 7168, "| K3", 16 * 3584, "| K3 without latent", 16 * 7168)
E_k3 = 3 * 3584 * 3072                         # one routed expert in the latent space
print(f"K3 routed params: {896 * E_k3 * 92 / 1e12:.2f}T of 2.78T total; active routed {16 * E_k3 * 92 / 1e9:.1f}B of 104.2B")
 

Check in the output: the head trade-off lands at +76% (prefill average) to +86% (decode), bracketing the report’s +83%; the layout reproduces the config’s 24/69 split; Kimi Linear’s 7-of-27 KV layers give the paper’s “up to 75%”; K3’s memory crosses K2’s at ~10.5K tokens and its FLOPs at ~41K; LatentMoE’s dispatch width equals K2’s exactly; and routed experts account for 2.72T of K3’s 2.78T parameters but under half of its active ones — the shared experts, 96-head attention and KDA layers are the always-on rest.

The method, not just the model

Three habits make this lineage readable. Every knob comes with a curve: K2’s sparsity and head-count choices are each one figure (Fig. 5, Fig. 6), with the cost side computed at the context where the model will be used. New mixers are proven small first: Kimi Linear’s 1.4T-token controlled comparison (same data, same recipe, MLA vs GDN-H vs KDA) is the evidence K3 relies on for its token mixer — K3 itself has no ablation of KDA, AttnRes, Quantile Balancing or SiTU-GLU. Stability fixes are local: QK-Clip touches only Wq,WkW_q, W_k of heads that exceed a threshold; SiTU-GLU only bounds an activation; the decay floor only clips a range that a kernel needed bounded. None changes what the block computes in the normal regime.

The open question is the same as for DeepSeek V4: at 2.8T and sparsity 56, are the 48B-scale orderings still right? The K3 report bundles architecture, data and recipe into its 2.5× figure, so it cannot say.

확인 문제Check yourself

K3 uses 96 MLA heads although K2 cut its heads from 128 to 64 for long-context cost. Why is that consistent?

Attention MACs per cached token scale with (MLA layers) × (heads) × 1,088 in absorbed decode. K2: 61×64=3,90461\times64=3{,}904 head-layers; K3: 24×96=2,30424\times96=2{,}304, i.e. 59% of K2’s even with 1.5× the heads per layer. The KDA layers’ cost does not grow with context. Replacing most global layers bought back the head budget.

확인 문제Check yourself

LatentMoE in K3 activates 16 experts per token versus K2's 8. What happens to the per-token all-to-all dispatch volume?

Dispatch volume per token is (active routed experts) × (width sent): K2 8×7,168=57,3448\times7{,}168=57{,}344, K3 16×3,584=57,34416\times3{,}584=57{,}344. Shared experts run locally on the full-width hidden state and are not dispatched. The price is a longer, ill-conditioned routed path (W↓\mathbf W^\downarrow → expert → W↑\mathbf W^\uparrow), which is why K3 adds an RMSNorm before the up-projection and SiTU-GLU.

Summary

  • K2 = DeepSeek-V3 skeleton with two knobs: experts 256 → 384 at 8 active (sparsity scaling law: 1.69×/1.39×/1.15× fewer FLOPs than sparsity 8/16/32 to a fixed loss) and heads 128 → 64 (+83% inference FLOPs at 128K for ≤1.2% loss gain; our recount +76% to +86%). MuonClip for stability.
  • Kimi Linear validated the mixer at 48B-A3B with a controlled 1.4T-token comparison: 3 KDA (per-channel decay) : 1 MLA (NoPE) beats all-MLA and GDN-H; the 3:1 ratio came from a sweep; KV −74%, 6.3× TPOT at 1M.
  • K3 scaled it to 93 layers (69 KDA + 24 Gated MLA), added a decay floor so the chunk kernel is all matmuls, and used the freed attention budget for 96 heads at 59% of K2’s per-token attention cost.
  • Depth: Block Attention Residuals (8 × 12 layers). Width: Stable LatentMoE, 16 of 896 experts in a 3,584-d latent at K2’s dispatch width, stabilised by RMSNorm, SiTU-GLU and Quantile Balancing.
  • K3 holds less memory than K2 above ~10.5K tokens and costs fewer FLOPs above ~41K: a design for long agentic contexts, with component evidence from smaller-scale papers.

교차점 그림 읽기

  1. 시퀀스당 KV+상태: K3는 K2보다 위에서 출발한다. 69층 × 96 heads × 128×128 FP32 상태가 첫 토큰 전에 이미 약 0.45 GB다. 약 10.5K 토큰에서 아래로 교차한다. 1M에서 K2는 시퀀스당 KV 약 74 GB(지원 문맥 128K 밖이라 흐리게), K3는 약 29 GB.
  2. 토큰당 FLOPs: K3의 활성 104B는 짧은 문맥에서 K2의 약 3배다. attention 절약은 약 41K 토큰 위에서야 이긴다. K3는 긴 문맥에 거는 설계이고, 그것이 정확히 RL 사후학습이 겨냥한 에이전트 영역이다.
  3. what-if heads를 128(기본값)로 두면 점선 K2가 K2가 거절한 대안이다. 간격은 문맥과 함께 커진다. 이 그림의 흡수 디코드 계산으로 1K에서 약 +12%, 128K에서 약 +94%다(보고서의 +83%는 밝히지 않은 계산 방식). head 수는 짧은 문맥에선 싸고 긴 문맥에선 지배적이다.
  4. KDA : MLA를 3:1에서 0(전부 MLA)으로 옮기면 K3의 메모리 선이 전부-MLA 기울기로 뛴다(토큰당 KV ×3.9). 7:1에서는 KV가 더 줄지만 8층 중 7층의 recall을 고정 상태에 맡긴다. Kimi Linear의 sweep은 품질 최적을 3:1에 놓았고(val PPL 5.65 vs 7:1 5.70, 15:1 5.82), 3:1을 넘어서는 메모리 이득은 작다.
NumPy K2의 head 거래, K3의 상태 교차점, LatentMoE의 dispatch 폭
import numpy as np

# ---- 1. K2의 head 수: 128K에서 64 -> 128 heads의 비용은? (보고서 Fig. 6: 추론 FLOPs +83%) ----
d, n_layers, act = 7168, 61, 32.6e9            # K2 config: hidden 7168, 61층; 활성 32.6B (보고서)
def extra_head_params(dh):                     # q_b (1536 -> heads*192), kv_b (512 -> heads*256), o (heads*128 -> d)
    return 1536 * dh * 192 + 512 * dh * 256 + dh * 128 * d
def k2_flops(heads, T=131072, mode='decode'):
    keys = T if mode == 'decode' else T / 2    # 위치 T에서 디코드, 또는 T토큰 prefill의 평균
    per_key = heads * (192 + 128)              # MHA 모드 MLA: QK는 128+64차원, AV는 128차원
    params = act + n_layers * extra_head_params(heads - 64)
    return 2 * params + 2 * per_key * keys * n_layers
for mode in ('prefill-average', 'decode'):
    r = k2_flops(128, mode=mode) / k2_flops(64, mode=mode)
    print(f"128K에서 128 vs 64 heads, {mode:15s}: +{r - 1:.0%}   (보고: +83%)")

# ---- 2. 시퀀스당 KV+상태 (config.json; MLA 576개 BF16; KDA 상태 FP32, conv 상태 BF16) ----
MLA = 576 * 2
def kda_state(heads, dk=128, dv=128, conv=4):
    return heads * dk * dv * 4 + 3 * heads * 128 * (conv - 1) * 2
def k3_layout(n=93, ratio=3):                  # config full_attn_layers = 4, 8, ..., 92, 93 (1부터 셈)
    return ['mla' if ratio == 0 or (i + 1) % (ratio + 1) == 0 or i == n - 1 else 'kda' for i in range(n)]
lay = k3_layout()
print("K3 배치: MLA", lay.count('mla'), "KDA", lay.count('kda'), "(config: 24 / 69)")
M = {  # 이름: (MLA 층, KDA 층, KDA heads, MLA heads, 활성 파라미터)
    'K2':          (61, 0, 0, 64, 32.6e9),
    'Kimi Linear': (7, 20, 32, 32, 3e9),
    'K3':          (lay.count('mla'), lay.count('kda'), 96, 96, 104.2e9),
}
def mem(m, L):
    a, k, kh, h, _ = M[m]; return a * MLA * L + k * kda_state(kh)
def flops(m, L):
    a, k, kh, h, p = M[m]; return 2 * (p + a * h * (576 + 512) * L + k * 4 * kh * 128 * 128)   # 흡수된 MLA; KDA head당 ~4 dk dv
for m in M:
    a, k, kh, h, _ = M[m]
    print(f"{m:12s} 토큰당 KV {a * MLA:6,d} B   고정 KDA 상태 {k * kda_state(kh) / 1e6:6.1f} MB")
print(f"Kimi Linear KV, 27층 전부-MLA 대비: {7 / 27:.0%} -> {1 - 7 / 27:.0%} 감소 (논문: 최대 75%)")
Ls = np.unique(np.logspace(10, 20, 3000, base=2).astype(np.int64)).tolist()   # 파이썬 int (Pyodide는 32비트)
x_mem = next(L for L in Ls if mem('K3', L) < mem('K2', L))
x_flp = next(L for L in Ls if flops('K3', L) < flops('K2', L))
print(f"L ~ {x_mem:,} 이상에서 K3 메모리 < K2, L ~ {x_flp:,} 이상에서 K3 토큰당 FLOPs < K2")
for L in (8192, 131072, 1 << 20):
    print(f"L={L:>7}: K2 {mem('K2', L) / 1e9:6.2f} GB {flops('K2', L) / 1e9:7.0f} GFLOP | K3 {mem('K3', L) / 1e9:6.2f} GB {flops('K3', L) / 1e9:7.0f} GFLOP")

# ---- 3. LatentMoE: K2의 dispatch 트래픽으로 expert 두 배 ----
print("MoE 층당 토큰 dispatch 폭: K2", 8 * 7168, "| K3", 16 * 3584, "| latent 없는 K3", 16 * 7168)
E_k3 = 3 * 3584 * 3072                         # latent 공간의 routed expert 하나
print(f"K3 routed 파라미터: 총 2.78T 중 {896 * E_k3 * 92 / 1e12:.2f}T; 활성 104.2B 중 routed {16 * E_k3 * 92 / 1e9:.1f}B")
 

출력에서 확인할 것: head 거래는 +76%(prefill 평균)에서 +86%(디코드)로 보고서의 +83%를 감싼다. 배치는 config의 24/69 분할을 재현한다. Kimi Linear의 27층 중 KV 7층이 논문의 “최대 75%“를 낸다. K3 메모리는 약 10.5K 토큰, FLOPs는 약 41K에서 K2와 교차한다. LatentMoE의 dispatch 폭은 K2와 정확히 같다. routed expert는 K3 2.78T 중 2.72T지만 활성의 절반도 안 된다. shared expert, 96-head attention, KDA 층이 늘 켜진 나머지다.

모델이 아니라 방법

이 계보를 읽기 쉽게 만드는 습관 셋. 모든 손잡이에 곡선이 붙는다. K2의 sparsity와 head 수 선택은 각각 그림 하나(Fig. 5, Fig. 6)이고, 비용 쪽은 모델이 쓰일 문맥에서 계산했다. 새 mixer는 먼저 작게 증명한다. Kimi Linear의 1.4T 토큰 대조 비교(같은 데이터, 같은 레시피, MLA vs GDN-H vs KDA)가 K3가 token mixer에 대해 기대는 근거다. K3 자체에는 KDA·AttnRes·Quantile Balancing·SiTU-GLU의 ablation이 없다. 안정화 수정은 국소적이다. QK-Clip은 문턱을 넘은 head의 Wq,WkW_q, W_k만 건드린다. SiTU-GLU는 활성 하나만 묶는다. decay 하한은 kernel이 유계여야 했던 범위만 자른다. 어느 것도 정상 영역에서 블록이 계산하는 것을 바꾸지 않는다.

열린 질문은 DeepSeek V4와 같다. 2.8T, sparsity 56에서도 48B 규모의 순서가 맞나? K3 보고서는 구조, 데이터, 레시피를 2.5배 한 숫자에 묶었으므로 답할 수 없다.

확인 문제Check yourself

K2는 긴 문맥 비용 때문에 head를 128에서 64로 줄였는데 K3는 MLA head를 96개 쓴다. 왜 모순이 아닌가?

흡수 디코드에서 캐시 토큰당 attention MAC은 (MLA 층 수) × (head 수) × 1,088에 비례한다. K2: 61×64=3,90461\times64=3{,}904 head-층, K3: 24×96=2,30424\times96=2{,}304로 층당 head가 1.5배인데도 K2의 59%다. KDA 층의 비용은 문맥과 함께 자라지 않는다. 전역 층 대부분을 바꾼 것이 head 예산을 되사 줬다.

확인 문제Check yourself

K3의 LatentMoE는 토큰당 expert 16개를 활성화한다(K2는 8개). 토큰당 all-to-all dispatch 양은?

토큰당 dispatch 양은 (활성 routed expert 수) × (보내는 폭)이다. K2 8×7,168=57,3448\times7{,}168=57{,}344, K3 16×3,584=57,34416\times3{,}584=57{,}344. shared expert는 full-width hidden으로 로컬에서 돌고 dispatch되지 않는다. 대가는 더 길고 조건이 나쁜 routed 경로(W↓\mathbf W^\downarrow → expert → W↑\mathbf W^\uparrow)이고, 그래서 K3는 up-projection 앞 RMSNorm과 SiTU-GLU를 더한다.

정리

  • K2 = DeepSeek-V3 골격 + 손잡이 둘: 활성 8개에서 expert 256 → 384(sparsity 스케일링 법칙: 같은 loss까지 sparsity 8/16/32보다 1.69×/1.39×/1.15× 적은 FLOPs), head 128 → 64(128K에서 추론 FLOPs +83%인데 loss 이득 ≤1.2%, 우리 재계산 +76%–+86%). 안정성은 MuonClip.
  • Kimi Linear는 48B-A3B에서 1.4T 토큰 대조 비교로 mixer를 검증했다. KDA(채널별 decay) 3 : MLA(NoPE) 1이 전부-MLA와 GDN-H를 이기고, 3:1은 sweep에서 나왔으며, KV −74%, 1M에서 TPOT 6.3×.
  • K3는 이를 93층(KDA 69 + Gated MLA 24)으로 키우고, decay 하한으로 chunk kernel을 전부 matmul로 만들었으며, 남은 attention 예산으로 96 heads를 K2 토큰당 attention 비용의 59%에 썼다.
  • 깊이: Block Attention Residuals(12층 × 8블록). 폭: Stable LatentMoE, 3,584차원 latent에서 896개 중 16개 expert를 K2의 dispatch 폭으로, RMSNorm·SiTU-GLU·Quantile Balancing으로 안정화.
  • K3는 약 10.5K 토큰 위에서 K2보다 메모리를 덜, 약 41K 위에서 FLOPs를 덜 쓴다. 긴 에이전트 문맥을 위한 설계이고, 부품 근거는 더 작은 규모의 논문에서 온다.

더 읽을거리Further reading