Search

Search papers and lessons

Kimi K2: Open Agentic Intelligence

Kimi Team, Yifan Bai, Yiping Bao et al. · 2025

Kimi K2 is an open 1-trillion-parameter mixture-of-experts model, trained with a stabilised Muon optimizer and tuned with agentic tool-use data and reinforcement learning.

On this page

  • Colour = topic mix
  • Linear algebra
  • Discrete math
  • Probability
  • Calculus
  • Neural network basics
  • Optimizers
  • ReadReady to readNot yet

TL;DR

Kimi K2 is a large language model with 1.04 trillion parameters, but only 32 billion of them run for any one token, because a router sends each token to a few specialist sub-networks (experts). The team trained it on 15.5 trillion tokens with a new optimizer, MuonClip, that never produced a loss spike, then tuned it to act as an agent: it learns to call tools, and it is trained with reinforcement learning on tasks that have checkable answers plus a self-judged reward for open-ended ones. They released the weights openly.

Builds on: Mixture of Experts, Muon Optimizer, Tool Use, Reinforcement Learning, LLM-as-a-Judge · Leads to: LLM Agent, SWE-bench: Can Language Models Resolve Real-World GitHub Issues?

Why it mattered

The paper is one of the clearest public accounts of how a frontier-scale open model was trained for agentic work: multi-step tool use, software repair and long multi-turn tasks. Three ideas stand out. The first is that a very sparse mixture of experts, here 384 experts with 8 active per token, can be pushed further than earlier designs. The second is that an optimizer can be stabilised by clipping attention logits directly in the weights. The third is that reinforcement learning can be extended from tasks with a checkable answer to subjective tasks by letting the model rank its own outputs.

The authors also report a concrete outcome: on the LMSYS Arena leaderboard (July 17, 2025) Kimi K2 ranked first among open-source models and fifth overall, based on more than 3,000 user votes. On SWE-bench Verified it scored 65.8 in the single-attempt agentic setting, and 71.6 with multiple attempts.

History

The paper places itself in a line of work. Its architecture follows DeepSeek-V3 (DeepSeek-V3 Technical Report), its RL algorithm comes from the authors' K1.5 work (Kimi k1.5: Scaling Reinforcement Learning with LLMs), and its pre-training is planned with scaling-law analysis of the kind described in Neural Scaling Laws. The authors' earlier Moonlight work reported that Muon beat AdamW under the same compute budget; scaling Muon up exposed exploding attention logits, which is the problem MuonClip addresses here. The authors then released the base and post-trained checkpoints openly.

The problem

Three things were blocking the next step.

Token supply. High-quality human text is limited, so a model must get more learning out of each token it sees. The paper calls this token efficiency. The optimizer Muon had shown better token efficiency than AdamW (AdamW Optimizer) in the authors' earlier work, but scaling it up made training unstable.

Instability. The problem is exploding attention logits. The attention score between a query and a key is a dot product that, if it grows too large, pushes the softmax (Softmax) into a near one-hot state and can make the loss jump or diverge. The authors report that in a mid-scale run with plain Muon, the maximum logits passed 1000. Two existing fixes did not fit: logit soft-capping clips the score only after the dot product has already grown, and query-key normalisation is not compatible with multi-head latent attention, because the key matrices are not fully built at inference time.

Agentic skill. Multi-step planning, long-horizon use of tools and error recovery are rare in ordinary web text. They have to be synthesised and then reinforced, and real environments are expensive to build at scale.

How it works

