Kimi K3 research notes: architecture, training/infra, open-source inventory, evaluation
Browse files- README.md +92 -0
- k3_architecture_notes.md +379 -0
- k3_evaluation_summary.md +219 -0
- k3_open_source_inventory.md +135 -0
- k3_training_and_infra_notes.md +632 -0
README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
tags:
|
| 4 |
+
- kimi-k3
|
| 5 |
+
- mixture-of-experts
|
| 6 |
+
- linear-attention
|
| 7 |
+
- research-notes
|
| 8 |
+
- survey
|
| 9 |
+
- open-source-models
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Kimi K3 — Research Notes & Open-Source Capability Inventory
|
| 13 |
+
|
| 14 |
+
> Study notes on **Kimi K3: Open Frontier Intelligence** (Moonshot AI, July 2026) — the first open
|
| 15 |
+
> 3T-class model — plus a **verified inventory of everything the K3 release actually open-sourced**.
|
| 16 |
+
> Maintained by **[Diogenes](https://huggingface.co/DiogenesLab)** / **[Oratis](https://huggingface.co/Oratis)**.
|
| 17 |
+
|
| 18 |
+
Kimi K3 is a 2.78T-parameter / 104.2B-activated natively multimodal MoE with a 1M-token context
|
| 19 |
+
window. It is interesting well beyond its size: it solves three problems that normally appear
|
| 20 |
+
separately — **sequence-length scaling, extreme MoE width, and depth-wise information flow** — and
|
| 21 |
+
each solution detaches cleanly from the rest of the model.
|
| 22 |
+
|
| 23 |
+
These notes are written to be *learned from*, not just skimmed: the emphasis is on **why** each
|
| 24 |
+
design exists and what failure mode it removes.
|
| 25 |
+
|
| 26 |
+
## Contents
|
| 27 |
+
|
| 28 |
+
| File | What it is |
|
| 29 |
+
|------|-----------|
|
| 30 |
+
| [`k3_architecture_notes.md`](k3_architecture_notes.md) | Architecture deep dive — Kimi Delta Attention and the lower-bounded decay trick, Attention Residuals, Stable LatentMoE (Normalized LatentMoE + SiTU-GLU + Quantile Balancing), MoonViT-V2 trained from scratch, Per-Head Muon. Includes the K2 → K3 spec diff. |
|
| 31 |
+
| [`k3_training_and_infra_notes.md`](k3_training_and_infra_notes.md) | Pre-training (data, scaling law methodology, the four-stage 8K→1M context curriculum), post-training (SFT → 9 domain × effort RL experts → multi-teacher on-policy distillation, MXFP4 QAT, EAGLE-3 draft + LK loss), RL environments and task synthesis, and the infrastructure (FlashKDA, KDA Context Parallelism, MoonEP, AgentENV, KDA-aware prefix caching). |
|
| 32 |
+
| [`k3_open_source_inventory.md`](k3_open_source_inventory.md) | **The practical artifact.** Every open-sourced component of the K3 release, each independently verified against its HF/GitHub page: what it does, its license, its hardware requirements, and how it maps back to a section of the technical report. Includes a breakdown of the Kimi K3 License, which is *not* MIT. |
|
| 33 |
+
| [`k3_evaluation_summary.md`](k3_evaluation_summary.md) | Where K3 actually lands — public benchmarks, in-house suites, the cyber-capability evaluation, third-party results (Artificial Analysis, Vals AI, LMArena), and cost-efficiency. |
|
| 34 |
+
|
| 35 |
+
## Three things worth knowing if you read nothing else
|
| 36 |
+
|
| 37 |
+
1. **A parameterization change bought an order of magnitude of hardware utilization.** KDA's chunkwise
|
| 38 |
+
form needs to rescale keys by the reciprocal cumulative decay `1/Γ`, which grows without bound and
|
| 39 |
+
overflows in low precision — so the predecessor (Kimi Linear) had to compute diagonal tiles with an
|
| 40 |
+
explicit position-pair path that cannot use Tensor Cores. K3 bounds the log-decay from below with a
|
| 41 |
+
scaled sigmoid (`g_min = −5`), which puts the cumulative decay over a 16-token tile in `(−80, 0)` and
|
| 42 |
+
the reciprocal below `e^80` — **inside BF16's dynamic range**. Diagonal and off-diagonal tiles now both
|
| 43 |
+
run as dense Tensor Core matmuls, and the special-case path is deleted. The algorithm did not change;
|
| 44 |
+
only the range of one quantity did.
|
| 45 |
+
|
| 46 |
+
2. **Contrastive vision pre-training turned out to be unnecessary as an initialization.** K3's vision
|
| 47 |
+
tower, MoonViT-V2, is trained **entirely from scratch with next-token prediction** rather than
|
| 48 |
+
initialized from SigLIP. The reported motivation is stability — the SigLIP-initialized baseline shows
|
| 49 |
+
persistently higher vision-tower gradient norms with frequent spikes throughout joint optimization —
|
| 50 |
+
and MoonViT-V2 **matches it on vision evaluations anyway**. This is a direct challenge to a default
|
| 51 |
+
design choice in multimodal LLMs. (Caveat worth keeping: this is evidence *at 2.8T scale with a full
|
| 52 |
+
multimodal corpus*; it does not automatically transfer to small-scale fine-tuning regimes.)
|
| 53 |
+
|
| 54 |
+
3. **The open-source surface is much larger than the weights.** Six engineering repositories ship under
|
| 55 |
+
MIT or Apache-2.0 — including the attention kernels, the expert-parallelism library, and the microVM
|
| 56 |
+
sandbox platform that powered the agentic RL — while the weights themselves carry a *different*,
|
| 57 |
+
more restrictive license. Two of the repos (`minitriton`, `nano-kpu`) were written by K3 itself and
|
| 58 |
+
are explicitly labeled demonstrations rather than products. See
|
| 59 |
+
[`k3_open_source_inventory.md`](k3_open_source_inventory.md).
|
| 60 |
+
|
| 61 |
+
## Notes on method
|
| 62 |
+
|
| 63 |
+
- Primary source is the **47-page Kimi K3 technical report** (Kimi Team, Moonshot AI). Every
|
| 64 |
+
open-source claim in the inventory was **independently re-verified** against the live HF or GitHub
|
| 65 |
+
page rather than transcribed from the report — a few details (exact hardware requirements, merge
|
| 66 |
+
status of the upstream FLA context-parallel PR, license thresholds) are only available there.
|
| 67 |
+
- Claims are marked **[report]** (stated in the technical report), **[verified]** (independently
|
| 68 |
+
checked against a live page), or **[analysis]** (our inference, not a claim of the original authors).
|
| 69 |
+
- This is a **curated public subset** of a larger internal research effort. Organization-specific
|
| 70 |
+
roadmap judgments are intentionally not included; the focus here is the general method, the
|
| 71 |
+
mechanisms, and the reusable artifacts.
|
| 72 |
+
- Last refreshed **2026-07-29**.
|
| 73 |
+
|
| 74 |
+
## Citation
|
| 75 |
+
|
| 76 |
+
The underlying work is Moonshot AI's:
|
| 77 |
+
|
| 78 |
+
```bibtex
|
| 79 |
+
@techreport{kimi2026k3,
|
| 80 |
+
title = {Kimi K3: Open Frontier Intelligence},
|
| 81 |
+
author = {Kimi Team},
|
| 82 |
+
year = {2026},
|
| 83 |
+
institution = {Moonshot AI},
|
| 84 |
+
url = {https://www.kimi.com/blog/kimi-k3}
|
| 85 |
+
}
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
## License
|
| 89 |
+
|
| 90 |
+
These notes released under **CC BY 4.0**. The Kimi K3 model, its technical report, and all cited
|
| 91 |
+
repositories belong to their respective authors under their own licenses — see
|
| 92 |
+
[`k3_open_source_inventory.md`](k3_open_source_inventory.md) for the per-artifact breakdown.
|
k3_architecture_notes.md
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Kimi K3 — Architecture Notes
|
| 2 |
+
|
| 3 |
+
> Deep dive on the architecture of **Kimi K3: Open Frontier Intelligence** (Kimi Team, Moonshot AI,
|
| 4 |
+
> July 2026). Source: the 47-page technical report. Claims marked **[report]** are stated there;
|
| 5 |
+
> **[analysis]** is our inference.
|
| 6 |
+
|
| 7 |
+
The organizing idea is stated plainly in the report and it is worth taking literally: **a Transformer
|
| 8 |
+
moves information along three axes — sequence length, network depth, and model width — and K3
|
| 9 |
+
replaces one component on each axis.**
|
| 10 |
+
|
| 11 |
+
| Axis | Kimi K2 | Kimi K3 | What it fixes |
|
| 12 |
+
|---|---|---|---|
|
| 13 |
+
| Sequence (token mixing) | All MLA | **Hybrid: 3× KDA + 1× Gated MLA**, repeated | Compute/memory at 1M context |
|
| 14 |
+
| Depth (layer mixing) | Standard residual accumulation | **Attention Residuals (Block AttnRes)** | Deep layers only see a compressed history |
|
| 15 |
+
| Width (channel mixing) | DeepSeekMoE, 384 experts | **Stable LatentMoE, 896 experts / 16 active** | Expert specialization space vs. communication and stability |
|
| 16 |
+
| Vision | — | **MoonViT-V2, 401M, trained from scratch** | Joint-optimization instability |
|
| 17 |
+
| Optimizer | Muon | **Per-Head Muon** | Uneven update scale across heads |
|
| 18 |
+
|
| 19 |
+
Together with refined data and training recipes these deliver an approximately **2.5× improvement in
|
| 20 |
+
overall scaling efficiency** over K2 — same FLOPs, lower held-out validation loss. The report does
|
| 21 |
+
**not** decompose how much of that comes from architecture vs. data vs. recipe. **[report]**
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
## 0. Specification diff, K2 → K3
|
| 26 |
+
|
| 27 |
+
| | Kimi K2 | Kimi K3 | Δ |
|
| 28 |
+
|---|---|---|---|
|
| 29 |
+
| Layers | 61 | **93** | ↑52% |
|
| 30 |
+
| Total parameters | 1.04T | **2.78T** | ↑167% |
|
| 31 |
+
| Activated parameters | 32.6B | **104.2B** | ↑220% |
|
| 32 |
+
| Hidden dimension | 7,168 | 7,168 | = |
|
| 33 |
+
| Latent MoE dimension | — | **3,584 (0.5×)** | new |
|
| 34 |
+
| MoE hidden dim per expert | 2,048 | 3,072 | ↑50% |
|
| 35 |
+
| Routed experts | 384 | **896** | ↑133% |
|
| 36 |
+
| Experts active per token | 8 | **16** | ↑100% |
|
| 37 |
+
| Shared experts | 1 | **2** | ↑100% |
|
| 38 |
+
| Attention heads | 64 | 96 | ↑50% |
|
| 39 |
+
| Dense layers | 1 | 1 | = |
|
| 40 |
+
| Vocabulary | 160K | 160K | = |
|
| 41 |
+
| Training context length | 128K | **1M** | 8× |
|
| 42 |
+
| Attention mechanism | MLA | **Hybrid KDA–MLA** | — |
|
| 43 |
+
| Activation | SwiGLU | **SiTU-GLU** | — |
|
| 44 |
+
| Attention-layer composition | 61 MLA | **69 KDA + 24 MLA** | — |
|
| 45 |
+
| MTP layers | 1 | 1 | = |
|
| 46 |
+
| ViT params / layers / patch / heads | — | **401M / 27 / 14 / 12** | new |
|
| 47 |
+
|
| 48 |
+
Sparsity is 896/16 = **56**. That ratio is the central tension of the design: a bigger expert pool
|
| 49 |
+
with more experts active per token buys specialization, but communication and expert-weight traffic
|
| 50 |
+
grow with routing multiplicity. LatentMoE exists to make that trade affordable (§3).
|
| 51 |
+
|
| 52 |
+
---
|
| 53 |
+
|
| 54 |
+
## 1. Hybrid attention
|
| 55 |
+
|
| 56 |
+
Each block is **3 KDA layers followed by 1 Gated MLA layer** — a 3:1 ratio, repeated throughout the
|
| 57 |
+
backbone. An **additional Gated MLA layer sits at the end of the backbone**, guaranteeing the final
|
| 58 |
+
layer always performs global attention.
|
| 59 |
+
|
| 60 |
+
### 1.1 Kimi Delta Attention
|
| 61 |
+
|
| 62 |
+
KDA comes from Kimi Linear ([arXiv:2510.26692](https://arxiv.org/abs/2510.26692), MIT, with released
|
| 63 |
+
48B-A3B checkpoints). It is a **delta-rule recurrence with a channel-wise forget gate**:
|
| 64 |
+
|
| 65 |
+
```
|
| 66 |
+
S_t = (I − β_t k_t k_tᵀ) Diag(α_t) S_{t−1} + β_t k_t v_tᵀ
|
| 67 |
+
ō_t = S_tᵀ q_t
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
- `α_t ∈ (0,1)^{d_k}` — a **channel-wise** one-step retention factor. Not a scalar: every channel
|
| 71 |
+
decides its own forgetting rate.
|
| 72 |
+
- `β_t ∈ (0,1)` — delta-rule write strength.
|
| 73 |
+
- q/k/v projections apply ShortConv then Swish; q and k are further L2-normalized.
|
| 74 |
+
|
| 75 |
+
The state `S ∈ R^{d_k×d_v}` is **fixed size** — it replaces a KV cache that grows with sequence
|
| 76 |
+
length. That is the physical basis for 1M context.
|
| 77 |
+
|
| 78 |
+
### 1.2 The lower-bounded decay — the most instructive decision in the report
|
| 79 |
+
|
| 80 |
+
This is worth studying not for the result but for the *shape* of the reasoning: **the algorithm did
|
| 81 |
+
not change; only the range of one quantity was tightened, and that bought a dense Tensor Core path.**
|
| 82 |
+
|
| 83 |
+
**The problem.** KDA is recurrent across chunks and parallel within each chunk. The chunkwise form
|
| 84 |
+
rescales keys by the reciprocal cumulative decay `1/Γ^{1→C}`. Since `Γ` is a product of retention
|
| 85 |
+
factors in `(0,1)`, this reciprocal **grows without bound and overflows in finite precision**.
|
| 86 |
+
|
| 87 |
+
**Kimi Linear's answer.** Control the numerical range by computing relative decay in log space and
|
| 88 |
+
splitting each chunk into secondary 16-token tiles. Off-diagonal tiles can then use dense Tensor Core
|
| 89 |
+
matmuls — but **diagonal tiles still require explicit position-pair computation**, which becomes the
|
| 90 |
+
main intra-chunk bottleneck.
|
| 91 |
+
|
| 92 |
+
**K3's answer.** Change the mapping from decay logits `z` to per-step log-decay `g`:
|
| 93 |
+
|
| 94 |
+
| | Mapping | Range |
|
| 95 |
+
|---|---|---|
|
| 96 |
+
| GDN / Mamba-2 / Kimi Linear | `g = −e^{A_h} · Softplus(z)` | `(−∞, 0)` — unbounded |
|
| 97 |
+
| **Kimi K3** | `g = g_min · Sigmoid(e^{A_h} z)` | `(g_min, 0)` — **bounded, `g_min = −5` fixed** |
|
| 98 |
+
|
| 99 |
+
Then `α = exp(g) ∈ (e^{g_min}, 1)`. With `g_min = −5`, every retention factor satisfies
|
| 100 |
+
`α ≥ e^{−5} ≈ 6.7×10⁻³`, so the cumulative log-decay over a **16-token tile lies in `(−80, 0)`**, the
|
| 101 |
+
reciprocal rescaling factor is **smaller than `e^80`**, and that **remains within the BF16 dynamic
|
| 102 |
+
range**.
|
| 103 |
+
|
| 104 |
+
**Consequence:** both diagonal and off-diagonal causal tiles now use dense Tensor Core matmuls. The
|
| 105 |
+
position-pair diagonal path is **eliminated entirely**. `A_h` is a learnable per-head log-scale
|
| 106 |
+
initialized to 0; `b_α` follows Kimi Linear's initialization. The report notes this parameterization
|
| 107 |
+
is closely related to lower-bounded recurrence gates in prior work (HGRN2, Griffin, RWKV-7).
|
| 108 |
+
|
| 109 |
+
> **[analysis]** The transferable lesson is diagnostic: whenever a kernel needs a special-cased
|
| 110 |
+
> branch, an fp32 fallback, or a separate code path "for numerical reasons", the first question is
|
| 111 |
+
> whether the algorithm genuinely requires it — or whether some freely-chosen parameterization simply
|
| 112 |
+
> left a range wider than it needed to be.
|
| 113 |
+
|
| 114 |
+
### 1.3 Full-rank output gate
|
| 115 |
+
|
| 116 |
+
Kimi Linear used a low-rank output gate. K3 replaces it with an **input-dependent full-rank
|
| 117 |
+
projection**, applied after head-wise RMSNorm of the recurrent output:
|
| 118 |
+
|
| 119 |
+
```
|
| 120 |
+
y = W_o [ Sigmoid(W_g x) ⊙ RMSNorm(ō) ]
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
### 1.4 Gated MLA, and NoPE
|
| 124 |
+
|
| 125 |
+
MLA (from DeepSeek-V2) compresses each token's KV into a low-dimensional latent `c = W_c x`, caching
|
| 126 |
+
`c` and reconstructing keys and values through learned up-projections during attention. K3 retains it
|
| 127 |
+
in the periodic global-attention layers and adds the same **input-dependent, channel-wise full-rank
|
| 128 |
+
output gate**. `W_g` is full rank, matching KDA's new parameterization; the gate lets each token
|
| 129 |
+
modulate which channels it reads from global attention.
|
| 130 |
+
|
| 131 |
+
**All MLA layers use NoPE — no positional encoding at all.** Positional information is carried
|
| 132 |
+
implicitly by KDA's recurrence and decay. Two consequences:
|
| 133 |
+
|
| 134 |
+
1. **Context extension requires no positional-encoding changes** — no RoPE base retuning, no YaRN
|
| 135 |
+
interpolation. The model extrapolates directly to 1M tokens.
|
| 136 |
+
2. It cleanly divides labor: KDA layers provide position-sensitive, recency-aware mixing; MLA layers
|
| 137 |
+
provide unrestricted, position-agnostic global content interaction.
|
| 138 |
+
|
| 139 |
+
**One low-precision detail.** To correct the biased rounding error that arises in flash attention,
|
| 140 |
+
K3 adopts the method of [arXiv:2510.04212](https://arxiv.org/abs/2510.04212) and **keeps the attention
|
| 141 |
+
output in FP32 during training**. That doubles the on-chip footprint of the output tile — so the
|
| 142 |
+
training kernel was redesigned to **overlap it with the KV staging buffers instead of the query tile**,
|
| 143 |
+
freeing shared memory for a deeper KV pipeline and higher throughput.
|
| 144 |
+
|
| 145 |
+
---
|
| 146 |
+
|
| 147 |
+
## 2. Attention Residuals — attention applied to the depth axis
|
| 148 |
+
|
| 149 |
+
**The motivation, stated as an analogy worth remembering:** standard residual connections compress
|
| 150 |
+
all prior information into a single state `h_l` over depth — *a bottleneck reminiscent of RNNs over
|
| 151 |
+
time*. Transformers replaced recurrence over time with attention, letting each position selectively
|
| 152 |
+
access all previous positions with data-dependent weights. AttnRes applies the same methodology to
|
| 153 |
+
depth: **each layer selectively retrieves representations from all preceding layers** rather than
|
| 154 |
+
accumulating them uniformly.
|
| 155 |
+
|
| 156 |
+
### 2.1 Full Attention Residuals
|
| 157 |
+
|
| 158 |
+
Each layer `l` gets a learnable pseudo-query `q_l = w_l ∈ R^d`; keys and values are the outputs of
|
| 159 |
+
all preceding layers, with `i = 0` being the token embedding:
|
| 160 |
+
|
| 161 |
+
```
|
| 162 |
+
φ(q, k) = exp( qᵀ RMSNorm(k) ) ← RMSNorm prevents large-magnitude layers dominating
|
| 163 |
+
α_{i→l} = φ(q_l, k_i) / Σ_j φ(q_l, k_j)
|
| 164 |
+
h_l = Σ_{i=0}^{l−1} α_{i→l} · v_i
|
| 165 |
+
```
|
| 166 |
+
|
| 167 |
+
Since depth is modest (`L < 100`), the `O(L²d)` arithmetic is affordable. **The practical overhead is
|
| 168 |
+
the `O(Ld)` memory** of keeping all layer outputs alive — plus cross-stage communication under
|
| 169 |
+
pipeline parallelism.
|
| 170 |
+
|
| 171 |
+
### 2.2 Block Attention Residuals — what K3 actually uses
|
| 172 |
+
|
| 173 |
+
Partition `L` layers into `N` blocks of `S = L/N` layers.
|
| 174 |
+
|
| 175 |
+
- **Within a block**, layer outputs are reduced to a single block representation by summation:
|
| 176 |
+
`b_n = Σ_{j∈B_n} f_j(h_j)`, with `b_0 = h_1` so the token embedding is always a source.
|
| 177 |
+
- **Across blocks**, full attention is applied over only the `N` block-level representations.
|
| 178 |
+
|
| 179 |
+
Memory and communication overhead drop from `O(Ld)` to `O(Nd)`.
|
| 180 |
+
|
| 181 |
+
**K3's configuration: 8 blocks of 12 layers** — giving a partial final block, and 9 total blocks when
|
| 182 |
+
counting the embedding layer. The report cites empirical evidence that `N ≈ 8` recovers most of the
|
| 183 |
+
benefit across model scales.
|
| 184 |
+
|
| 185 |
+
The block structure also **bounds inference-time state**, and lets the parallel inter-block results be
|
| 186 |
+
merged with the sequential intra-block partial sums via **online softmax**, significantly reducing
|
| 187 |
+
inference-time cost.
|
| 188 |
+
|
| 189 |
+
---
|
| 190 |
+
|
| 191 |
+
## 3. Stable LatentMoE — three patches that make 896 experts work
|
| 192 |
+
|
| 193 |
+
**LatentMoE** ([arXiv:2601.18089](https://arxiv.org/abs/2601.18089)) separates the model width seen by
|
| 194 |
+
the routed experts from the full width: **shared experts retain a full-width path for common
|
| 195 |
+
transformations, while specialized routed experts operate in a compact latent space of width `ℓ`.**
|
| 196 |
+
|
| 197 |
+
```
|
| 198 |
+
u = Σ_{i∈T_k(x)} p_i · E_i^routed(W↓ x) ← routed path at ℓ = 3584 (0.5 × 7168)
|
| 199 |
+
y = Σ_{j=1}^{N_s} E_j^shared(x) + W↑ RMSNorm(u) ← shared path at full width d
|
| 200 |
+
```
|
| 201 |
+
|
| 202 |
+
K3 fixes `N_s = 2` full-width shared experts per layer. This is what makes scaling channel mixing to
|
| 203 |
+
896 routed experts with 16 active per token affordable in communication and weight traffic.
|
| 204 |
+
|
| 205 |
+
But extreme sparsity amplifies two failure modes of the vanilla design, and each patch targets one.
|
| 206 |
+
|
| 207 |
+
### 3.1 Patch 1 — RMSNorm before the up-projection (Normalized LatentMoE)
|
| 208 |
+
|
| 209 |
+
**Failure mode:** the routed path composes `W↓`, a gated multi-branch expert FFN, and `W↑` into a
|
| 210 |
+
chain of nearly four consecutive matrix multiplications. That ill-conditioned structure at 2.78T scale
|
| 211 |
+
**produces exploding internal activations in the routed branch**. Original LatentMoE applies `W↑`
|
| 212 |
+
directly to the aggregated routed representation `u`, whose scale varies with the selected experts and
|
| 213 |
+
their routing weights.
|
| 214 |
+
|
| 215 |
+
**Patch:** insert an RMSNorm **between expert aggregation and the up-projection**. This reduces the
|
| 216 |
+
sensitivity of the routed branch to scale variation before it is combined with the full-width shared
|
| 217 |
+
branch. Beyond stabilizing training, the report states the additional RMSNorm **consistently improves
|
| 218 |
+
validation loss and downstream benchmarks**.
|
| 219 |
+
|
| 220 |
+
### 3.2 Patch 2 — SiTU-GLU (Sigmoid Tanh Unit GLU)
|
| 221 |
+
|
| 222 |
+
**Failure mode:** in SwiGLU **both multiplicative factors are unbounded**, so coincident large
|
| 223 |
+
coordinates produce activation outliers and raise overflow risk in low-precision arithmetic. The
|
| 224 |
+
original GLU's sigmoid gate avoids unbounded gate growth, but discards the approximately-linear
|
| 225 |
+
positive regime of Swish that makes it work.
|
| 226 |
+
|
| 227 |
+
**Patch:** apply the smooth cap `softcap(x, β) = β·tanh(x/β)` to the linear factor of the Swish gate
|
| 228 |
+
and, independently, to the up branch:
|
| 229 |
+
|
| 230 |
+
```
|
| 231 |
+
SiTU-GLU(x) = [ β₁ tanh(W_g x / β₁) ⊙ Sigmoid(W_g x) ] ⊙ [ β₂ tanh(W_u x / β₂) ]
|
| 232 |
+
```
|
| 233 |
+
|
| 234 |
+
| Property | Value |
|
| 235 |
+
|---|---|
|
| 236 |
+
| Hyperparameters | **β₁ = 4** (gate branch), **β₂ = 25** (up branch) |
|
| 237 |
+
| Output bound | `‖SiTU-GLU(x)‖_∞ ≤ β₁β₂ = 100` |
|
| 238 |
+
| Near the origin | `β tanh(z/β) = z + O(z³/β²)` — **matches SwiGLU to first order** |
|
| 239 |
+
| Limit | Recovers SwiGLU pointwise as `β₁, β₂ → ∞` |
|
| 240 |
+
|
| 241 |
+
Unlike hard clamping of gate pre-activations, **the smooth cap preserves nonzero gradients away from
|
| 242 |
+
saturation boundaries**, which the report finds gives better training behavior.
|
| 243 |
+
|
| 244 |
+
### 3.3 Patch 3 — Quantile Balancing (QB)
|
| 245 |
+
|
| 246 |
+
K3 uses **auxiliary-loss-free routing**: an expert-specific bias `b_j` is added to the router score
|
| 247 |
+
used for Top-k selection, but omitted from the mixture weights.
|
| 248 |
+
|
| 249 |
+
```
|
| 250 |
+
T_i = argtop_k(s_i + b), p_{i,j} = s_{i,j} / Σ_{r∈T_i} s_{i,r}, j ∈ T_i
|
| 251 |
+
```
|
| 252 |
+
|
| 253 |
+
Because `b` is omitted from `p`, it **regulates dispatch without altering mixture weights or the
|
| 254 |
+
gradient-based optimization of the router**.
|
| 255 |
+
|
| 256 |
+
**Failure mode:** the original method updates `b` with a fixed-step sign rule
|
| 257 |
+
`b_j ← b_j + γ·sign(ℓ̄ − ℓ_j)`. Maintaining balanced loads **becomes much harder as LatentMoE grows the
|
| 258 |
+
pool to 896 experts per layer**: `γ` trades off slow adaptation against oscillation, imbalanced routing
|
| 259 |
+
slows expert-parallel training, and some experts may end up poorly trained.
|
| 260 |
+
|
| 261 |
+
**Patch — set each bias from the router-score quantile that matches its target load.** With target
|
| 262 |
+
load `q = mk/n` for a batch of `m` tokens over `n` experts:
|
| 263 |
+
|
| 264 |
+
1. Replace Top-k selection with **Top-(k+1)** on the biased score. The first `k` entries are the
|
| 265 |
+
routes actually taken; the `(k+1)`-th entry is the cutoff `α_i` that an expert must exceed to
|
| 266 |
+
enter token `i`'s Top-k. Taking the cutoff from Top-(k+1) routing **avoids a separate
|
| 267 |
+
token-side quantile pass**.
|
| 268 |
+
2. With cutoffs fixed, the count of tokens routed to expert `j` under candidate bias `b̂_j` is
|
| 269 |
+
monotonically decreasing in the threshold `−b̂_j`. Setting that count to `q` makes `−b̂_j` the
|
| 270 |
+
`(q+1)`-th largest margin `s_{i,j} − α_i`. Since `q/m = k/n`, this is the `(1 − k/n)`-quantile:
|
| 271 |
+
|
| 272 |
+
```
|
| 273 |
+
b̂_j ← − quantile_{1−k/n}( s_{:,j} − α )
|
| 274 |
+
b ← b̂ − mean(b̂) · 1 ← mean-centering
|
| 275 |
+
```
|
| 276 |
+
|
| 277 |
+
The update **takes effect only at the next step** — a batch is never routed with a bias derived from
|
| 278 |
+
itself. The final bias is **frozen at inference**.
|
| 279 |
+
|
| 280 |
+
**Why it is principled.** Appendix C derives QB from the maximum-score balanced assignment problem.
|
| 281 |
+
The LP relaxation is exact (total unimodularity of the bipartite b-matching polytope); the convex dual
|
| 282 |
+
is minimized by **alternating exact coordinate minimization**, and both subproblems turn out to be
|
| 283 |
+
quantiles along the token and expert axes respectively — hence the name. The original sign-based
|
| 284 |
+
loss-free update is recovered as a **SignSGD step on that same dual objective**; QB jumps directly to
|
| 285 |
+
the exact coordinate minimizer. In the reported experiments it **equilibrates within a few update
|
| 286 |
+
steps even for nearly 10³ experts**.
|
| 287 |
+
|
| 288 |
+
**Making the quantile computable at scale (Appendix D).** The quantile spans the whole global batch —
|
| 289 |
+
millions of margins sharded across ranks and gradient-accumulation steps — so gathering them exactly
|
| 290 |
+
is not viable inside the training loop. K3 instead maintains a **binned histogram per expert**:
|
| 291 |
+
|
| 292 |
+
- Each rank scatter-adds its local values into a per-expert count matrix `H ∈ N^{n×B}` during the
|
| 293 |
+
forward pass, accumulating over micro-batches with **no communication**. A single all-reduce at the
|
| 294 |
+
end of the step sums local counts into the global histogram.
|
| 295 |
+
- **`B = 1000` bins** gives an error of **at most a few 10⁻³**, with no measurable residual load
|
| 296 |
+
imbalance observed.
|
| 297 |
+
- Communication is one integer all-reduce of `n × B` values per layer per step — **independent of `m`**,
|
| 298 |
+
and in their configuration **below 1% of the cost** of exchanging raw margins.
|
| 299 |
+
- Because counts are additive, the estimate is **exactly invariant to how tokens are partitioned
|
| 300 |
+
across ranks**: it is the quantile of the *pooled* global batch, not an average of per-rank
|
| 301 |
+
quantiles — which generally differ.
|
| 302 |
+
|
| 303 |
+
---
|
| 304 |
+
|
| 305 |
+
## 4. MoonViT-V2 — the vision tower trained from scratch
|
| 306 |
+
|
| 307 |
+
**The departure:** prior practice, including Kimi K2.5 itself, initializes the vision encoder from a
|
| 308 |
+
contrastively pre-trained model such as SigLIP, on the premise that pre-trained visual knowledge gives
|
| 309 |
+
the model a head start. **K3 trains MoonViT-V2 entirely from scratch with next-token prediction.**
|
| 310 |
+
|
| 311 |
+
Three reasons and results, per the report:
|
| 312 |
+
|
| 313 |
+
1. **Training stability (the primary motivation).** When a pre-trained encoder is attached to the LLM,
|
| 314 |
+
joint optimization becomes unstable. Report Fig. 6 is the evidence: the SigLIP-initialized
|
| 315 |
+
MoonViT-3D shows **persistently higher vision-tower gradient norms with frequent spikes**, while
|
| 316 |
+
MoonViT-V2 remains stable throughout training.
|
| 317 |
+
2. **Objective alignment.** Next-token prediction lets the encoder's representations be **shaped
|
| 318 |
+
directly by the language-modeling objective**, rather than by a contrastive loss that favors global
|
| 319 |
+
semantics over fine-grained textual and structural cues.
|
| 320 |
+
3. **Result.** MoonViT-V2 **matches the SigLIP-initialized baseline across vision evaluations** —
|
| 321 |
+
indicating, in the report's words, that contrastive pre-training is unnecessary as an initialization
|
| 322 |
+
for multimodal language models at scale.
|
| 323 |
+
|
| 324 |
+
> **[analysis]** This is evidence *at scale*, with a full multimodal corpus and a 2.8T backbone. It is
|
| 325 |
+
> not an argument that from-scratch vision towers win in small-scale or fine-tuning regimes, where the
|
| 326 |
+
> head start from pre-trained visual knowledge is likely still real. What generalizes more safely is
|
| 327 |
+
> the **diagnostic**: if you observe persistent vision-tower gradient spikes during joint optimization,
|
| 328 |
+
> this report says the root cause may be an objective mismatch between contrastive initialization and
|
| 329 |
+
> the language-modeling objective — not your learning rate. That makes vision-tower gradient norm a
|
| 330 |
+
> monitoring signal worth having.
|
| 331 |
+
|
| 332 |
+
**Architecture.**
|
| 333 |
+
|
| 334 |
+
- 27-layer ViT, **401M parameters**, adopting **RMSNorm and removing all bias terms** from its linear
|
| 335 |
+
and attention projections — a design that further stabilizes from-scratch optimization.
|
| 336 |
+
- **Images and videos are processed with fully shared parameters.** Attention is factorized into
|
| 337 |
+
intra-frame spatial and inter-frame temporal passes; temporal pooling further compresses tokens
|
| 338 |
+
along the time dimension.
|
| 339 |
+
- Before projection, a **2×2 pixel-shuffle downsampling** reduces visual token count by 4×, keeping
|
| 340 |
+
inputs of up to **3584 × 3584 pixels** affordable within the 1M-token context.
|
| 341 |
+
- A lightweight **MLP projector** maps visual features into the shared embedding space.
|
| 342 |
+
|
| 343 |
+
**Why native multimodality matters architecturally.** Text, images and video are processed by a single
|
| 344 |
+
shared backbone within one context, with no post-hoc modality-alignment stage. **Rendered outputs and
|
| 345 |
+
the code that produced them live in the same token stream** — the model can write code, inspect
|
| 346 |
+
screenshots, and iteratively refine visual artifacts (UIs, graphics, video) **with no cross-model
|
| 347 |
+
hand-off**. This is the architectural precondition for the video-editing and motion-design results in
|
| 348 |
+
report §7.
|
| 349 |
+
|
| 350 |
+
---
|
| 351 |
+
|
| 352 |
+
## 5. Per-Head Muon
|
| 353 |
+
|
| 354 |
+
K3 follows K2 in using **Muon** for matrix parameters, refined into a **per-head variant for attention
|
| 355 |
+
projections**: instead of applying Newton–Schulz orthogonalization to the full Q, K, V projection
|
| 356 |
+
matrices, their momentum matrices are **partitioned along the head dimension and each head's block is
|
| 357 |
+
orthogonalized separately**.
|
| 358 |
+
|
| 359 |
+
**The intuition:** full-matrix orthogonalization treats all heads as a single coupled block, so heads
|
| 360 |
+
with larger gradient or momentum scales dominate the shared update direction while smaller-scale heads
|
| 361 |
+
receive insufficiently normalized updates. **Per-head orthogonalization equalizes the update scale
|
| 362 |
+
across heads.**
|
| 363 |
+
|
| 364 |
+
In practice this yields more balanced learning dynamics across heads and improves training stability
|
| 365 |
+
at larger scales. It also **slightly reduces optimizer overhead**, since Newton–Schulz iterations on
|
| 366 |
+
tall per-head blocks are cheaper than on the full projection matrix.
|
| 367 |
+
|
| 368 |
+
---
|
| 369 |
+
|
| 370 |
+
## References
|
| 371 |
+
|
| 372 |
+
- Kimi K3 technical report · [blog](https://www.kimi.com/blog/kimi-k3) · [weights](https://huggingface.co/moonshotai/Kimi-K3)
|
| 373 |
+
- Kimi Linear (KDA) [arXiv:2510.26692](https://arxiv.org/abs/2510.26692) · [code](https://github.com/MoonshotAI/Kimi-Linear)
|
| 374 |
+
- LatentMoE [arXiv:2601.18089](https://arxiv.org/abs/2601.18089) · DeepSeekMoE [arXiv:2401.06066](https://arxiv.org/abs/2401.06066) · DeepSeek-V2 / MLA [arXiv:2405.04434](https://arxiv.org/abs/2405.04434)
|
| 375 |
+
- Gated DeltaNet [ICLR 2025](https://openreview.net/forum?id=r8H7xhYPwz) · Mamba-2 / SSD [arXiv:2405.21060](https://arxiv.org/abs/2405.21060)
|
| 376 |
+
- Gated Attention [arXiv:2505.06708](https://arxiv.org/abs/2505.06708) · GLU Variants [arXiv:2002.05202](https://arxiv.org/abs/2002.05202) · PowLU [arXiv:2605.25704](https://arxiv.org/abs/2605.25704)
|
| 377 |
+
- Low-precision flash attention rounding [arXiv:2510.04212](https://arxiv.org/abs/2510.04212)
|
| 378 |
+
- Muon [kellerjordan.github.io/posts/muon](https://kellerjordan.github.io/posts/muon/) · Muon is Scalable [arXiv:2502.16982](https://arxiv.org/abs/2502.16982)
|
| 379 |
+
- Load balancing: auxiliary-loss-free (DeepSeek-V3) [arXiv:2412.19437](https://arxiv.org/abs/2412.19437) · BIP [arXiv:2502.15451](https://arxiv.org/abs/2502.15451) · the quantile view, in Chinese [spaces.ac.cn/archives/11619](https://spaces.ac.cn/archives/11619)
|
k3_evaluation_summary.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Kimi K3 — Evaluation Summary
|
| 2 |
+
|
| 3 |
+
> Where Kimi K3 actually lands: public benchmarks, in-house suites, cyber-capability evaluation,
|
| 4 |
+
> third-party results, and cost efficiency. All figures from the technical report unless marked
|
| 5 |
+
> **[verified]**. Baselines: Claude Fable 5, GPT-5.6 Sol, Claude Opus 4.8, GPT-5.5 (xhigh), and
|
| 6 |
+
> GLM-5.2 (open weight).
|
| 7 |
+
|
| 8 |
+
**The one-line summary from the report itself:** K3 **trails the strongest proprietary systems overall
|
| 9 |
+
— Claude Fable 5 and GPT-5.6 Sol — and is consistently ahead of every other open and proprietary model
|
| 10 |
+
in their suite.**
|
| 11 |
+
|
| 12 |
+
Evaluation configuration: K3 is evaluated at **reasoning effort = max, temperature = 1.0**. Single-step
|
| 13 |
+
tasks and vision benchmarks without tools use **top-p = 0.95**; agentic tasks use **top-p = 1.0**. The
|
| 14 |
+
report's general recommendation is top-p = 0.95 for reasoning and knowledge, top-p = 1.0 for coding and
|
| 15 |
+
agentic scenarios. Results for Claude Fable 5 include fallback behaviors, and GPT-5.6 Sol results
|
| 16 |
+
include potential cyberguards.
|
| 17 |
+
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
## 1. Public benchmarks
|
| 21 |
+
|
| 22 |
+
### Reasoning & Knowledge
|
| 23 |
+
|
| 24 |
+
| Benchmark | Kimi K3 | Best baseline |
|
| 25 |
+
|---|---|---|
|
| 26 |
+
| GPQA Diamond | 93.5 | **94.1** (GPT-5.6 Sol) |
|
| 27 |
+
| AA-LCR | **74.7** | 73.7 (GPT-5.6 Sol) |
|
| 28 |
+
| HLE-Full (no tool / tool) | 43.5 / 56.0 | **53.3 / 63.0** (Fable 5) |
|
| 29 |
+
| CritPt | 23.4 | **32.3** (GPT-5.6 Sol) |
|
| 30 |
+
|
| 31 |
+
Competitive at graduate-level reasoning; **a real gap remains on research-level tasks**. The report is
|
| 32 |
+
explicit that **research-level reasoning remains a key direction for improvement**.
|
| 33 |
+
|
| 34 |
+
### Coding
|
| 35 |
+
|
| 36 |
+
| Benchmark | Kimi K3 | Note |
|
| 37 |
+
|---|---|---|
|
| 38 |
+
| ProgramBench | **77.8** | best |
|
| 39 |
+
| SWE-Marathon | **42.0** | best — **7 points ahead of Fable 5**; a GPU-kernel-oriented suite |
|
| 40 |
+
| Terminal-Bench 2.1 | 88.3 | nearly matches GPT-5.6 Sol (88.8) |
|
| 41 |
+
| FrontierSWE | 81.2 | second, behind Fable 5 (86.6), well ahead of all others |
|
| 42 |
+
| DeepSWE | 67.5 | behind Fable 5 and GPT-5.6 Sol, ahead of Opus 4.8 and GPT-5.5 |
|
| 43 |
+
| PostTrainBench / MLS-Bench-Lite / SciCode | 36.6 / 48.3 / 58.7 | — |
|
| 44 |
+
|
| 45 |
+
### Agentic — the broadest area of strength
|
| 46 |
+
|
| 47 |
+
State of the art on: **BrowseComp 91.2**, **DeepSearchQA (F1) 95.0**, **ResearchRubrics 76.2**,
|
| 48 |
+
**MCPMark-Verified 94.5**, **AutomationBench 30.8**, **SpreadsheetBench 2 34.8**, **τ³-Banking 33.4**,
|
| 49 |
+
**Harvey Lab-AA 94.6** (criterion pass rate).
|
| 50 |
+
|
| 51 |
+
The main exceptions are **knowledge-work suites, both led by Claude Fable 5**: GDPval-AA v2 (K3 third at
|
| 52 |
+
1,686 Elo) and AA-Briefcase (K3 second at 1,548). Elsewhere it is largely competitive — CorpFin v2 (71.6
|
| 53 |
+
vs 71.8) and OSWorld-Verified (84.8 vs 85.0) finish within 0.2 points — while the harder computer-use
|
| 54 |
+
benchmarks (**OSWorld 2.0, SaaS-Bench**) are still led by Fable 5 or GPT-5.6 Sol.
|
| 55 |
+
|
| 56 |
+
### Vision
|
| 57 |
+
|
| 58 |
+
| Benchmark | Kimi K3 | Note |
|
| 59 |
+
|---|---|---|
|
| 60 |
+
| OmniDocBench | **91.1** | best |
|
| 61 |
+
| Video-MME (w/ sub) | **90.0** | best |
|
| 62 |
+
| MMVU | **82.1** | best |
|
| 63 |
+
| Math-Vision (no tool / Python) | 94.3 / **97.8** | — |
|
| 64 |
+
| ZeroBench-main (pass@5, no tool / Python) | 23.0 / **41.0** | ties Fable 5 without tools |
|
| 65 |
+
| WorldVQA ForceAnswer | 51.0 | second, behind Fable 5 (56.7) |
|
| 66 |
+
| MMMU-Pro / CharXiv (RQ) | 81.6 / 83.4 · 84.8 / 91.3 | — |
|
| 67 |
+
|
| 68 |
+
**The tool-augmentation delta is the interesting part.** Math-Vision +3.5 and ZeroBench-main **+18.0**
|
| 69 |
+
with a Python tool indicate that a substantial fraction of K3's visual capability is unlocked by
|
| 70 |
+
**writing code to look at the image**, rather than by pure forward perception. This corresponds directly
|
| 71 |
+
to the "multi-step verifiable visual reasoning" RL environment (report §4.2.3), where trajectories are
|
| 72 |
+
generated with a Python interpreter in the loop and execution outputs — including generated images — are
|
| 73 |
+
fed back as new observations.
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
|
| 77 |
+
## 2. In-house evaluation
|
| 78 |
+
|
| 79 |
+
The internal suite separates strengths from weaknesses more sharply than the public benchmarks.
|
| 80 |
+
|
| 81 |
+
- **Clearest strengths: orchestration- and research-type agency.** K3 leads **Swarm Bench (76.3)** and
|
| 82 |
+
**Deep Research Bench (90.0)** by clear margins — indicating strong capability in decomposing complex
|
| 83 |
+
objectives, coordinating parallel work, and producing rubric-satisfying deliverables.
|
| 84 |
+
- **Coding.** On Kimi Code Bench 2.0 it trails only Claude Fable 5, and it attains the **best score on
|
| 85 |
+
Coding Experience (59.9)** — suggesting its practical behavior as a coding agent (communication quality,
|
| 86 |
+
behavioral appropriateness, instruction-following stability) is **ahead of its raw test scores**.
|
| 87 |
+
- **Professional knowledge work has improved markedly** over the previous generation, with Finance Bench
|
| 88 |
+
essentially tied with GPT-5.6 Sol.
|
| 89 |
+
- **Kimi Webdev Bench** (blind expert judging vs Claude Opus 4.8, both under the Claude Code harness):
|
| 90 |
+
|
| 91 |
+
| Domain | Win | Tie | Lose | Win − Lose |
|
| 92 |
+
|---|---|---|---|---|
|
| 93 |
+
| Games | 55.6% | 3.7% | 40.7% | +14.9 |
|
| 94 |
+
| **3D / WebGL / Shader** | 72.7% | 13.7% | 13.6% | **+59.1** |
|
| 95 |
+
| Website / UI Clone | 52.6% | 21.1% | 26.3% | +26.3 |
|
| 96 |
+
| **Overall** | 58.6% | 13.8% | 27.6% | **+31.0** |
|
| 97 |
+
|
| 98 |
+
- **Where it trails**: Agent Behavior Bench, MIRA Bench, 24/7 ClawBench 2.0, Agentic Vision Bench, and
|
| 99 |
+
KWV Bench. On the remaining filled suites (KAET, CLIF Bench, Online Experience, DECK Bench,
|
| 100 |
+
Faithfulness, Chat All-in-One Bench) it ranks first or a close second.
|
| 101 |
+
|
| 102 |
+
---
|
| 103 |
+
|
| 104 |
+
## 3. Cyber-security evaluation
|
| 105 |
+
|
| 106 |
+
Evaluated along a two-tier progression of increasing operational risk. Reported factually here; the
|
| 107 |
+
report itself frames these as **a lower bound on capability**, conditioned on the current model version
|
| 108 |
+
and evaluation coverage.
|
| 109 |
+
|
| 110 |
+
**Tier 1 — vulnerability discovery** (identifying genuine bugs in current codebases and demonstrating
|
| 111 |
+
reproducibility; primarily associated with defensive security research). Across dozens of widely deployed
|
| 112 |
+
systems spanning OS kernels, databases, AI services, web frameworks, blockchain, and VPN software, the
|
| 113 |
+
model identified hundreds of candidates. **Of the findings that underwent human review, approximately 70%
|
| 114 |
+
were confirmed genuine, including 16 previously unknown vulnerabilities across six projects.** Two Linux
|
| 115 |
+
kernel findings are cited: a remotely triggerable heap out-of-bounds write introduced by an incomplete
|
| 116 |
+
upstream fix (confirmed by security experts as a remote denial-of-service primitive), and a Dirty-COW-class
|
| 117 |
+
vulnerability in the RDMA subsystem where an earlier upstream fix had inadvertently dropped a permission
|
| 118 |
+
check (confirmed as a deterministic local privilege-escalation primitive).
|
| 119 |
+
|
| 120 |
+
**Tier 2 — exploit development** (36 in-house tasks: 16 user-space, 20 Linux kernel). Every task is
|
| 121 |
+
**verified solvable by human security experts**; completing the full suite is estimated at roughly **540
|
| 122 |
+
expert-hours, about 15 hours per task on average**.
|
| 123 |
+
|
| 124 |
+
| | Kimi K3 | GLM-5.2 |
|
| 125 |
+
|---|---|---|
|
| 126 |
+
| Tasks solved | **14 / 36 (38.9%)** | 8 / 36 (22.2%) |
|
| 127 |
+
|
| 128 |
+
Successes are **unevenly distributed: 10 of K3's 14 come from the user-space track.** On the kernel
|
| 129 |
+
track, **neither model solves three-quarters of the tasks.** Trajectory analysis attributes the remaining
|
| 130 |
+
gap to human-expert capability to four recurring failure modes: (i) difficulty completing the final stage
|
| 131 |
+
of an exploit chain from primitives already obtained; (ii) poor strategy selection under mitigations;
|
| 132 |
+
(iii) getting trapped in prolonged, unproductive debugging loops; and (iv) insufficient verification of the
|
| 133 |
+
final deliverable before submission.
|
| 134 |
+
|
| 135 |
+
**Independent assessment.** A joint assessment by the UK AI Security Institute and NIST's Center for AI
|
| 136 |
+
Standards and Innovation (CAISI) reaches consistent conclusions: K3 outperforms GLM-5.2 on exploit
|
| 137 |
+
development (**32% vs 24% on ExploitBench**; **17 vs 11 steps** on a 32-step simulated enterprise network
|
| 138 |
+
that takes a human expert roughly 20 hours), but **trails frontier cyber-capable models on end-to-end
|
| 139 |
+
exploit completion, achieving arbitrary code execution on 0 of 41 tasks.**
|
| 140 |
+
|
| 141 |
+
Note on comparability: frontier models from Anthropic and OpenAI refuse cyber-related tasks, making a
|
| 142 |
+
comparable evaluation infeasible; they are excluded from this suite.
|
| 143 |
+
|
| 144 |
+
---
|
| 145 |
+
|
| 146 |
+
## 4. Third-party evaluation (as of 2026-07-23)
|
| 147 |
+
|
| 148 |
+
| Source | Result |
|
| 149 |
+
|---|---|
|
| 150 |
+
| **Artificial Analysis** | Intelligence Index v4.1 = **57.1**, ranking **#4 of 580 models** — third if GPT-5.6 Sol's effort variants are counted as a single entry — behind Fable 5 (59.9) and GPT-5.6 Sol (58.9), **ahead of all other evaluated models** |
|
| 151 |
+
| **Vals AI** | GDP-weighted industry benchmark suite: Vals Index **74.7**, **#2 of 39**, behind Fable 5 (75.1), ahead of GPT-5.6 Sol (73.1) |
|
| 152 |
+
| **LMArena** | **WebDev Arena 1,678 Elo, #1 of 99 — the first open model to top this leaderboard.** Text Arena 1,486 Elo, #8 of 200. Agent Arena 9.1, #4 of 37 (behind Fable 5 at 12.7, GPT-5.6 Sol at 10.1, Opus 4.8 at 9.8) |
|
| 153 |
+
|
| 154 |
+
---
|
| 155 |
+
|
| 156 |
+
## 5. Cost efficiency
|
| 157 |
+
|
| 158 |
+
Score against per-task cost across four suites. For Kimi Code Bench 2.0, costs are measured internally
|
| 159 |
+
with K3 run via Kimi Code and all other models via Claude Code. For BrowseComp, K3's cost is measured
|
| 160 |
+
from their own runs while Claude and GPT costs are cited from published charts. GDPval-AA v2 and
|
| 161 |
+
AA-Briefcase costs are cited from Artificial Analysis's pay-per-token API pricing.
|
| 162 |
+
|
| 163 |
+
| Suite | Result |
|
| 164 |
+
|---|---|
|
| 165 |
+
| **Kimi Code Bench 2.0** | 4.0 points behind Fable 5 at **38% of its cost**; at *high* effort it already **matches Claude Opus 4.8's maximum-effort score at roughly one third of the cost** |
|
| 166 |
+
| **BrowseComp** | Best score **91.2% at $2.03 per task** — **half the cost of GPT-5.6 Sol** (90.4%) and **an order of magnitude cheaper** than the Claude models at maximum effort |
|
| 167 |
+
| **GDPval-AA v2** | Within 50 Elo of GPT-5.6 Sol at **13% lower cost**, and **2.6× cheaper than Claude Fable 5** |
|
| 168 |
+
| **AA-Briefcase** | Second-best score behind Fable 5, at **roughly half the latter's cost** |
|
| 169 |
+
|
| 170 |
+
**Overall, K3 sits on or near the cost-efficiency frontier across all four suites — near-top scores at a
|
| 171 |
+
fraction of the cost of Claude Fable 5 in particular.**
|
| 172 |
+
|
| 173 |
+
---
|
| 174 |
+
|
| 175 |
+
## 6. Case studies (report §7)
|
| 176 |
+
|
| 177 |
+
Five demonstrations, reported here as capability evidence:
|
| 178 |
+
|
| 179 |
+
1. **GPU kernel optimization.** Each model works independently in an identically configured sandbox with a
|
| 180 |
+
budget of up to 24 hours per task, across four kernels (AttnRes, DeepSeek Sparse Attention, KDA, and MLA
|
| 181 |
+
with head dimension 512), on an NVIDIA Hopper GPU and an alternative-vendor GPGPU. K3 **reduced AttnRes
|
| 182 |
+
latency from 283.6 ms to 114.4 ms, cut DSA and KDA runtime by 55.1% and 73.6%**, and reached **over half
|
| 183 |
+
of peak TFLOPS on MLA**. It **matched Claude Fable 5 (with fallback)** and substantially outperformed
|
| 184 |
+
Opus 4.8, GPT-5.6 Sol, and GPT-5.5. Notably, **an early K3 checkpoint was already handling most of the
|
| 185 |
+
kernel optimization work during late-stage development.**
|
| 186 |
+
2. **MiniTriton** — a compact Triton-like compiler K3 developed: custom tile-level Python frontend and layout
|
| 187 |
+
system, a lightweight warp-level MLIR annotation and optimization layer, and a PTX code-generation
|
| 188 |
+
pipeline, plus a dual-mode tensor library with reverse-mode autograd, neural-network modules, distributed
|
| 189 |
+
training primitives over NCCL, and sparse and visualization primitives. On an NVIDIA L20 it **outperforms
|
| 190 |
+
PyTorch eager and `torch.compile` in geometric mean** over its core benchmark suite; its from-scratch
|
| 191 |
+
tensor-core matmul **approaches cuBLAS at the largest shapes, reaching about 90% of the measured machine
|
| 192 |
+
roofline**; its DSL-level KDA prefill kernel outperforms a matched Triton reference by a clear margin. It
|
| 193 |
+
also trains a GPT end to end with a loss curve closely tracking the PyTorch reference, with **full-model
|
| 194 |
+
gradients differing from torch autograd by no more than torch's own fp32 rounding error (10⁻⁴)**, measured
|
| 195 |
+
against an fp64 reference. Open source, Apache-2.0.
|
| 196 |
+
3. **Chip design (nano-kpu).** K3 designed an inference-chip prototype for a nano model **following the same
|
| 197 |
+
architecture as itself** — hybrid KDA and NoPE-MLA attention, Block AttnRes with a block size of two,
|
| 198 |
+
sigmoid-based MoE routing with one shared expert, under group-wise INT4 weight quantization (group size
|
| 199 |
+
128). In **a single 48-hour autonomous run with Kimi Code**, K3 built, optimized, and verified the chip
|
| 200 |
+
using open-source EDA tools with the Nangate45 standard-cell library. Within a **4 mm² analytical area
|
| 201 |
+
budget, the design closes timing at 100 MHz** and achieves an **RTL-simulated decode throughput of over
|
| 202 |
+
8,700 tokens/s**, integrating **1.46M standard cells, 0.277 MiB of SRAM, and an INT4 MAC array with fused
|
| 203 |
+
dequantization**. Open source, Apache-2.0.
|
| 204 |
+
4. **Coding for research.** To reproduce the I–Love–Q universal relations in computational astrophysics, K3
|
| 205 |
+
**reviewed more than 20 papers and cross-validated their results, implemented the full numerical pipeline,
|
| 206 |
+
evaluated over 300 equations of state, identified inconsistencies in published formulas, wrote more than
|
| 207 |
+
3,000 lines of Python, and produced an interactive HTML dashboard — in about two hours**, versus a typical
|
| 208 |
+
one to two weeks for an experienced researcher.
|
| 209 |
+
5. **Knowledge work.** In Kimi Work, K3 produced an interactive research website covering **42 years of the AI
|
| 210 |
+
ASIC industry**, completing more than **120 rounds of iterative refinement**, drawing on a corpus of **87
|
| 211 |
+
quarterly reports and 99 original PDFs (more than 11,000 pages)** through over **2,800 web searches** and
|
| 212 |
+
over **1,100 terminal queries**. In a second case, K3 analyzed **391 gravitational-wave events in GWTC-5**
|
| 213 |
+
using more than **20 concurrent subagents**, producing seven scientific visualizations, two summary tables,
|
| 214 |
+
and a literature synthesis of over ten papers.
|
| 215 |
+
6. **Video editing and motion design.** Leveraging its native multimodal architecture, K3 created a
|
| 216 |
+
3Blue1Brown-style motion-graphics explainer **of its own architecture**, and edited its teaser video from
|
| 217 |
+
**56 source clips** — clip selection, motion-matched cuts, frame-accurate beat synchronization, audio
|
| 218 |
+
processing, and multiple rounds of revision. Producing a comparable high-density short video would
|
| 219 |
+
typically take an experienced editor one to two days.
|
k3_open_source_inventory.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Kimi K3 — Open-Source Capability Inventory
|
| 2 |
+
|
| 3 |
+
> Every open-sourced component of the Kimi K3 release, **independently verified against its live
|
| 4 |
+
> HuggingFace or GitHub page** (2026-07-29) rather than transcribed from the technical report.
|
| 5 |
+
> Where the report and the repository disagree or the repository adds detail, the repository wins.
|
| 6 |
+
|
| 7 |
+
The headline is that **the weights are the smallest part of the release**. Six engineering
|
| 8 |
+
repositories ship under MIT or Apache-2.0, covering the attention kernels, the expert-parallelism
|
| 9 |
+
library, and the sandbox platform that powered agentic RL — all usable without the weights, at
|
| 10 |
+
scales far below 2.8T.
|
| 11 |
+
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
## 1. The inventory
|
| 15 |
+
|
| 16 |
+
| # | Artifact | Location | License | What it is | Maps to |
|
| 17 |
+
|---|---|---|---|---|---|
|
| 18 |
+
| 1 | **Kimi K3 weights** | [`moonshotai/Kimi-K3`](https://huggingface.co/moonshotai/Kimi-K3) | **Kimi K3 License** (not MIT — §2) | Safetensors, F32/BF16/U8. **MXFP4 weights / MXFP8 activations (quantization-aware training)**. Community has produced 1 adapter, 9 finetunes, **16 quantizations**, 7 Spaces. | The model |
|
| 19 |
+
| 2 | **Kimi-K3 (GitHub)** | [`MoonshotAI/Kimi-K3`](https://github.com/MoonshotAI/Kimi-K3) | Kimi K3 License | Architecture table, evaluation tables, deployment guidance (**vLLM / SGLang / TokenSpeed**), the XTML chat template and tool-calling format. API is OpenAI- and Anthropic-compatible. | Deployment entry point |
|
| 20 |
+
| 3 | **FlashKDA** | [`MoonshotAI/FlashKDA`](https://github.com/MoonshotAI/FlashKDA) | **MIT** | CUTLASS-based high-performance CUDA kernels for Kimi Delta Attention. **Requires SM90+, CUDA 12.9+, PyTorch 2.4+.** Ships H20 and GB200 benchmark docs. | Report §5.1.1 (chunkwise kernel) |
|
| 21 |
+
| 4 | **MoonEP** | [`MoonshotAI/MoonEP`](https://github.com/MoonshotAI/MoonEP) | **MIT** | Perfectly-balanced expert parallelism via dynamic redundant experts. API: `dispatch` / `combine` / `prefetch_weight` / `reduce_grad`; zero-copy and traditional modes. Needs multi-GPU with NVLink; tests need 8+ GPUs. | Report §5.2.1 |
|
| 22 |
+
| 5 | **AgentENV** | [`kvcache-ai/AgentENV`](https://github.com/kvcache-ai/AgentENV) | **MIT** | Firecracker microVM sandbox platform with OverlayBD on-demand image loading. **Boot/resume < 50 ms, pause < 100 ms, incremental snapshot < 100 ms** even under heavy disk modification. Supports fork; ballooning reclaims guest memory to sustain high overcommit. Ubuntu 24.04 script or Docker; CLI on Linux/macOS × x86_64/arm64. | Report §5.3.2 |
|
| 23 |
+
| 6 | **Kimi-Linear** | [`MoonshotAI/Kimi-Linear`](https://github.com/MoonshotAI/Kimi-Linear) | **MIT** | The original KDA work. Two checkpoints — **Kimi-Linear-48B-A3B-Base / -Instruct**, 5.7T training tokens, 1M context. 3:1 KDA-to-MLA ratio, **up to 75% KV-cache reduction**; claims up to **6.3× throughput vs MLA at 1M tokens**; RULER@128k = 84.3. | KDA's predecessor |
|
| 24 |
+
| 7 | **MiniTriton** | [`MoonshotAI/minitriton`](https://github.com/MoonshotAI/minitriton) | **Apache-2.0** | Python-embedded DSL → MLIR → PTX tile compiler, plus an eager tensor library sharing one DSL compiler and runtime. Reverse-mode autograd, NN modules, **distributed primitives over NCCL**, sparse and visualization primitives. `examples/vecadd.py` for end-to-end compile; `examples/train_gpt.py` trains a ~50M GPT on the repo's own source as corpus. | Report §7 (case study) |
|
| 25 |
+
| 8 | **nano-kpu** | [`MoonshotAI/nano-kpu`](https://github.com/MoonshotAI/nano-kpu) | **Apache-2.0** | Verilog RTL for a nano-scale hybrid inference chip: KDA linear attention, NoPE-MLA, sigmoid-routed MoE, attention-residual mixing, int4 group-128 weights. Toolchain: Verilator 5.x + yosys ≥0.64 + Nangate45. `python3 harness/evaluate.py --quick` for functional sim. | Report §7 (case study) |
|
| 26 |
+
| 9 | **KDA context parallelism (upstream)** | [`fla-org/flash-linear-attention` PR #691](https://github.com/fla-org/flash-linear-attention/pull/691) | FLA's license | Context-parallel support for GatedDeltaNet and KDA: `FLACPContext`, communication primitives, `fla/ops/cp/`, CP-aware Triton kernels, `CausalConv1dFunctionCP` / `GatedDeltaNetWithCP` / `KimiDeltaAttentionWithCP`, plus distributed tests and a benchmark harness. **Merged 2026-01-20.** | Report §5.1.2 (KCP) |
|
| 27 |
+
|
| 28 |
+
### Notes that only the repositories tell you
|
| 29 |
+
|
| 30 |
+
- **FlashKDA auto-dispatches.** It registers itself as the backend for `chunk_kda` in
|
| 31 |
+
`flash-linear-attention >= 0.5.0`. If you install FLA at that version on SM90+ hardware you get
|
| 32 |
+
FlashKDA whether or not you asked; opt out with `FLA_FLASH_KDA=0`. **[verified]**
|
| 33 |
+
- **The upstream CP numbers are large.** PR #691 reports, against all-to-all context parallelism:
|
| 34 |
+
GDN forward **+60%** (vs 29%), GDN forward+backward **+68%** (vs 37%), KDA forward+backward
|
| 35 |
+
**+86%** (vs 55%). **[verified]**
|
| 36 |
+
- **MoonEP's advantage is flatness, not peak.** Its communication latency is below DeepEP v2 at every
|
| 37 |
+
imbalance level, but the load-bearing claim is that **iteration time stays flat as routing imbalance
|
| 38 |
+
grows** while DeepEP degrades steadily — and that static shapes prevent the fragmentation that
|
| 39 |
+
causes OOM under high imbalance. **[verified]**
|
| 40 |
+
- **`minitriton` and `nano-kpu` disclaim themselves.** Both repos state they are demonstrations of
|
| 41 |
+
K3's capability — "not a Moonshot product, and not for production use". Their value is as
|
| 42 |
+
**calibration evidence** for what autonomous model-driven engineering currently reaches, not as
|
| 43 |
+
tools. **[verified]**
|
| 44 |
+
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
## 2. The Kimi K3 License — read this before building on the weights
|
| 48 |
+
|
| 49 |
+
The weights and the K3 repository code use the **Kimi K3 License**, which is *not* MIT. It grants
|
| 50 |
+
MIT-style breadth — "use, copy, modify, merge, publish, distribute, sublicense, and/or sell", and
|
| 51 |
+
explicitly permits creating derivative works — but adds commercial conditions standard MIT does not
|
| 52 |
+
have. **[verified]**
|
| 53 |
+
|
| 54 |
+
| Condition | Trigger | Obligation |
|
| 55 |
+
|---|---|---|
|
| 56 |
+
| **Attribution / branding** | Product with **> 100 million monthly active users**, **or > $20M monthly revenue** | Must display **"Kimi K3" prominently on the user interface** |
|
| 57 |
+
| **Model-as-a-Service** | **> $20M (or equivalent) total revenue over any consecutive 12 months** | Must **enter a separate commercial agreement with Moonshot AI before use** |
|
| 58 |
+
| **Exemption** | Internal use; access via Moonshot AI's official products or **certified inference partners** | Exempt from the above |
|
| 59 |
+
|
| 60 |
+
- **Commercial use is permitted.** **Derivative works, including derivative model training and
|
| 61 |
+
distillation, are permitted** — but the same restrictions **propagate to the derivatives**.
|
| 62 |
+
- **Practical read:** below both thresholds this behaves like a permissive license. The thing to
|
| 63 |
+
track is that if you distill from K3 and redistribute the resulting weights, the conditions travel
|
| 64 |
+
with them. That is a materially different legal posture from artifacts 3–8, which are plain MIT or
|
| 65 |
+
Apache-2.0. **Do not treat the release as uniformly licensed.**
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
## 3. What is *not* open
|
| 70 |
+
|
| 71 |
+
Worth being explicit, because the release is broad enough that it is easy to assume more is included
|
| 72 |
+
than is:
|
| 73 |
+
|
| 74 |
+
- **No training data.** Neither the pre-training corpus, the SFT dataset, the RL task sets, nor the
|
| 75 |
+
knowledge graph used for task synthesis (report §4.2.2) is released.
|
| 76 |
+
- **No RL training code.** The environments described in report §4.2 — the unified white-box harness,
|
| 77 |
+
the verifiable agentic problems, the kernel-optimization suite with its reward-hacking detector,
|
| 78 |
+
the personal-assistant mocks, Autonomous Execution Tasks, the web-development suite — are described
|
| 79 |
+
but not shipped. AgentENV is the *sandbox runtime* underneath them, not the environments.
|
| 80 |
+
- **No in-house benchmarks.** Kimi Code Bench 2.0, Kimi Webdev Bench, MIRA, KAET, CLIF, Swarm Bench,
|
| 81 |
+
Deep Research Bench, KWV, DECK, Agent Behavior Bench and the rest of report §6.2.1 are internal.
|
| 82 |
+
- **No scaling-law data.** The 2.5× efficiency claim over K2 is presented as a fitted curve
|
| 83 |
+
(report Fig. 7) without the underlying runs, and the report does not decompose how much comes from
|
| 84 |
+
architecture vs. data vs. training recipe.
|
| 85 |
+
|
| 86 |
+
---
|
| 87 |
+
|
| 88 |
+
## 4. Reuse guide by scale
|
| 89 |
+
|
| 90 |
+
Sorted by how usable each artifact is to a team that is *not* training a 3T model.
|
| 91 |
+
|
| 92 |
+
**Usable at small scale, today**
|
| 93 |
+
|
| 94 |
+
- **`Kimi-Linear-48B-A3B` (MIT weights)** — the practical entry point to KDA. If the question is
|
| 95 |
+
"does a linear-attention hybrid hold up on my long-sequence workload", this is a runnable checkpoint;
|
| 96 |
+
you do not need to start from K3's 2.8T.
|
| 97 |
+
- **AgentENV (MIT)** — arguably the most broadly reusable piece. The pause/resume/fork/snapshot
|
| 98 |
+
semantics target a real and general problem: an agent waiting on model inference can account for
|
| 99 |
+
**up to 98% of a sandbox's lifetime**, and pausing costs nothing. Fork gives side-effect-free reward
|
| 100 |
+
judging. Sub-50 ms resume makes fine-grained branch evaluation practical. None of this requires
|
| 101 |
+
a large model.
|
| 102 |
+
- **FlashKDA (MIT)** — free if you already use FLA ≥ 0.5.0 on SM90+. Check your hardware first;
|
| 103 |
+
pre-Hopper GPUs are out.
|
| 104 |
+
|
| 105 |
+
**Requires real scale**
|
| 106 |
+
|
| 107 |
+
- **MoonEP (MIT)** — needs multi-GPU NVLink and an actual expert-parallel MoE training job; tests
|
| 108 |
+
alone need 8+ GPUs. Worth reading the `E/R` redundant-expert bound proof (report Appendix E) even
|
| 109 |
+
if you never run it: it is a clean argument that a feasible balanced plan *always* exists, which is
|
| 110 |
+
what lets training never stall.
|
| 111 |
+
|
| 112 |
+
**Evidence, not tools**
|
| 113 |
+
|
| 114 |
+
- **`minitriton`, `nano-kpu`** — read to calibrate what autonomous model-driven engineering currently
|
| 115 |
+
achieves. nano-kpu was built, optimized and verified in **a single 48-hour autonomous run**; the
|
| 116 |
+
design closes timing at 100 MHz within a 4 mm² analytical area budget and reaches over 8,700 tokens/s
|
| 117 |
+
simulated decode throughput with 1.46M standard cells and 0.277 MiB SRAM. MiniTriton's from-scratch
|
| 118 |
+
tensor-core matmul approaches cuBLAS at the largest shapes — about **90% of measured machine roofline**
|
| 119 |
+
— and its full-model gradients differ from torch autograd by no more than torch's own fp32 rounding
|
| 120 |
+
error (10⁻⁴), measured against an fp64 reference. **[report]**
|
| 121 |
+
|
| 122 |
+
---
|
| 123 |
+
|
| 124 |
+
## 5. Deployment
|
| 125 |
+
|
| 126 |
+
Per the model card, the recommended inference engines are **vLLM** (recipes at `recipes.vllm.ai`),
|
| 127 |
+
**SGLang** (`docs.sglang.io` cookbook), and **TokenSpeed** (`lightseek.org/tokenspeed`). Hosted API
|
| 128 |
+
access is at `platform.kimi.ai` with OpenAI- and Anthropic-compatible endpoints. The recommended agent
|
| 129 |
+
framework is the Kimi Code CLI. **[verified]**
|
| 130 |
+
|
| 131 |
+
Two usage details that bite if missed, both from the model card: thinking is enabled with a
|
| 132 |
+
configurable `reasoning_effort` (`low` / `high` / `max`), and **multi-turn conversations require
|
| 133 |
+
passing complete assistant messages back verbatim — including `reasoning_content` and `tool_calls`**.
|
| 134 |
+
The chat template only supports *preserved thinking*: the `think` channel stays in history even when
|
| 135 |
+
empty, so the model sees a consistent message structure every turn (report Appendix F).
|
k3_training_and_infra_notes.md
ADDED
|
@@ -0,0 +1,632 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Kimi K3 — Training and Infrastructure Notes
|
| 2 |
+
|
| 3 |
+
> Pre-training, post-training, RL environments, and the systems work behind **Kimi K3** (Kimi Team,
|
| 4 |
+
> Moonshot AI, July 2026). Companion to [`k3_architecture_notes.md`](k3_architecture_notes.md).
|
| 5 |
+
> **[report]** = stated in the technical report; **[analysis]** = our inference.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## 1. Pre-training
|
| 10 |
+
|
| 11 |
+
### 1.1 Data
|
| 12 |
+
|
| 13 |
+
A curated corpus spanning four text domains — **Web Text, Code, Mathematics, Knowledge** — plus a
|
| 14 |
+
large-scale vision corpus.
|
| 15 |
+
|
| 16 |
+
**Text.** Each domain is filtered by a combination of rule-based heuristics, classifier-based quality
|
| 17 |
+
scoring, and deduplication, with **domain-specific sampling rates determined by ablation studies on
|
| 18 |
+
smaller models**. Following K2's rephrasing recipe, knowledge and mathematics corpora are rephrased
|
| 19 |
+
with style- and perspective-diverse prompting, chunk-wise autoregressive generation, and **fidelity
|
| 20 |
+
verification against the source documents**.
|
| 21 |
+
|
| 22 |
+
**Vision.** Open-source collections combined with in-house pipelines for filtering, synthesis, and
|
| 23 |
+
deduplication. Two details worth extracting:
|
| 24 |
+
|
| 25 |
+
- **Coordinate supervision is provided in both absolute and normalized `[0,1]` formats**, enabling
|
| 26 |
+
localization that is both precise and resolution-robust.
|
| 27 |
+
- Beyond classical text-captioned images, they **substantially scale up programmatic multimodal data,
|
| 28 |
+
pairing code snippets with their rendered visuals** across domain-specific formats including SVG,
|
| 29 |
+
3D assets, Webpage, **Game**, and CAD schematics.
|
| 30 |
+
|
| 31 |
+
> **[analysis]** The programmatic pairing idea generalizes cheaply: anywhere you can *render* from a
|
| 32 |
+
> known state, you get ground-truth-annotated visual supervision for free, with none of the data
|
| 33 |
+
> governance burden that attaches to captured or user-contributed imagery.
|
| 34 |
+
|
| 35 |
+
### 1.2 Scaling law — a methodology worth copying
|
| 36 |
+
|
| 37 |
+
Report Fig. 7 gives fitted scaling curves for K2 and K3; at equal FLOPs, K3's held-out validation loss
|
| 38 |
+
corresponds to a **2.5× compute-equivalent gain**.
|
| 39 |
+
|
| 40 |
+
The more transferable content is **how they compared learning-rate schedules**:
|
| 41 |
+
|
| 42 |
+
> Their scaling-law study consistently favors cosine decay over Warmup-Stable-Decay (WSD). **But** —
|
| 43 |
+
> even under the same model size and training-token budget, the two schedules' optimal peak learning
|
| 44 |
+
> rates and batch sizes **differ substantially**. As a result, **comparing the two schedules using a
|
| 45 |
+
> shared set of hyperparameters may unfairly favor one simply because those hyperparameters are better
|
| 46 |
+
> aligned with it.** To ensure a fair comparison, they conducted an **independent scaling-law search for
|
| 47 |
+
> each schedule**. Under their respective optimal settings, cosine decay consistently achieves a lower
|
| 48 |
+
> final loss than WSD.
|
| 49 |
+
|
| 50 |
+
> **[analysis]** This discipline is more valuable than the conclusion, and it applies far below
|
| 51 |
+
> frontier scale: **any A/B comparison between two training configurations is invalid if their optimal
|
| 52 |
+
> hyperparameters do not sit in the same neighborhood.** Choice of adapter rank, teacher model,
|
| 53 |
+
> objective weighting — all of these move the optimum. The cheap fix is a small independent LR/batch
|
| 54 |
+
> sweep per arm before declaring a winner; the honest fallback is to label the result
|
| 55 |
+
> "hyperparameters not aligned, indicative only".
|
| 56 |
+
|
| 57 |
+
### 1.3 Recipe and the context curriculum
|
| 58 |
+
|
| 59 |
+
- **Native multimodal training**: language and vision are **jointly optimized from the start of
|
| 60 |
+
training**, not grafted together via a post-hoc alignment stage. Visual and textual tokens are
|
| 61 |
+
interleaved within a single next-token prediction objective.
|
| 62 |
+
- Per-Head Muon plus the weight-clipping mechanism introduced in K2; QB for MoE load balancing;
|
| 63 |
+
**cosine LR schedule with 1% linear warmup**; **weight decay 0.1 throughout**.
|
| 64 |
+
- **Four-stage context curriculum**: **8K → 64K during pre-training**, then **256K → 1M during
|
| 65 |
+
cooldown**. Concentrating the costly long-sequence computation within a small fraction of the
|
| 66 |
+
overall training budget keeps the curriculum economical while still letting the model adapt
|
| 67 |
+
gradually to increasingly long-range dependencies.
|
| 68 |
+
- **Long-context data cleaning.** Long documents and videos from natural sources contain a substantial
|
| 69 |
+
amount of low-quality content — near-duplicates, binary blobs, truncated files, video clips, invalid
|
| 70 |
+
machine-generated logs. The pipeline combines exact and fuzzy deduplication, **perceptual hashing
|
| 71 |
+
over frames for video**, heuristic and classifier-based quality filtering, and structural validation.
|
| 72 |
+
Because genuinely long and coherent documents are scarce relative to short text, they are
|
| 73 |
+
**upsampled** so the long-context distribution is not overwhelmed by short sequences during cooldown.
|
| 74 |
+
- **Length alone does not confer long-range capability.** They additionally **synthesize** long-context
|
| 75 |
+
data by carefully permuting and concatenating multimodal documents and sub-tasks, **so that the
|
| 76 |
+
embedded tasks can be solved only by attending to information scattered across the full 1M-token
|
| 77 |
+
context**. This trains the attention mechanism at the intended scale and prevents it from
|
| 78 |
+
degenerating into local patterns.
|
| 79 |
+
|
| 80 |
+
---
|
| 81 |
+
|
| 82 |
+
## 2. Post-training
|
| 83 |
+
|
| 84 |
+
```
|
| 85 |
+
SFT (cold start) → RL (3 domains × 3 effort levels = 9 experts) → MOPD (consolidate into one)
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
### 2.1 Supervised fine-tuning
|
| 89 |
+
|
| 90 |
+
Data trajectories are synthesized using **domain-specialized models from the prior Kimi series**,
|
| 91 |
+
followed by multi-stage verification and human-in-the-loop annotation. All data is serialized with the
|
| 92 |
+
**XTML** chat template (§2.5). **Quantization-aware training is applied from the SFT stage onward.**
|
| 93 |
+
|
| 94 |
+
### 2.2 Reinforcement learning: 3 domains × 3 effort levels
|
| 95 |
+
|
| 96 |
+
Rather than training specialized RL models per task, RL is scaled across three broad domains, each
|
| 97 |
+
spanning a wide spectrum of sub-tasks, with **one expert trained per domain at every reasoning-effort
|
| 98 |
+
level**:
|
| 99 |
+
|
| 100 |
+
| Domain | Coverage |
|
| 101 |
+
|---|---|
|
| 102 |
+
| **General tasks** | General experience, vision, reasoning, faithfulness, search, knowledge work |
|
| 103 |
+
| **General agents** | Long-horizon assistant tasks, deep research, paragraph-level writing |
|
| 104 |
+
| **Coding agents** | Software engineering, coding experience, kernel tasks, web development |
|
| 105 |
+
|
| 106 |
+
Crossed with `{low, high, max}` → **nine expert models**. Report Fig. 8 shows that **as RL FLOPs scale,
|
| 107 |
+
tool-call steps scale up consistently**, accompanied by comprehensive improvement in overall capability.
|
| 108 |
+
|
| 109 |
+
**Partial rollout.** Long-horizon tasks have severe long-tail latency. For each of `N` prompts they
|
| 110 |
+
sample `K` completions, maintaining `N × K` active trajectories. **Rather than waiting for all rollouts
|
| 111 |
+
to terminate**, the generation phase pauses as soon as a fraction `λ ∈ (0,1)` completes (i.e. `λNK`),
|
| 112 |
+
allowing policy optimization to proceed without execution stragglers. Paused rollouts are enqueued and
|
| 113 |
+
prioritized for resumption at the start of the next iteration — powered by the sandbox infrastructure
|
| 114 |
+
(§4.4). Once all `K` responses for a prompt complete, they are immediately dispatched for policy
|
| 115 |
+
optimization.
|
| 116 |
+
|
| 117 |
+
**The cost and the mitigation.** An individual long-horizon trajectory naturally spans multiple
|
| 118 |
+
iterations, **introducing data staleness that threatens training stability**. Their policy optimization
|
| 119 |
+
algorithm inherently tolerates an extreme off-policy regime through a **per-token regularization**: by
|
| 120 |
+
constraining policy updates within a localized neighborhood, it robustly handles highly stale data and
|
| 121 |
+
sustains training stability.
|
| 122 |
+
|
| 123 |
+
**Reasoning Effort RL.** A **per-problem token budget control mechanism**: each problem `x` gets an
|
| 124 |
+
initial token budget `b₀(x)` estimated from the cold-start model, and the task reward is **overridden
|
| 125 |
+
with −1** for trajectories whose total budget `T(y)` exceeds a scaled threshold `τ · b₀(x)`. For
|
| 126 |
+
general tasks `T(y)` measures thinking tokens; for agentic tasks it accounts for cumulative output
|
| 127 |
+
tokens including both reasoning traces and tool-call arguments. Training follows a **stage-wise
|
| 128 |
+
curriculum over the budget multiplier τ**: first a *max-budget* variant with relatively large τ (while
|
| 129 |
+
still capping the maximum to suppress excessive overthinking), then **τ is annealed to smaller values**
|
| 130 |
+
to obtain the *high*- and *low*-effort experts. τ is configured per domain under human-in-the-loop
|
| 131 |
+
guidance.
|
| 132 |
+
|
| 133 |
+
**Agentic Generative Reward Model.** For non-verifiable general tasks, a tournament-style group reward
|
| 134 |
+
with binary comparisons. Beyond generic agentic capabilities, the agentic judge must follow a
|
| 135 |
+
**mandatory protocol**: (1) read the outcome, product, or text output; (2) generate a rubric;
|
| 136 |
+
(3) score each candidate against the rubric; (4) record the rubric-assigned scores in a scorepad. To
|
| 137 |
+
mitigate reward hacking toward increasingly verbose outputs, a **budget-based verbosity control**
|
| 138 |
+
mirrors the reasoning-effort control: given an initial verbosity `ℓ₀` estimated from the cold-start
|
| 139 |
+
model and a multiplier `σ`, a candidate whose output length exceeds `σ · ℓ₀` **automatically loses the
|
| 140 |
+
binary comparison**.
|
| 141 |
+
|
| 142 |
+
### 2.3 Multi-Teacher On-Policy Distillation (MOPD)
|
| 143 |
+
|
| 144 |
+
Consolidating the nine experts into one model. For a given domain `d` and sampled effort level
|
| 145 |
+
`e ∈ {low, high, max}`, optimization is guided by the corresponding teacher `π_teacher^{(d,e)}`. The
|
| 146 |
+
per-token OPD reward on `y_t`:
|
| 147 |
+
|
| 148 |
+
```
|
| 149 |
+
r_opd(y_t | e, x, y_<t) = clip( sg( log [ π_teacher^{(d,e)}(y_t | x, y_<t) / π_θ(y_t | x, y_<t) ] ), −R_max, R_max )
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
where `sg(·)` is stop-gradient and `R_max > 0` clips extreme advantage signals, stabilizing RL
|
| 153 |
+
training. **This dense reward signal integrates seamlessly into their RL framework** — meaning
|
| 154 |
+
infrastructure-level optimizations such as partial rollout naturally apply to distillation training for
|
| 155 |
+
long-horizon tasks. They also experimented with more fine-grained top-`k` distillation objectives and
|
| 156 |
+
**observed no clear advantage in either convergence speed or final performance**.
|
| 157 |
+
|
| 158 |
+
### 2.4 Deployment-aware post-training
|
| 159 |
+
|
| 160 |
+
**MXFP4 quantization-aware training.** The **MoE expert weights — which dominate the model's parameter
|
| 161 |
+
memory — are quantized to MXFP4**, with activations computed in MXFP8, while **all non-expert
|
| 162 |
+
components (attention projections, latent MoE projections, shared experts, MoE routers) remain in
|
| 163 |
+
higher precision**. QAT runs throughout the entire post-training stage, covering both SFT and RL, so
|
| 164 |
+
the model adapts to quantization-induced precision loss. **During RL, rollout and training share the
|
| 165 |
+
same quantization scheme — eliminating the train–inference mismatch.**
|
| 166 |
+
|
| 167 |
+
**Draft model fine-tuning.** K3 is pre-trained with a multi-token-prediction layer that mirrors the
|
| 168 |
+
structure of a backbone block. That MTP layer is fine-tuned into an **EAGLE-3-style draft model** —
|
| 169 |
+
target model frozen, only the draft layer and its feature-fusion projection trained. The draft is
|
| 170 |
+
**unrolled for seven steps during training**; beyond the first step, it consumes its own outputs from
|
| 171 |
+
earlier steps, mirroring the recurrent drafting procedure at inference.
|
| 172 |
+
|
| 173 |
+
Two details worth extracting:
|
| 174 |
+
|
| 175 |
+
- **Feature fusion with an identity-preserving initialization.** The draft input fuses low-, mid- and
|
| 176 |
+
high-level features of the target model, taken from the outputs of the **1st, 4th, and final AttnRes
|
| 177 |
+
blocks**. These are concatenated and projected to hidden size by a bias-free matrix `W_E3`,
|
| 178 |
+
**initialized as `[0 0 I]`** so that at initialization the fused representation **coincides exactly
|
| 179 |
+
with the high-level input `h_h` on which the MTP layer was pre-trained** — and gradually learns to
|
| 180 |
+
incorporate the low- and mid-level features during fine-tuning.
|
| 181 |
+
- **Optimize acceptance rate directly, not a KL surrogate.** Speculative decoding speedup is governed
|
| 182 |
+
by the per-token acceptance rate `Σ_x min(p(x), q(x))` under lossless speculative sampling.
|
| 183 |
+
**Minimizing the conventional KL-divergence surrogate does not guarantee maximizing this rate** for a
|
| 184 |
+
capacity-limited draft model. So they directly optimize the likelihood-based **LK loss** — the
|
| 185 |
+
negative logarithm of the acceptance rate itself: `L_LK = −log Σ_x min(p(x), q(x))`, with `p` and `q`
|
| 186 |
+
evaluated at temperature 1 and **no auxiliary ground-truth cross-entropy term**.
|
| 187 |
+
|
| 188 |
+
### 2.5 The XTML chat template (Appendix F)
|
| 189 |
+
|
| 190 |
+
Three design goals: **extensibility** (new capabilities via backward-compatible message formats rather
|
| 191 |
+
than template revisions), **a low alignment tax** (the format should be learnable with minimal
|
| 192 |
+
supervised data, supporting a pipeline where a lightly fine-tuned pre-trained model proceeds directly
|
| 193 |
+
to RL), and **decoding friendliness** (simple encoders, streaming parsers, grammar-constrained
|
| 194 |
+
enforcers).
|
| 195 |
+
|
| 196 |
+
- **Syntax.** Angle-bracket syntax is replaced by three reserved special tokens — `[open]`, `[sep]`,
|
| 197 |
+
`[close]` — plus `[end_of_msg]` as the generation stop marker. An element
|
| 198 |
+
`[open]tag attr="value"[sep] ... [close]tag[sep]` is isomorphic to its XML counterpart, but **every
|
| 199 |
+
structural boundary is an explicit special token**, which removes tokenization ambiguity at element
|
| 200 |
+
boundaries and simplifies constrained decoding.
|
| 201 |
+
- **Messages and zones.** *Input messages* cover system/user/tool/assistant. *Option messages* are
|
| 202 |
+
placed by scope: **global options** (`tool-declare`, `thinking-effort`) appear **before** all input
|
| 203 |
+
messages — they govern the whole session, rarely change, and modifying them invalidates the KV cache
|
| 204 |
+
anyway. **One-shot options** (`tool_choice`, `response_format`) are appended **after** the input
|
| 205 |
+
messages, **so per-request changes leave the history KV cache intact**. A third kind, the *input
|
| 206 |
+
option message*, is interleaved with input messages to supplement or override a global option
|
| 207 |
+
mid-session — which is what supports **dynamically loaded tools**: tools retrieved during a
|
| 208 |
+
conversation are announced through an additional `tool-declare` message, expanding the toolset
|
| 209 |
+
**without rebuilding the preceding context**.
|
| 210 |
+
- **Channels** (inspired by OpenAI's Harmony format). An assistant message body is organized into
|
| 211 |
+
`think` (reasoning trace), `response` (user-visible answer), and `tools` (tool calls). The two
|
| 212 |
+
generation modes are selected **purely through the generation prefix** — `[open]think[sep]` for
|
| 213 |
+
thinking mode, `[open]response[sep]` for instruct mode — **rather than through separate templates**.
|
| 214 |
+
K3 supports only **preserved thinking**: in thinking mode the think channel is **always retained in
|
| 215 |
+
history, kept even when its content is empty**, so the model observes a consistent message structure
|
| 216 |
+
across turns. In instruct mode historical messages contain only the response and tools channels.
|
| 217 |
+
- **Tool calling.** Each call carries `tool` and `index` attributes; index numbers parallel calls within
|
| 218 |
+
a message, and each tool-result message repeats the same `tool`/`index` pair and follows the order of
|
| 219 |
+
its call, **so results are unambiguously associated with calls**. Arguments are **typed**: string
|
| 220 |
+
arguments appear as raw text, other JSON types are compactly serialized. **Free-form text such as
|
| 221 |
+
code is therefore a first-class citizen rather than an escaped JSON string.** A pure-JSON fallback
|
| 222 |
+
block covers inputs whose arguments cannot be decomposed into typed argument blocks; it occurs only
|
| 223 |
+
in input tokens, never in model outputs, and **its loss is masked during training**.
|
| 224 |
+
- **Reasoning effort** is exposed as a global option message of type `thinking-effort`, inserted after
|
| 225 |
+
the tool declaration and before the input messages. The schema reserves four levels (`low`, `medium`,
|
| 226 |
+
`high`, `max`), of which K3 supports a subset. This **decouples the effort interface from the template
|
| 227 |
+
syntax** and aligns directly with the effort-conditioned training of §2.2.
|
| 228 |
+
|
| 229 |
+
---
|
| 230 |
+
|
| 231 |
+
## 3. RL task synthesis and agentic environments
|
| 232 |
+
|
| 233 |
+
### 3.1 Unified white-box RL environment
|
| 234 |
+
|
| 235 |
+
Training with a single fixed agent harness can cause a model to **overfit to a particular tool schema,
|
| 236 |
+
system prompt, context management mechanism, or interaction protocol**. K3's environment represents an
|
| 237 |
+
agent harness as **a collection of configurable, composable modules** — tool interfaces, system
|
| 238 |
+
prompts, context management strategies, skills, memories, subagents, and other components. Composing
|
| 239 |
+
these through configuration, the environment can instantiate mainstream harnesses such as **Kimi Code,
|
| 240 |
+
Claude Code, Codex, OpenClaw, and Hermes**, as well as entirely new ones. During RL training they
|
| 241 |
+
**dynamically construct different harness configurations for different task groups**, exposing K3 to
|
| 242 |
+
diverse combinations of these modules rather than the conventions of any single harness.
|
| 243 |
+
|
| 244 |
+
### 3.2 Knowledge-graph-guided task synthesis
|
| 245 |
+
|
| 246 |
+
The quality and diversity of post-training tasks are largely determined by their source materials.
|
| 247 |
+
Retrieval guided by fine-grained concepts surfaces specialized and underrepresented knowledge, while
|
| 248 |
+
sampling across diverse concepts broadens domain coverage. K3 builds a **self-evolving, hierarchically
|
| 249 |
+
organized knowledge graph** that agents continuously expand through web-scale exploration.
|
| 250 |
+
|
| 251 |
+
**Construction.** A directed acyclic graph built by recursive, agent-driven expansion. Starting from
|
| 252 |
+
predefined coarse-grained seed nodes, an agent instance is assigned to each node and performs multiple
|
| 253 |
+
web searches to investigate that concept. **Before adding new nodes, the agent explores the existing
|
| 254 |
+
graph to identify equivalent or related concepts, reuse existing nodes where appropriate, and minimize
|
| 255 |
+
duplication.** Edges are always directed from the coarser concept to the finer one, **regardless of
|
| 256 |
+
which endpoint the agent discovers first**. Newly added nodes are subsequently assigned to agents for
|
| 257 |
+
further exploration. **A branch stops expanding when the assigned agent determines that the current
|
| 258 |
+
concept is sufficiently atomic.**
|
| 259 |
+
|
| 260 |
+
**Material retrieval and task synthesis.** To target a desired distribution across domains and task
|
| 261 |
+
types, the system samples nodes at varying levels of granularity, either individually or in related
|
| 262 |
+
combinations. Keywords derived from the sampled nodes are combined with **contextual information from
|
| 263 |
+
their ancestors in the knowledge graph** to formulate web queries. The retrieved real-world materials
|
| 264 |
+
are assembled so that a synthesis agent produces training tasks of various types.
|
| 265 |
+
|
| 266 |
+
### 3.3 Verifiable problems in agentic environments
|
| 267 |
+
|
| 268 |
+
| Task family | Content and verification |
|
| 269 |
+
|---|---|
|
| 270 |
+
| **Multi-step complex information searching** | The model plans its research, gathers evidence from the web step by step, and produces a verifiable answer |
|
| 271 |
+
| **Real day-to-day professional work** | Investment banking, data analysis, legal practice. The model decomposes a complex request, operates domain tools in a sandbox, and completes a deliverable **over dozens to hundreds of steps** |
|
| 272 |
+
| **Multi-step verifiable visual reasoning** | STEM problems, visual puzzles, chart understanding. Each trajectory is generated in an agent environment equipped with a **Python interpreter in an isolated sandbox**: the model iteratively writes and executes code to crop, zoom, or transform the input image, perform precise computation, or verify intermediate results, and **receives the execution outputs — including generated images — as new observations** over multiple interaction steps |
|
| 273 |
+
| **GPU kernel optimization** | Single-operator kernels to fused mega-kernels, sourced from high-quality GitHub repositories such as Flash Linear Attention. Covers CUDA, Triton, CuTe DSL, Gluon, ThunderKittens, TileLang, and BF16/FP8/FP4. **Rewards evaluate both correctness and performance**: each kernel provides a PyTorch reference implementation, and **solutions exceeding a predefined numerical error threshold receive zero reward**. Performance is scored against an expert implementation — **matching yields 0.5, approaching the hardware roofline increases the reward toward 1**. A **hacking-detection system** penalizes reward-hacking strategies such as CUDA graph replay, input caching, and precision reduction, and is **continuously extended with new safeguards as new hacking strategies are observed** |
|
| 274 |
+
| **Long-horizon personal assistant** | **Realistic mock implementations** of widely used applications (Gmail, Notion, Slack, Canvas) that preserve core semantics while enabling reproducible, large-scale interaction **without external APIs or rate limits**. The agent operates in a **persistent, evolving environment over multiple simulated days**, encountering dozens of interdependent events distributed across applications. **A single rollout may involve up to thousands of tool calls and millions of context tokens.** Each event carries its own evaluation criterion, assessed by deterministic rules or LLM-based evaluators |
|
| 275 |
+
| **Autonomous Execution Tasks (AET)** | Each task specifies an initial state, a constrained goal, a tool-based action space, execution budgets, and **an independent verifier**. Agents see **only** the objective, context, constraints, and verification interfaces — **no reference trajectories or predefined procedures** — and must autonomously perform task decomposition, tool selection, planning, error recovery, and termination. **Rewards are grounded in the verifier's evaluation of the final environment state rather than the agent's self-reported completion.** Environments include black-box system replication, quantitative factor discovery, and tax auditing. Reward hacking is mitigated by **isolating agents from verifiers**, **pairing public verifiers that offer diagnostic feedback with hidden verifiers that evaluate held-out scenarios**, and applying **penalty-based rewards under limited submission budgets** |
|
| 276 |
+
| **Web development** | Expert-curated; inputs range from one-line scene descriptions to multi-paragraph specifications; artifacts span websites, interactive games, 3D/WebGL scenes, data visualizations, SVGs, and full-stack applications. **Every task runs in a containerized sandbox and is rolled out under diverse agent scaffolds rather than a single fixed harness**, to promote cross-scaffold generalization. Rewards combine **deterministic checks** (functional tests, plus structural and pixel-level similarity for tasks replicating a reference) with **model judging** (source-code inspection, and looking at and interacting with the output artifact). **The reward is zeroed when a project fails to build, runs with errors, or fakes rather than implements the artifact** |
|
| 277 |
+
|
| 278 |
+
> **[analysis]** Two patterns here transfer to evaluation design at any scale. First, **grade the
|
| 279 |
+
> environment state, not the agent's report** — self-reported completion is the single easiest thing
|
| 280 |
+
> for a policy to learn to fake. Second, **split verifiers into a public one that gives diagnostic
|
| 281 |
+
> feedback and a hidden one that scores held-out scenarios**; this is the agentic analogue of a
|
| 282 |
+
> train/test split, and without it a public metric will be optimized instead of the capability.
|
| 283 |
+
|
| 284 |
+
---
|
| 285 |
+
|
| 286 |
+
## 4. Infrastructure
|
| 287 |
+
|
| 288 |
+
K3 combines three system challenges rarely encountered in a single model: **hybrid KDA attention,
|
| 289 |
+
3T-class sparse MoE, and million-token agentic RL workloads.**
|
| 290 |
+
|
| 291 |
+
### 4.1 KDA algorithm–system co-design
|
| 292 |
+
|
| 293 |
+
KDA replaces a growing KV cache with a fixed-size recurrent state. **The serial dependence poses
|
| 294 |
+
challenges in parallel execution, in exchange for a fixed-size state that is cheap to transfer and
|
| 295 |
+
reuse** — exploited at two levels.
|
| 296 |
+
|
| 297 |
+
**FlashKDA (open source, MIT).** The chunkwise form is parallel within each chunk but serial across
|
| 298 |
+
chunks; executed naively the two phases alternate, leaving SMs idle during serial propagation. FlashKDA
|
| 299 |
+
is a **CUTLASS-based chunkwise kernel that overlaps intra-chunk computation with cross-chunk state
|
| 300 |
+
propagation**, decomposing the work into token-parallel stages and a head-parallel recurrence, each
|
| 301 |
+
scheduled and tuned independently. It substantially outperforms the Triton reference, **serves both
|
| 302 |
+
training and inference prefill**, and is auto-dispatched as a backend of flash-linear-attention.
|
| 303 |
+
|
| 304 |
+
**Intra-device context parallelism for long-context prefill.** Tensor parallelism partitions heads
|
| 305 |
+
across devices but **never shortens the recurrence**, so under pure TP, prefilling an ultra-long
|
| 306 |
+
sequence leaves most SMs idle when each rank holds only a few heads. The key observation: **the state
|
| 307 |
+
transition of each segment can be evaluated independently of the incoming state and composed exactly
|
| 308 |
+
afterward.** An automatic SM-level context-parallel planner partitions the sequence across the SMs of a
|
| 309 |
+
single rank, evaluates the segment transitions in parallel, and merges them to recover each segment's
|
| 310 |
+
exact state. **Entirely intra-device; no cross-device communication.**
|
| 311 |
+
|
| 312 |
+
**KDA Context Parallelism (KCP), cross-device.** For softmax attention, context parallelism requires
|
| 313 |
+
exchanging KV blocks whose size grows with sequence length. Linear attention instead carries only a
|
| 314 |
+
fixed-size state — but **direct summation is insufficient for KDA**: the delta rule applies a
|
| 315 |
+
token-dependent matrix `M_t = (I − β_t k_t k_tᵀ) Diag(α_t)` to the **incoming** state before adding the
|
| 316 |
+
current write, so the effect of a local segment depends on the state entering that segment and
|
| 317 |
+
**cannot be determined from the state computed with `S = 0` alone**.
|
| 318 |
+
|
| 319 |
+
KCP decomposes each segment's effect into two locally computable quantities — a **cumulative transition
|
| 320 |
+
`M` acting on the incoming state**, and a **state `S̃` generated locally from zero**:
|
| 321 |
+
|
| 322 |
+
```
|
| 323 |
+
S^t_{[i+1]} = S̃^t_{[i+1]} + M^{t←1}_{[i+1]} · Σ_{j=1}^{i} ( ∏_{l←j+1} M^{T_l←1}_{[l]} ) S̃^{T_j}_{[j]}
|
| 324 |
+
```
|
| 325 |
+
|
| 326 |
+
Every state is composed purely from locally computed fragments. These rank-level updates **compose
|
| 327 |
+
associatively**, so the incoming state of each rank can be recovered by a **prefix scan**. Each rank
|
| 328 |
+
first computes `M^{T+1←1}` and `S̃^{T}` locally, then **exchanges both tensors with a single
|
| 329 |
+
`all-gather`**. → **KCP requires only a fixed-size all-gather for recurrent-state synchronization and
|
| 330 |
+
achieves linear compute scaling.** Implementation is upstream in
|
| 331 |
+
[FLA PR #691](https://github.com/fla-org/flash-linear-attention/pull/691) (merged 2026-01-20).
|
| 332 |
+
|
| 333 |
+
### 4.2 Infrastructure for 3T-class pre-training
|
| 334 |
+
|
| 335 |
+
Parallelism: **PP with virtual stages + EP + ZeRO-1 DP + Pipeline ZeRO-2 gradient sharding + CP**. MoE
|
| 336 |
+
layers replicate shared experts across EP ranks, and the all-to-all for expert dispatch and combine is
|
| 337 |
+
overlapped with computation.
|
| 338 |
+
|
| 339 |
+
**(a) MoonEP — perfectly balanced expert-parallel MoE training (open source, MIT)**
|
| 340 |
+
|
| 341 |
+
In conventional EP schemes token loads are imbalanced across ranks; the resulting computational
|
| 342 |
+
imbalance degrades throughput, and the dynamically varying shapes of routed-expert activations cause
|
| 343 |
+
substantial memory fragmentation. MoonEP achieves **perfect load balance with dynamic redundant
|
| 344 |
+
experts**: in the forward pass it plans redundant experts from the router outputs of the current
|
| 345 |
+
micro-batch and layer and **prefetches them before the routed-expert computation**; in the backward
|
| 346 |
+
pass it **stages their gradients in a local reduce buffer** and reduces them back to their home ranks
|
| 347 |
+
once computation completes.
|
| 348 |
+
|
| 349 |
+
- **Perfect balance with bounded redundant experts.** MoonEP requires every rank to receive exactly
|
| 350 |
+
`S × K` tokens. The report **proves that a balanced plan always exists with at most `E/R` redundant
|
| 351 |
+
experts per rank, and that this bound is essentially tight** (Appendix E, with a tightness
|
| 352 |
+
construction). Reserving `E/R` redundant-expert slots per rank therefore **guarantees a feasible
|
| 353 |
+
solution always exists, so training is never interrupted**. In contrast, prior work such as ECHO and
|
| 354 |
+
UltraEP presets the number of redundant experts or imposes a per-rank token cap — **training is then
|
| 355 |
+
forced to stop whenever no feasible plan exists within the cap**, the cap itself requires manual
|
| 356 |
+
tuning, and residual imbalance remains.
|
| 357 |
+
- **Online planning.** Computing the exact optimum at every step is prohibitively expensive. Exact
|
| 358 |
+
solutions are computed offline with integer linear programming as references, and a **GPU planning
|
| 359 |
+
kernel** is designed that is near-optimal, incurs negligible overhead, and **always respects the
|
| 360 |
+
`E/R` upper bound**.
|
| 361 |
+
- **Zero-copy communication.** A fused permute/unpermute operator in which **the planning kernel
|
| 362 |
+
precomputes the destination of every token**, so tokens are sent directly to their expert-grouped
|
| 363 |
+
positions on remote ranks and views of the communication buffer are returned directly to the
|
| 364 |
+
computation, **eliminating intermediate copies**. Under worst-case imbalance the zero-copy data path
|
| 365 |
+
in DeepEP requires a buffer of size `S × K × R`, whereas **MoonEP requires only a fixed `S × K`**
|
| 366 |
+
owing to the perfect balance.
|
| 367 |
+
- **Sync-free execution with static shapes.** In conventional MoE implementations the per-expert token
|
| 368 |
+
counts vary across steps and layers, and the host must synchronize with the device at every layer to
|
| 369 |
+
obtain the actual computation shapes, **stalling the pipeline between layers**. With perfect balance,
|
| 370 |
+
**the computation shapes of all layers are statically known** — eliminating the per-layer MoE host
|
| 371 |
+
synchronization and alleviating host-side kernel-launch overhead.
|
| 372 |
+
- **Expert-GEMM scheduling and overlap.** Even with perfectly balanced aggregate load, per-expert token
|
| 373 |
+
counts within each rank remain skewed, and a fixed-order, workload-oblivious schedule turns this skew
|
| 374 |
+
into an imbalanced makespan across SM workers. A **workload-aware scheduler** adapts its parameters
|
| 375 |
+
to the current token distribution before launch and keeps them fixed during execution; a lightweight
|
| 376 |
+
heuristic selects these using an **analytical cost model of hardware metrics**, with key coefficients
|
| 377 |
+
calibrated through offline autotuning. Shared-expert GEMMs are dispatched to a **separate stream** so
|
| 378 |
+
they overlap with other kernels.
|
| 379 |
+
|
| 380 |
+
**(b) Memory-efficient training**
|
| 381 |
+
|
| 382 |
+
- **Unified activation manager.** Every tensor saved for the backward pass is associated with a
|
| 383 |
+
**pluggable storage backend**; recomputation, quantization, and offload/remote-offload are **merely
|
| 384 |
+
storage policies under this abstraction**, freely composable at tensor granularity, declared via
|
| 385 |
+
lightweight annotations on tensors and **fully decoupled from the model code**. Recomputation is
|
| 386 |
+
performed at function granularity (supporting cross-layer recomputation). All GPU memory is allocated
|
| 387 |
+
on the main compute stream and managed within a single memory pool, **avoiding multi-stream
|
| 388 |
+
fragmentation and host-bound recomputation**; activations are prefetched back at layer granularity and
|
| 389 |
+
overlapped with computation. In K3, most activations use **block-wise FP8 quantization** combined with
|
| 390 |
+
offload/remote-offload, and element-wise operators are configured with recomputation.
|
| 391 |
+
- **Memory-efficient MoE.** In the native implementation the gradient computation of permuted probs
|
| 392 |
+
depends on the forward output `output`. Inspired by SonicMoE, this gradient is **rewritten through a
|
| 393 |
+
mathematical transformation into a form depending only on the intermediate activation `act_output` and
|
| 394 |
+
the upstream gradient `doutput`**, eliminating the backward dependency on `output` at the cost of an
|
| 395 |
+
additional lightweight element-wise computation. Furthermore, in the forward pass of the group GEMM
|
| 396 |
+
they **save only the input of the dispatch operation**; during the backward pass, the input of the
|
| 397 |
+
group GEMM is **recovered by recomputing dispatch**, and the communication introduced by this
|
| 398 |
+
recomputation can be **overlapped with part of the group-GEMM backward**, eliminating this portion of
|
| 399 |
+
activation storage at negligible cost.
|
| 400 |
+
- **Memory-efficient Attention Residual.** The block representation is **generated once at the boundary
|
| 401 |
+
layer and shared by all subsequent layers, residing directly on the GPU**. The AttnRes computation is
|
| 402 |
+
**entirely wrapped with checkpointing**, so the activation saved for the backward pass at each layer
|
| 403 |
+
is **identical to that of the standard residual architecture**. For pipeline parallelism they adopt
|
| 404 |
+
**cache-based pipeline communication**, in which only newly generated blocks are incrementally
|
| 405 |
+
transferred between stages and released as soon as the micro-batch finishes, **reaching the theoretical
|
| 406 |
+
lower bound on memory footprint**.
|
| 407 |
+
- **Balancing activations across PP ranks.** Under interleaved 1F1B, activations are unevenly
|
| 408 |
+
distributed across PP ranks due to pipeline warmup, and the number of resident activations decreases as
|
| 409 |
+
the PP rank increases. To avoid OOM, activations are **remotely offloaded to the memory of other PP
|
| 410 |
+
ranks** using the Mooncake Transfer Engine.
|
| 411 |
+
- **Pipeline ZeRO-2 gradient sharding and offloading.** Gradients are sharded across DP ranks, and the
|
| 412 |
+
**sharded gradients are stored in CPU memory** to reduce GPU usage while keeping the double grad buffer
|
| 413 |
+
on the GPU. After gradients are reduced across DP ranks into the double grad buffer, they are
|
| 414 |
+
accumulated into the CPU shards.
|
| 415 |
+
- **P2P-based Muon orthogonalization.** The distributed optimizer shards parameters evenly across DP
|
| 416 |
+
ranks, whereas Newton–Schulz orthogonalization requires the **full parameter matrix**, necessitating a
|
| 417 |
+
communication step to gather complete parameters before each update. The naive approach performs an
|
| 418 |
+
all-gather over the entire parameter buffer on every rank, incurring a substantial memory footprint on
|
| 419 |
+
top of making communication the primary bottleneck at scale. Instead, **each rank retrieves only the
|
| 420 |
+
shards of its locally owned parameters via peer-to-peer communication with the corresponding owner
|
| 421 |
+
ranks**, eliminating the full-parameter buffer and reducing both memory usage and communication volume.
|
| 422 |
+
Communication and computation are further pipelined at the granularity of model-chunk buffers.
|
| 423 |
+
|
| 424 |
+
**(c) Multimodal encoder optimization**
|
| 425 |
+
|
| 426 |
+
- **Dynamic CP in the multimodal encoder.** In long-context multimodal training, large images and long
|
| 427 |
+
videos substantially increase vision-encoder computation time and cause significant load imbalance
|
| 428 |
+
across devices. Context parallelism is extended to such large samples: **a single large image is
|
| 429 |
+
partitioned along the patch dimension across multiple devices**, and attention is computed by gathering
|
| 430 |
+
key–value pairs across CP ranks. In addition, each CP group is divided into several **sub-CP groups**
|
| 431 |
+
and large images are distributed among them in a load-balanced manner, **preventing the communication
|
| 432 |
+
fraction from growing with scale**. This reduces both the encoder latency of large visual samples and
|
| 433 |
+
the cross-device load imbalance, **allowing the remaining encoder computation to be hidden in pipeline
|
| 434 |
+
bubbles**.
|
| 435 |
+
- **Encoder computation in PP bubbles.** K2.5 introduced the Decoupled Encoder Process, splitting ViT and
|
| 436 |
+
text training into separate stages. K3 observes that **under the interleaved 1F1B schedule, the text
|
| 437 |
+
forward passes of the first PP micro-batches are all scheduled at the very beginning, while the text
|
| 438 |
+
backward passes of the last PP micro-batches finish only at the very end.** They therefore further
|
| 439 |
+
decompose the ViT computation: **the ViT forward passes of the first PP micro-batches are executed
|
| 440 |
+
synchronously upfront, the remaining forward passes are scheduled into pipeline bubbles**, and the
|
| 441 |
+
backward passes are handled analogously. As a result, **most of the ViT computation is hidden within
|
| 442 |
+
pipeline bubbles, largely eliminating the effective overhead of the vision encoder.**
|
| 443 |
+
|
| 444 |
+
### 4.3 Infrastructure for 1M agentic RL
|
| 445 |
+
|
| 446 |
+
- **Co-located RL training** keeps each 1M-context RL experiment within a few hundred GPUs, and partial
|
| 447 |
+
rollouts reduce tail latency. This achieves good hardware utilization but **introduces memory
|
| 448 |
+
contention between the rollout KV cache that must be persisted for the next iteration and the memory
|
| 449 |
+
needed for training** — more severe in long-context RL.
|
| 450 |
+
- **External KV cache pool.** At 1M-context multi-step rollout, a prefix KV-cache miss is extremely
|
| 451 |
+
expensive. Partial rollout exacerbates this (many unfinished long prefill requests from the previous
|
| 452 |
+
iteration arrive at the same time), and speculative decoding further accelerates request turnover within
|
| 453 |
+
relatively fixed tool-call intervals, **increasing prefix-block churn** and lowering the cache hit rate.
|
| 454 |
+
The fix decouples prefix retention from GPU residency with a **write-back design**: active decoding
|
| 455 |
+
blocks remain in GPU KV cache, while **reusable prefixes are written back to an external KV cache pool
|
| 456 |
+
in CPU DRAM only when evicted from GPU**, and prefetched back before the next reuse. **KDA states are
|
| 457 |
+
offloaded and prefetched together with the corresponding MLA KV cache blocks, keeping their lifecycles
|
| 458 |
+
aligned.** Compared with a write-through strategy, this incurs CPU DRAM usage and transfer bandwidth
|
| 459 |
+
only for prefixes that leave the active decode path, avoiding redundant CPU copies of blocks that are
|
| 460 |
+
still resident and active on GPU. Sufficient DRAM is available because **training states (model weights
|
| 461 |
+
and optimizer states) are offloaded to NVMe after a training iteration finishes**; the pool is released
|
| 462 |
+
after a rollout iteration to avoid contention with training workloads.
|
| 463 |
+
- **Rollout auto-throttling scheduler.** In multi-step rollout, contexts grow progressively as the
|
| 464 |
+
trajectory advances, making fixed concurrency based on the full-trajectory average length both hard to
|
| 465 |
+
estimate and overly conservative early on. Conversely, setting concurrency too high creates KV cache
|
| 466 |
+
pressure in later stages and can trigger preemption. An **auto-throttling mechanism at the LLM request
|
| 467 |
+
scheduling layer** uses runtime signals such as active request count, queued request count, and KV
|
| 468 |
+
cache utilization to dynamically control how many requests are sent to the inference engine — keeping
|
| 469 |
+
early rollout well utilized while reducing concurrency as KV cache pressure rises, **avoiding both
|
| 470 |
+
under-saturation and overload without manual tuning**.
|
| 471 |
+
- **Gradient-buffer reuse for non-policy model forwarding.** RL loss computation often requires
|
| 472 |
+
forward-only non-policy models, such as reference models, whose weights are too large to keep resident
|
| 473 |
+
on GPU. These weights are **kept in CPU memory and materialized only when needed, backing their
|
| 474 |
+
parameter tensors by the policy model's FP32 gradient-buffer storage.** This reuses existing GPU memory
|
| 475 |
+
without extra allocation or fragmentation, and **remains safe because the buffers are overwritten when
|
| 476 |
+
real gradients are later computed**. With ZeRO-2 gradient sharding and offloading, each GPU retains
|
| 477 |
+
gradient buffers for only two VPP chunks; reference weights are **streamed into these slots chunk by
|
| 478 |
+
chunk — one slot for the current forward computation while the other prefetches the next chunk** —
|
| 479 |
+
hiding copy overhead without increasing GPU memory.
|
| 480 |
+
|
| 481 |
+
### 4.4 AgentENV — the microVM sandbox (open source, MIT)
|
| 482 |
+
|
| 483 |
+
K3 employs multiple sandbox runtimes: a traditional container-based runtime, a GPU sandbox runtime, and
|
| 484 |
+
most notably **AgentENV**, a microVM-based sandbox developed in collaboration with partners. Three core
|
| 485 |
+
design goals:
|
| 486 |
+
|
| 487 |
+
1. **High-fidelity isolated sandbox runtime.** As agents become more capable and tasks more difficult,
|
| 488 |
+
they explore more aggressively and may even attempt reward hacking. In early experiments with
|
| 489 |
+
traditional container-based sandbox runtimes they **observed several kernel panics and deadlocks
|
| 490 |
+
caused by unintended agent operations**. On the other hand, they want to permit as much exploration
|
| 491 |
+
as possible: complex tasks require a sandbox close to a real-world environment — agents should be able
|
| 492 |
+
to mount disks, run containers, or even launch virtual machines at will. **Firecracker microVMs**
|
| 493 |
+
provide a level of isolation and fidelity that container-based runtimes cannot match.
|
| 494 |
+
2. **Flexible sandbox life-cycles for agentic RL.** At the low level, AgentENV supports **incremental
|
| 495 |
+
checkpointing and resuming**, where only memory pages dirtied since the last checkpoint are saved —
|
| 496 |
+
achieving **checkpoint and resume latencies as low as 133 ms and 49 ms** respectively. On top of this,
|
| 497 |
+
three high-level operations:
|
| 498 |
+
- **Pause and Resume** — a paused sandbox consumes no memory or CPU, and a sandbox can therefore be
|
| 499 |
+
paused while the agent is waiting for the model's inference result, **which can account for as much
|
| 500 |
+
as 98% of the sandbox lifetime**.
|
| 501 |
+
- **Fork** — creates a new sandbox from the exact state of the original while keeping the original
|
| 502 |
+
running, **useful for reward judging without side effects**.
|
| 503 |
+
- **Snapshot** — snapshots at regular intervals for error recovery.
|
| 504 |
+
3. **High efficiency and high density.** Tens of thousands of sandboxes, each with a unique set of
|
| 505 |
+
images, may need to be created within seconds. They adopt **OverlayBD** as the image format, together
|
| 506 |
+
with a custom ublk driver implementation, storage-layer sharing, and P2P transport, **achieving
|
| 507 |
+
sub-second launch latency at large scale**. Copy-on-write memory and page-cache optimizations further
|
| 508 |
+
reduce memory usage, achieving a **memory overcommit ratio of up to 6.5× in real workloads**.
|
| 509 |
+
|
| 510 |
+
> **Scale.** Throughout K3's training and evaluation, a total of **51,219,741 sandboxes across
|
| 511 |
+
> 1,505,678 images** were created. **[report]**
|
| 512 |
+
|
| 513 |
+
### 4.5 Inference and online serving
|
| 514 |
+
|
| 515 |
+
**KDA-aware prefix cache management.** The hybrid architecture complicates prefix caching: the KDA
|
| 516 |
+
recurrent state and the MLA KV cache **differ fundamentally in size and lifetime**, yet a cached prefix
|
| 517 |
+
is reusable only when both can be restored together at the same boundary.
|
| 518 |
+
|
| 519 |
+
- **Unified cache layout.** KDA states are **packed into the same paged block pool as MLA KV**, with
|
| 520 |
+
pages unified to the same byte size so both page types share one implementation of allocation,
|
| 521 |
+
eviction, and transfer. Within a page, the states of all heads are **stored contiguously head by
|
| 522 |
+
head**, so each head's byte stream is self-contained and serves as the minimal unit of cross-node
|
| 523 |
+
transfer. Under prefill/decode disaggregation, when prefill and decode nodes adopt different TP
|
| 524 |
+
degrees, **re-layout is performed on the transfer path with zero GPU-side reshuffling**. This
|
| 525 |
+
asymmetry proved useful during development: **any type-confused access yields garbage rather than
|
| 526 |
+
plausible data — a zero-overhead sanity check on the pooled layout.**
|
| 527 |
+
- **The granularity problem.** Block-hash-based prefix caching reuses the KV cache at the granularity of
|
| 528 |
+
one physical block; only complete blocks are hashed. This coupling breaks down in K3. Block-hash
|
| 529 |
+
matching requires one block size shared by all layers, and a prefix hit is reusable only if the KDA
|
| 530 |
+
state at the hit boundary has been persisted. A KDA layer maintains **a single large recurrent state
|
| 531 |
+
per sequence** rather than per-token entries, so state snapshots are affordable only at sparse
|
| 532 |
+
boundaries — and the shared block size is therefore **forced to 1024–6144 tokens**, with the hash
|
| 533 |
+
granularity tied to the storage block. At such a coarse granularity **caching is nearly useless**:
|
| 534 |
+
requests shorter than one block can never be reused, and chunked prefill exports no cacheable prefix
|
| 535 |
+
until it crosses a full block boundary.
|
| 536 |
+
- **Decouple the two granularities.** Prefix hashing runs on fine **hash blocks** (e.g. 512 tokens)
|
| 537 |
+
inside MLA pages, while the physical block remains the coarse allocation unit. Alignment runs the other
|
| 538 |
+
way for KDA: **checkpoints of the recurrent state are saved only at (a sparse subset of) MLA's hash
|
| 539 |
+
endpoints** — the only positions a lookup can ever reference.
|
| 540 |
+
- During prefill, a partially filled MLA page is **registered in the prefix-cache index under the
|
| 541 |
+
chained hash of its last complete hash block**, where each hash covers all preceding hash blocks so
|
| 542 |
+
that matching an endpoint certifies the whole prefix up to it; the registered endpoint advances as the
|
| 543 |
+
page fills. Meanwhile, the KDA kernel persists the recurrent state **at the last hash-aligned position
|
| 544 |
+
processed on each forward pass**. Checkpoints are large, so intermediate checkpoints are superseded as
|
| 545 |
+
the request advances and recycled, while **those at conversation-turn boundaries are retained** for
|
| 546 |
+
cross-request reuse. Cached checkpoints are **read-only snapshots**: a hit restores the state by
|
| 547 |
+
copying it into the request's private running state before the next forward pass, and new checkpoints
|
| 548 |
+
are written to fresh slots, **so a checkpoint visible to other requests is never mutated in place**.
|
| 549 |
+
- Lookup proceeds in two stages. The MLA stage matches whole physical blocks by chained hash and, **at
|
| 550 |
+
the first missing block, falls back to the hash endpoints inside it**, so partially filled pages remain
|
| 551 |
+
hittable. The KDA stage then **requires a checkpoint at the candidate boundary in every KDA cache
|
| 552 |
+
group**. The hit is the longest boundary satisfying both stages — **always a multiple of the hash
|
| 553 |
+
block, and never required to be a multiple of the physical block.**
|
| 554 |
+
- **Consistency under concurrent scheduling**, dictated by three concrete failure modes: ① all cache
|
| 555 |
+
groups draw blocks from one shared free list, so allocating a private copy for one group could evict a
|
| 556 |
+
block that another group has just hit → **every hit block is pinned across all groups before anything
|
| 557 |
+
is allocated**; ② the copy into the private block executes on the GPU immediately before the forward
|
| 558 |
+
pass, so a block allocated or registered within the current scheduling step would still hand the
|
| 559 |
+
previous owner's bytes to a reader → **such blocks are excluded from matching until their copies
|
| 560 |
+
land**; ③ a checkpoint can restore a request only if it exists in every KDA group, so **evicting one
|
| 561 |
+
group's checkpoint atomically invalidates its siblings** — a checkpoint is either hittable in every
|
| 562 |
+
group or in none.
|
| 563 |
+
- **Result:** prefix caching for hybrid KDA–MLA models **reaches the same generality as for
|
| 564 |
+
full-attention models — any shared prefix is reusable at any 512-token boundary, independently of
|
| 565 |
+
request length, chunking, or scheduling interleaving.**
|
| 566 |
+
|
| 567 |
+
**High-performance kernels.**
|
| 568 |
+
|
| 569 |
+
- **KDA decoding.** The bottleneck shifts from exploiting parallelism to efficiently managing the
|
| 570 |
+
evolving recurrent state, which is updated in place at every decoding step. This in-place update
|
| 571 |
+
becomes problematic in MTP-based speculative decoding: **if verification rejects a subset of the drafted
|
| 572 |
+
tokens, the state has already advanced beyond the last accepted token and cannot be trivially rolled
|
| 573 |
+
back.** Maintaining a state snapshot per draft position would enable rollback but would multiply state
|
| 574 |
+
traffic — a cost that dominates at the large batch sizes typical of online serving. The observation:
|
| 575 |
+
**the state after any accepted draft prefix is fully determined by the projected inputs of the draft
|
| 576 |
+
tokens, which are far smaller than the state itself.** So they **cache only these projected inputs**,
|
| 577 |
+
rebuild the states of accepted tokens on-chip, and write back the states of the verified and bonus
|
| 578 |
+
tokens — a design independently proposed in the concurrent work ReplaySSM. The replayed tokens, the
|
| 579 |
+
bonus token, and the next draft window **share one recurrent loop inside a single fused kernel**
|
| 580 |
+
covering short convolution, input normalization, gating, the KDA recurrence, and output normalization.
|
| 581 |
+
Verification latency grows **sub-linearly** with the number of tokens verified and remains below that of
|
| 582 |
+
state-caching baselines. **Because the projection caches never leave the decode stage, prefix caching
|
| 583 |
+
and prefill–decode disaggregation operate on the same payload as in non-speculative serving.**
|
| 584 |
+
- **Block AttnRes.** A two-stage schedule: a batched inter-block pass reads the cached block
|
| 585 |
+
representations once per block, after which each layer folds in the intra-block partial sum through an
|
| 586 |
+
**online-softmax merge**. Memory access accounts for a substantial fraction of the cost of these kernels
|
| 587 |
+
in both prefill and decoding, so both stages focus primarily on memory efficiency. **For prefill**,
|
| 588 |
+
materializing the block representations on every tensor-parallel rank would incur substantial redundant
|
| 589 |
+
memory consumption; they therefore adopt **sequence parallelism for activations** — the TP all-reduce of
|
| 590 |
+
the AttnRes output is decomposed into a reduce-scatter and an all-gather, with the intra-block kernel
|
| 591 |
+
inserted between the two collectives, operating on the sequence-sharded hidden states so that the block
|
| 592 |
+
representations of each token are **materialized on exactly one rank**. **For decoding**, the inter-block
|
| 593 |
+
kernel is launched on a side stream so that it overlaps with independent computation on the main stream;
|
| 594 |
+
the intra-block kernel is instead streamlined through **fusion** — the merging of the AttnRes output with
|
| 595 |
+
its partial-sum update, together with the subsequent RMSNorm, is fused into the preceding TP all-reduce,
|
| 596 |
+
eliminating a dedicated kernel for the intra-block phase and reducing its memory traffic.
|
| 597 |
+
- **Stable LatentMoE.** Three optimizations mitigate the overhead of the latent GEMMs: ① **fuse the latent
|
| 598 |
+
down-projection with the MoE router into a single GEMM**; ② shard latent weight matrices across ranks and
|
| 599 |
+
**fuse the output all-gather into the GEMM epilogue using multimem store instructions**; ③ overlap the
|
| 600 |
+
resulting communication with other operators, such as the shared-expert computation. **For routed experts
|
| 601 |
+
at small batch sizes**, the group GEMMs reduce to memory-bound streaming of weight matrices — a regime for
|
| 602 |
+
which conventional tile-centric kernels are poorly suited due to their compute-oriented design and
|
| 603 |
+
preprocessing overheads. They instead build the MoE decoding kernel upon the **token-centric design of
|
| 604 |
+
WarpDecode**, in which **each warp is responsible for one output neuron and streams the associated weights
|
| 605 |
+
directly from memory**; each warp is further subdivided into finer-grained lane teams, each processing a
|
| 606 |
+
disjoint subset of experts, followed by a warp-wide reduction of the partial results. The weight layout is
|
| 607 |
+
**permuted offline at a one-time preprocessing cost**, substantially reducing the runtime dequantization
|
| 608 |
+
overhead.
|
| 609 |
+
|
| 610 |
+
**Fleet-level scheduling.**
|
| 611 |
+
|
| 612 |
+
- **Cache-aware affinity scheduling.** At 1M context, a typical coding input carries a prefix of 400K
|
| 613 |
+
tokens but requires a prefill increment of only ~4K tokens, so **a prefix-cache hit avoids re-prefilling
|
| 614 |
+
the entire prefix and is orders of magnitude cheaper than a miss**. Each request is therefore routed to
|
| 615 |
+
the cluster that holds its prefix cache, as moving the cache to another cluster would require
|
| 616 |
+
transferring it over inter-cluster links far slower than the intra-cluster fabric. This affinity, however,
|
| 617 |
+
binds each session to a single cluster, whose failure would interrupt all sessions bound to it.
|
| 618 |
+
**Consistent hashing therefore pins each session to two clusters**, a primary that serves its traffic and
|
| 619 |
+
a pre-assigned secondary that takes over when the primary fails. The secondary holds none of the session's
|
| 620 |
+
prefix cache and must re-prefill it upon failover; but since consistent hashing **distributes the secondary
|
| 621 |
+
assignments of different sessions uniformly across the fleet**, this re-prefill load is divided among many
|
| 622 |
+
clusters rather than concentrated on one. Cache locality is preserved in the common case while the impact
|
| 623 |
+
of any single cluster failure remains bounded.
|
| 624 |
+
- **Budget-based admission control.** Production traffic mixes short requests under 2K tokens with ultra-long
|
| 625 |
+
requests up to 1M tokens, so **the per-request cost spans roughly three orders of magnitude** and the total
|
| 626 |
+
load imposed by any fixed number of requests is highly unpredictable. Capacity planning, queueing models,
|
| 627 |
+
and rate-limiting quotas based on the "average request" all break down under this variance. In a typical
|
| 628 |
+
failure mode, a burst of long-context requests saturates the available compute, and short requests arriving
|
| 629 |
+
afterwards cannot be scheduled promptly, **degrading time to first token across all traffic**. They
|
| 630 |
+
therefore allocate **separate resource budgets to different request classes**, so that bursty long-context
|
| 631 |
+
traffic consumes at most its own share of the capacity and **cannot degrade the system-wide SLOs
|
| 632 |
+
experienced by other classes**.
|