Frontier 아키텍처 딥다이브Architecture Deep Dives
MoE, MLA, sparse·linear attention, Mamba 하이브리드, MTP — 부품을 하나씩 해부하고, frontier 모델들이 왜 그 조합을 골랐는지 직접 조작하며 따라간다.MoE, MLA, sparse and linear attention, Mamba hybrids, MTP — take each component apart, then follow why frontier models chose their combinations by manipulating them yourself.
- 설계 공간: 블록의 손잡이와 비용The design space: the knobs of a block and what they cost45 분min
프론티어 모델의 블록을 손잡이 몇 개(d, 층, head, KV 폭, expert 총·활성·shared, expert 폭, latent, 어휘, 전역 층 비율, 문맥)로 적고, 각 손잡이가 메모리·FLOPs·KV라는 세 청구서에 어떻게 찍히는지 식으로 유도한다. 공개된 config로 DeepSeek-V3/V3.2/V4, Kimi K2/K3, Qwen3/Qwen3.8, gpt-oss, MAI-Base, Nemotron 3 Ultra의 보고된 파라미터 수를 재현하고, 같은 모델로 문맥 길이에 따른 비용 순위를 비교한다.Write a frontier block down as a handful of knobs (d, layers, heads, KV width, experts total/active/shared, expert width, latent, vocabulary, full-attention share, context) and derive how each knob lands on three bills — memory, FLOPs and KV. With released configs we reproduce the reported parameter counts of DeepSeek-V3/V3.2/V4, Kimi K2/K3, Qwen3/Qwen3.8, gpt-oss, MAI-Base and Nemotron 3 Ultra, then compare how their costs re-order as the context grows.
- MoE 해부: routing, 세분화·shared expert, 부하 균형, dropless, LatentMoEAnatomy of MoE: routing, fine-grained and shared experts, load balancing, dropless, LatentMoE55 분min
MoE 층을 router 식부터 GPU 사이 all-to-all까지 해부한다. softmax·sigmoid·√softplus gate와 재정규화, 세분화 expert의 조합 수와 shared expert, 다섯 가지 부하 균형(aux loss micro/global, aux-free bias, Quantile Balancing)을 같은 토큰 흐름에서 비교하고, capacity·token dropping·multi-round dropless, expert parallel 통신량, LatentMoE와 sparsity scaling을 식과 시뮬레이션으로 정리한다.Take an MoE layer apart from the router equation to the all-to-all between GPUs. Softmax, sigmoid and √softplus gates and renormalisation; the combinatorics of fine-grained experts and the shared expert; five load-balancing schemes (aux loss on micro or global batch, aux-free bias, Quantile Balancing) run on the same token stream; capacity, token dropping and multi-round dropless; expert-parallel communication volume; LatentMoE and sparsity scaling — each with equations and a simulation.
- Attention과 KV: MHA → GQA → MLA, sliding window·sink, local/globalAttention and KV: MHA → GQA → MLA, sliding windows and sinks, local/global50 분min
KV cache를 줄이는 세 갈래(head 공유 GQA/MQA, 저차원 latent MLA, 층마다 다른 시야 sliding window)를 식과 NumPy로 유도한다. MLA의 학습(MHA) 모드와 decode(흡수된 MQA) 모드가 같은 함수임을 확인하고, RoPE가 왜 latent 밖으로 나가야 하는지와 세 가지 해법(decoupled key, NoPE, partial RoPE)을 비교한다. decode 산술 강도로 MLA가 memory-bound를 벗어나는 이유를, 장난감 다중 hop 검색으로 local:global 비율의 KV–recall 거래를 본다.Derive, with equations and NumPy, the three ways to shrink the KV cache — sharing heads (GQA/MQA), a low-rank latent (MLA), and giving layers different fields of view (sliding windows). Check that MLA's training (MHA) mode and decode (absorbed MQA) mode are the same function, see why RoPE has to live outside the latent and compare the three fixes (decoupled key, NoPE, partial RoPE). Use decode arithmetic intensity to see why MLA leaves the memory-bound regime, and a toy multi-hop retrieval to see the KV-versus-recall trade-off of local:global ratios.
- Sparse attention: NSA·DSA·QSA·CSA/HCA로 보는 top-k 선택Sparse attention: NSA, DSA, QSA, CSA/HCA45 분min
2025–26년의 sparse attention 네 가지(NSA의 압축·선택·window 세 갈래, DeepSeek-V3.2 DSA의 lightning indexer, Qwen3.8의 block 압축 indexer QSA, DeepSeek-V4의 CSA/HCA)를 "싸게 점수 매기고, top-k를 고르고, 정확히 attention"이라는 한 틀로 정리한다. 공개 설정으로 query당 비용을 점수·선택·window로 나눠 세고, 장난감 needle 검색으로 토큰 단위 대 block 단위 선택과 평균 pooling의 희석을 실험한다.Put the sparse attentions of 2025–26 — NSA's compress/select/window branches, DeepSeek-V3.2's DSA lightning indexer, Qwen3.8's block-compressed QSA indexer and DeepSeek-V4's CSA/HCA — into one frame, "score cheaply, select top-k, attend exactly". Count each design's per-query cost from its released configuration, split into scoring, selection and window, and run a toy needle-retrieval experiment on token- versus block-level selection and the dilution of mean pooling.
- Linear attention과 SSM — 고정 크기 상태로 문맥 압축하기Linear attention and SSMs — compressing context into a fixed-size state60 분min
linear attention을 outer-product fast-weight 메모리로 보고, delta rule → Gated DeltaNet → KDA, Mamba → Mamba-2의 SSD 쌍대성(state space ↔ masked attention), lightning attention을 하나의 점화식 가족으로 묶는다. chunk 병렬 알고리즘을 유도해 NumPy로 순환형과 일치를 확인하고, associative recall 실험으로 고정 상태의 용량 한계를 재며, 실제 config로 하이브리드 비율별 메모리를 계산해 왜 full attention 층을 일부 남기는지 본다.Read linear attention as an outer-product fast-weight memory and put the delta rule → Gated DeltaNet → KDA, Mamba → Mamba-2's SSD duality (state space ↔ masked attention) and lightning attention into one family of recurrences. Derive the chunkwise-parallel algorithm and check it against the recurrence in NumPy, measure the capacity limit of a fixed state with an associative-recall experiment, and compute memory per hybrid ratio from real configs to see why hybrids keep some full-attention layers.
- 안정화 부품 — norm 위치, logit 통제, residual 변형, 긴 문맥의 위치 인코딩Stability components — norm placement, logit control, residual variants, positions at long context60 분min
규모가 커질 때 깨지는 세 곳을 부품 단위로 본다. norm 위치(pre/post/sandwich/reordered/DeepNorm)가 신호 전파를 어떻게 바꾸는지, attention logit 성장을 QK-norm·QK-clip·soft-cap·z-loss가 각각 어떻게 막는지, residual stream을 넓히는 HC·mHC(Sinkhorn)·Gated Residual·Attention Residuals가 왜 필요한지, RoPE base·PI·NTK·YaRN·Llama 3 스케일링·partial RoPE·NoPE가 긴 문맥에서 무엇을 고치는지를 그림과 코드로 확인한다.The three places that break as models grow, one component at a time: how norm placement (pre/post/sandwich/reordered/DeepNorm) changes signal propagation; how QK-norm, QK-clip, soft-capping and z-loss each bound logit growth; why HC, mHC (Sinkhorn), Gated Residual and Attention Residuals widen the residual stream; and what RoPE base, PI, NTK, YaRN, Llama-3 scaling, partial RoPE and NoPE fix at long context — with figures and code.
- 모델의 양 끝 — multi-token prediction, 어휘, tying, n-gram 임베딩Both ends of the model — multi-token prediction, vocabulary, tying, n-gram embeddings50 분min
모델이 무엇을 예측하고(MTP) 무엇을 읽는지(어휘, 임베딩 tying, n-gram 임베딩)를 비용과 함께 본다. Gloeckle의 병렬 head와 DeepSeek-V3의 순차 모듈을 비교하고, MTP를 speculative decoding drafter로 쓸 때의 수락률 수학을 유도·검증하며, 어휘 크기가 파라미터·FLOPs·logits 메모리를 어떻게 정하는지, Engram과 Qwen3.8의 해시 n-gram 테이블이 왜 FLOPs 없이 파라미터를 늘리는 축인지 계산한다.What the model predicts (MTP) and what it reads (vocabulary, embedding tying, n-gram embeddings), with their costs. Compare Gloeckle's parallel heads with DeepSeek-V3's sequential modules, derive and verify the acceptance math of MTP as a speculative-decoding drafter, compute how vocabulary size sets parameters, FLOPs and logits memory, and why the hashed n-gram tables of Engram and Qwen3.8 are an axis that adds parameters without FLOPs.
- DeepSeek 계보: V2 → V3 → V3.2 → V4 → V4.1The DeepSeek lineage: V2 → V3 → V3.2 → V4 → V4.150 분min
DeepSeek 다섯 세대가 블록의 어느 부분을 왜 바꿨는지를 토큰당 비용의 세 인수(항목 크기 × 저장 항목 수 × KV를 가진 층 수)와 활성 파라미터로 읽는다. 각 세대가 공격한 병목, 보고서의 근거, 그리고 공개 config로 다시 계산한 KV·FLOPs와 교차점.Why each of five DeepSeek generations changed which part of the block, read through the per-token cost — entry size × entries stored × layers holding KV, plus active parameters. The bottleneck each generation attacked, the evidence its report gives, and KV/FLOPs and crossovers recomputed from the public configs.
- Qwen 계보: Qwen3 → Qwen3-Next → Qwen3.5 → Qwen3.8-NextThe Qwen lineage: Qwen3 → Qwen3-Next → Qwen3.5 → Qwen3.8-Next45 분min
Qwen이 attention 층의 3/4를 고정 상태 Gated DeltaNet으로 바꾸고, 남은 1/4를 gate와 sparse 읽기로 다시 설계하고, residual을 넓힌 순서를 비용으로 읽는다. 하이브리드가 메모리를 더 쓰는 짧은 문맥, 이득이 나는 교차점(약 1K 토큰), 남은 attention 층이 FLOPs를 지배하는 이유를 config로 계산한다.How Qwen replaced three quarters of its attention layers with fixed-state Gated DeltaNet, then redesigned the remaining quarter with a gate and sparse reads, then widened the residual — read as costs. From the configs we compute where the hybrid costs more memory, where it pays off (~1K tokens), and why the remaining attention layers still dominate FLOPs.
- Kimi 계보: K2 → Kimi Linear → K3The Kimi lineage: K2 → Kimi Linear → K345 분min
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.
- Nemotron — Mamba 하이브리드 계보Nemotron — the hybrid Mamba lineage60 분min
Nemotron-H → Nano 2 → Nemotron 3(Nano·Super·Ultra) → Nemotron 4(발표만)로 이어지는 NVIDIA의 하이브리드 계보를 config에서 직접 읽는다. Mamba-2가 attention 대부분을 대신하는 이유(decode 비용과 고정 state)를 계산으로 유도하고, 그래도 attention을 몇 층 남기는 이유(고정 state의 recall 용량, 층 배치 ablation)를 장난감 실험과 층 배치 편집기로 확인한 뒤, LatentMoE·MTP·NVFP4가 이 골격에 어떻게 얹히는지 본다.NVIDIA's hybrid line — Nemotron-H → Nano 2 → Nemotron 3 (Nano, Super, Ultra) → Nemotron 4 (announced only) — read directly from the configs. We derive why Mamba-2 replaces most attention layers (decode cost, constant state), check with a toy experiment and a layer-pattern editor why a few attention layers stay (the recall capacity of a fixed state, the layer-pattern ablations), and see how LatentMoE, MTP and NVFP4 sit on top of this skeleton.
- 설계 선택 비교 — gpt-oss · MiMo · MiniMax · GLM-5 · MAIDesign choices compared — gpt-oss, MiMo-V2, MiniMax-M2, GLM-5, MAI-Base-255 분min
다섯 보고서(gpt-oss, MiMo-V2(.6), MiniMax-M2, GLM-5, MAI-Base-2)와 앞 레슨의 Nemotron 3를 하나의 행렬로 놓고, attention 종류·비율, MoE 구성, MTP, 정밀도, 컨텍스트를 각 보고서가 밝힌 이유와 함께 비교한다. 모든 캐시를 한 식으로 계산하고, 하이브리드 attention에 대한 서로 반대되는 증거를 나란히 읽은 뒤, 배포 목표(긴 컨텍스트 agent, 저지연 채팅, 값싼 batch)에 따라 어떤 선택이 이기는지 비용 모델로 직접 확인한다.One matrix for five reports (gpt-oss, MiMo-V2(.6), MiniMax-M2, GLM-5, MAI-Base-2) plus Nemotron 3 from the previous lesson — attention type and ratio, MoE configuration, MTP, precision and context, each with the reason the report gives. We compute every cache with one formula, read the contradictory evidence on hybrid attention side by side, and use a cost model to see which choices win for each deployment target (long-context agent, low-latency chat, cheap batch inference).