Here is the pipeline in the order the paper runs it.

  1. Pre-training data. The corpus has 15.5 trillion tokens across web text, code, mathematics and knowledge. For knowledge and maths text, the authors rewrite passages in several styles, a method they describe as rephrasing. Instead of repeating the same text for 10 epochs, they rephrase it and train for fewer passes.

  2. Architecture. Each MoE layer has 384 experts. For each token, a router picks 8 of them, and one shared expert is used by every token. The attention is multi-head latent attention with 64 heads, half the 128 used in DeepSeek-V3 (DeepSeek-V3 Technical Report). A toy version: a layer with 6 experts and a router that picks 2 per token runs 2 experts for each token and leaves 4 idle. Kimi K2 runs 8 of its 384 experts for each token.

  3. Pre-training with MuonClip. The optimizer does a Muon step, a momentum-weighted update orthogonalised by Newton-Schulz iteration (Muon Optimizer), and then a QK-Clip step. QK-Clip looks at each attention head's largest recent logit. If it is above a threshold tau, it rescales that head's query and key weights after the update. The forward pass in that step is not changed; only the weights are adjusted so future logits shrink. The authors set tau to 100. The logits hit that cap early and fall back to a normal range later in training, and the loss curve has no spikes.

  4. Agentic data synthesis. The team builds a tool repository of more than 3,000 real MCP tools from GitHub plus more than 20,000 synthetic tools. For each toolset they generate an agent, a set of tasks with rubrics, and then multi-turn trajectories in which a simulated user talks to the agent and a tool simulator returns results and updates state. An LLM judge keeps only trajectories that meet the rubric. For coding, real sandboxes run tests so that the signal is ground truth.

  5. Reinforcement learning. Verifiable tasks (maths, logic puzzles, instruction following with code checks, competitive programming, software engineering with unit tests) give a reward from a checker. For open-ended tasks, the model itself compares pairs of responses against a rubric and that judgement is the reward. The RL update minimises a squared-error objective inherited from the K1.5 policy optimisation (see the math section), with a per-task token budget: responses over budget are truncated and penalised.

  6. Evaluation. The model is run in non-thinking mode on coding, tool-use, reasoning, general and safety benchmarks, against open and closed baselines.

The math

Step 2 in symbols: sparsity

Sparsity is the ratio of total experts to active experts. Kimi K2 has 384 experts and 8 active per token, so its sparsity is 384 / 8 = 48. The fraction of expert parameters a token uses is 1 / 48, about 2.1 percent. The authors report that, at a fixed number of active parameters, raising sparsity lowers loss, and that sparsity 48 reduces FLOPs by 1.69 times compared with sparsity 8 for the same validation loss of 1.5. They chose 48 because more sparsity adds infrastructure complexity.

Step 3 in symbols: the MuonClip update

Let M_t be the momentum buffer of a weight matrix at step t, G_t its gradient, mu the momentum coefficient, eta the learning rate and lambda the weight decay. The Muon part is

Mt=μMt−1+Gt,Ot=NS⁡(Mt)⋅max⁡(n,m)⋅0.2,Wt=Wt−1−η(Ot+λWt−1)\mathbf{M}_{t}=\mu\mathbf{M}_{t-1}+\mathbf{G}_{t},\qquad \mathbf{O}_{t}=\operatorname{NS}(\mathbf{M}_{t})\cdot\sqrt{\max(n,m)}\cdot 0.2,\qquad \mathbf{W}_{t}=\mathbf{W}_{t-1}-\eta\bigl(\mathbf{O}_{t}+\lambda\mathbf{W}_{t-1}\bigr)

where NS is the Newton-Schulz iteration that approximately replaces a matrix with its nearest orthogonal matrix, and the factor 0.2 matches the update size to Adam's.

Step 3 in symbols: the QK-Clip rule

For head h, the maximum logit in a batch is

Smax⁡h=1dmax⁡X∈Bmax⁡i,jQihKjh⊤S^{h}_{\max}=\frac{1}{\sqrt{d}}\max_{\mathbf{X}\in B}\max_{i,j}\mathbf{Q}^{h}_{i}\mathbf{K}^{h\top}_{j}

where d is the head dimension and i, j index tokens. If S_max^h is above tau, set gamma = tau / S_max^h, which is below 1. The content query and key weights of that head are multiplied by the square root of gamma each, and its head-specific rotary query weights by gamma. The shared rotary key is left alone, so the rotary change does not leak into other heads. Because the content logit is a product of one query and one key, it scales by gamma, and the largest logit for that head is pulled to about tau after the update.

Step 5 in symbols: the RL objective

For a prompt x, the policy samples K responses y_1 to y_K from the previous policy, with rewards r(x, y_i). Let rbar be their mean reward. The paper's objective is

LRL(θ)=Ex[1K∑i=1K(r(x,yi)−rˉ(x)−τlog⁡πθ(yi∣x)πold(yi∣x))2]L_{\mathrm{RL}}(\theta)=\mathbb{E}_{x}\left[\frac{1}{K}\sum_{i=1}^{K}\left(r(x,y_i)-\bar{r}(x)-\tau\log\frac{\pi_\theta(y_i\mid x)}{\pi_{\mathrm{old}}(y_i\mid x)}\right)^{2}\right]

Here the term r minus rbar is the advantage of a response relative to its siblings, and the log-ratio keeps the new policy close to the old one. The regularisation strength is also written tau in the paper, which is a different tau from the QK-Clip threshold.

Worked examples

Example
Tiny: how many experts are idle?
  1. A layer has 6 experts. The router chooses the 2 with highest scores for each token.
  2. For one token, 2 experts run and 4 do not.
  3. So 4 of 6 experts are idle for that token, which is 2 / 3 of the layer's expert parameters.
  4. Now scale the same ratio to Kimi K2: 8 of 384 run, so 376 are idle, which is about 97.9 percent.
  5. Interpretation: sparsity lowers compute per token while the total parameter count stays large.
Example
Standard: clipping one head
  1. Suppose a head's largest logit in a batch is S_max^h = 250, and tau = 100.
  2. Compute gamma = tau / S_max^h = 100 / 250 = 0.4.
  3. Multiply that head's query weights and key weights each by the square root of 0.4, about 0.6325.
  4. The logit is a dot product of one query and one key, so its size scales by 0.6325 times 0.6325 = 0.4.
  5. New largest logit: 250 times 0.4 = 100, equal to tau.
  6. Interpretation: the clip acts on the weights after the update, so future logits in that head are pulled down toward the cap. Only the head that exceeded the cap is touched.
Example
Realistic: rephrasing versus repetition

Table 1 of the paper compares three ways of using the same knowledge text, measured by SimpleQA accuracy on an early checkpoint:

SetupRephrasingsEpochsSimpleQA accuracy
Raw text repeated01023.76
Rephrased once, repeated11027.39
Rephrased ten times, one pass10128.94
  1. Compare the first and third rows, which are the two extremes.
  2. The difference is 28.94 minus 23.76 = 5.18 points.
  3. As a share of the baseline, 5.18 / 23.76 is about 0.218, so about 21.8 percent more accuracy.
  4. The second row isolates the effect of one rephrasing: 27.39 minus 23.76 = 3.63 points for the first rewrite.
  5. Interpretation: rewriting the text adds new surface forms that carry the same facts, so each pass gives more learning signal than repeating the original.6. Try it: using only the second and third rows, how many accuracy points does going from one rephrasing for 10 epochs to ten rephrasings for one epoch add? Answer: 28.94 minus 27.39 = 1.55 points.

Results

The paper reports the following for Kimi-K2-Instruct, all in non-thinking mode, with values from its Table 3.

AreaBenchmarkKimi K2Best comparison in the table
CodingLiveCodeBench v6 (Pass@1)53.748.5 (Claude Sonnet 4)
CodingSWE-bench Verified, agentic single attempt65.872.7 (Claude Sonnet 4, marked from its own report)
CodingSWE-bench Multilingual47.351.0 (Claude Sonnet 4)
Tool useTau2 retail / airline / telecom70.6 / 56.5 / 65.881.8 / 60.0 / 57.0 (Claude Opus 4)
Tool useAceBench (Acc.)76.580.1 (GPT-4.1)
MathAIME 2025 (Avg@64)49.546.7 (DeepSeek-V3-0324)
ScienceGPQA-Diamond (Avg@8)75.174.9 (Claude Opus 4)
GeneralMMLU (EM)89.592.9 (Claude Opus 4)
GeneralIFEval (Prompt Strict)89.888.0 (GPT-4.1)

Read these carefully. The paper says the model outperforms most open- and closed-weight baselines under non-thinking settings, and claims open-source state of the art on real-world SWE tasks. Proprietary models still score higher on several rows, as the table shows; the caption says bold marks the global best and underlined bold marks the best open-source result. The abstract's Tau2-Bench figure of 66.1 is reported separately from the three per-domain numbers in the table. The main limits, in the paper's words, are excessive token generation on hard reasoning or unclear tool definitions, which can truncate outputs or leave tool calls incomplete, and weaker one-shot results on building whole software projects than the agentic coding framework.

Common mistakes and tradeoffs

It is tempting to think a bigger model is simply a bigger dense model. In fact the 1.04 trillion parameters are mostly stored experts; each token uses about 32 billion. Memory and serving cost still scale with the total, while compute per token scales with the active part.

It is tempting to think clipping logits limits the model. In fact QK-Clip changes the weights after an update and leaves the forward pass in that step unchanged, so the cap is a steering signal that pulls logits back toward the threshold over time. The paper's own figure shows the max logits sitting at the cap early in training and only falling to a stable range after about 30 percent of the training steps.

It is tempting to think a model judging its own answers is circular. In fact the paper grounds the judge: rollouts from verifiable-reward tasks are used to keep updating the critic, so the judge's standards are tied to objective signal. Self-judgement still has limits: Appendix F.3 notes that the critic rubrics may favour confident, assertive answers even where a question is ambiguous.

It is tempting to think that more sparsity is always better. The paper's scaling experiments support that loss falls as sparsity rises, but they chose 48 because the infrastructure cost grows. Similarly, doubling attention heads improved validation loss by only 0.5 to 1.2 percent in their experiments, while raising inference FLOPs by 83 percent at a 128k sequence length, so they kept 64 heads.

When to use this recipe: a large open model where long-horizon tool use and coding matter, and where you can afford synthetic data generation and a sandboxed RL environment. When not to: a small model or a short-context chat product, where the sparse-routing and agentic machinery adds complexity without a clear payoff. Alternatives include dense models with conventional AdamW (AdamW Optimizer), preference-based tuning such as Direct Preference Optimization, and group-relative variants of RL such as Group Relative Policy Optimization (GRPO).

Reading guide

Recap

  • Sparse mixture of experts: 1.04 trillion total parameters, 32 billion active, 384 experts with 8 chosen per token.
  • MuonClip: the Muon optimizer plus QK-Clip, which rescales query and key weights whenever a head's logit passes tau = 100, giving a run with no loss spikes over 15.5 trillion tokens.
  • Agentic data: simulated tools, agents, tasks and trajectories, filtered by rubric and by real sandboxes for coding.
  • Reinforcement learning: verifiable rewards plus a self-critique reward, with token budgets and a PTX loss to keep high-quality data in play.
  • Read next: LLM Agent for the agent loop in general, and SWE-bench: Can Language Models Resolve Real-World GitHub Issues? for the benchmark the paper leans on most.

Check yourself

QuestionWhat is the sparsity of Kimi K2's expert layers, and why did the authors stop at that value rather than go higher?Show answer

Sparsity is total experts divided by active experts: 384 / 8 = 48. Scaling experiments showed loss keeps falling as sparsity rises, but the infrastructure complexity of more experts grows, so the authors chose 48 to balance performance and cost.

QuestionA head's largest logit is 400 and tau is 100. What scale factor gamma does QK-Clip compute, and what is the new largest logit?Show answer

gamma = 100 / 400 = 0.25. The query and key weights are each multiplied by the square root of 0.25, which is 0.5, so the logit scales by 0.5 times 0.5 = 0.25. The new largest logit is 400 times 0.25 = 100.

QuestionWhy does the paper use a self-critique reward for some tasks but a verifier for others?Show answer

Verifiable tasks, such as maths with known answers or code with unit tests, have a checker that gives an objective reward. Open-ended tasks such as creative writing have no such checker, so the model compares pairs of its own responses against rubrics to produce a preference signal. The critic is also refined on verifiable rollouts so its judgements stay grounded.

QuestionCompute the active fraction of expert parameters for one token and explain what it means for serving cost compared with the total size.Show answer

One token activates 8 of 384 experts, so 8 / 384 = 1 / 48, about 2.1 percent of the expert parameters. Compute per token is set by the active part, but the full 1.04 trillion parameters must still be stored and moved, so memory and serving infrastructure cost follow the total size.

Sources

Read the full paper

Kimi Team, Yifan Bai, Yiping Bao et al., 2025. arXiv:2507.20534