Last month, we released our largest open-source model to date, K3.
As the successor to K2, K3 is not a redesign from scratch, but rather a natural evolution along our past series of works, incorporating some of our latest understandings and improvements regarding effectiveness, efficiency, and stability. One might say it is a continuous, "culminating" research achievement rather than an all-in gamble.
In this post, let us discuss some of the architectural design ideas behind K3.
Preface #
Simply put, on the architectural side, K3 = KDA + MLA + Stable LatentMoE + AttnRes. The training optimizer remains the Moonlight version of Muon, but the weights in the Attention component have been switched to a Per-Head format for optimization.
Among these, we have already introduced AttnRes in detail in "Memoirs of Attention Residuals", and for KDA we have also shared a detailed technical report, 《Kimi Linear: An Expressive, Efficient Attention Architecture》. As for Per-Head Muon, it actually has no performance advantage (nor any disadvantage, of course); switching to it was more out of correctness considerations (each head is inherently relatively independent and should not be coupled together).
So in what follows, we will mainly focus our discussion on MoE and MLA: for the former, we will talk about how we "tamed" LatentMoE; for the latter, we will discuss our trade-offs in Attention.
Mixture of Experts #
The MoE used in K3 is what we call "Stable LatentMoE". As the name implies, it is a "Stable" version of "LatentMoE". LatentMoE itself is not new; it comes from 《LatentMoE: Toward Optimal Accuracy per FLOP and Parameter in Mixture of Experts》, with the advantage that it can achieve better performance under roughly the same training and inference costs, but incorporating it also introduced stability issues, so we proposed several improvements.
SiTU #
In current mainstream MoE architectures, an individual expert typically takes the form of SwiGLU:
where
To address this, we first replaced SiLU with SiTU (Sigmoid Tanh Unit):
This first bounds the gating part within
where
Norm #
The difference between LatentMoE and MoE is:
That is, LatentMoE first reduces dimensionality, then performs a
To stabilize training, a naive idea is, after dimension reduction (i.e., the output of
After the fact, we also conducted more careful comparative experiments and found that this extra RMS Norm not only stabilizes training, but also has a magical effect on performance. Specifically, under conditions where all setups converge normally, whether this RMS Norm is added has little effect on the validation loss, but on certain benchmarks, omitting this RMS Norm consistently worsens results.
As for the reason, it may be that this norm better balances the ratio between Routed Experts and Shared Experts (in our tests, after adding this norm, there was no need to add an extra scaling factor), or it may be because normalization is a nonlinear operation (albeit an extremely weak nonlinearity), whose inclusion imperceptibly increases the effective depth of LatentMoE.
QB #
The MoE in K3 was originally conceived as top-8 out of 448, but after introducing LatentMoE, it became top-16 out of 896. Although the sparsity remains unchanged, the increase in the total number of experts still exacerbates the load imbalance problem.
Like the previous-generation model K2, K3 also adopts the Loss-Free load balancing scheme, but the previously used SignSGD-style update rule was no longer very stable with K3's large total number of experts. We therefore introduced QB (Quantile Balancing), which is mathematically more reasonable and needs no additional hyperparameters. We discussed its details in MoE Journey, Part 6: Optimal Allocation Promotes Balance in detail.
The core operation of QB is computing global quantiles, but quantiles are a nonlinear operation; computing them naively incurs very heavy communication. The approach I previously proposed was to compute local quantiles and then average them globally, but later we found that as the scale expanded further, this method was still not accurate enough. Therefore, K3 ultimately adopted bin-based approximation (histogram estimation): after compressing the scores for which quantiles are required to 0–1, we estimate the distribution of scores across bins, and then read off the quantile from the distribution.
Regarding the number of bins, we found that 10,000 bins provided no better gain for load balancing compared to 1,000 bins, so we recommend using 1,000 bins, which is sufficient. Thanks to the additivity of distributions, we can aggregate distribution information across machines and across gradient accumulations with minimal communication overhead, thereby obtaining the global approximate quantile.
Attention Mechanism #
The attention in K3 is a hybrid of "KDA + MLA"; here we mainly discuss MLA. Of course, MLA is no longer new, but there are some details worth discussing. Some readers might scoff: DSV4 has abandoned MLA, and you guys are still using MLA—have you run out of ideas? Certainly not. K3's use of MLA is still the result of careful consideration.
MLA #
A year ago, I wrote The Road to Upgrading Transformers: 20. What Makes MLA Good? (Part 1) and The Road to Upgrading Transformers: 21. What Makes MLA Good? (Part 2), exploring the benefits of MLA from both experimental and theoretical perspectives. At that time, my assessment was: "Under the same training and inference costs, MLA is likely the best-performing Full Attention variant".
Is this judgment still valid today? Basically yes, but with some minor changes. When fixing the training cost and KV cache size, MLA remains a near-optimal attention mechanism. However, beyond the KV cache, decoding now has a new variable—MTP, or speculative decoding, whose core idea is trading compute for speed. Yet during decoding, MLA behaves as an MQA with head_dims=512+, which already consumes most of the compute upfront; therefore, "MLA+MTP" can easily be at a disadvantage.
However, choosing an attention mechanism requires comprehensive consideration across multiple aspects. MTP is only one part of the picture; switching to another design might be friendly to MTP, but not necessarily better in other respects.
During training, MLA is an MHA with 192+128 (qk_dims and v_dims). If we scale it down, for example to a 128+128 GQA8, it is difficult to outperform MLA in terms of performance. Even if it can achieve parity, GQA8's KV cache is more than three times that of MLA, which is unrealistic. Note that introducing MTP only means decoding speed no longer depends solely on KV cache size; it does not mean the KV cache can be arbitrarily large. In long-context scenarios, the KV cache is still strictly better when smaller.
If we scale it up, for instance switching to a 256+256 MFA (which is essentially an MQA), then performance can indeed catch up, and the KV cache is no larger than MLA's. However, training cost increases, making it very likely to lose out under scaling laws. Moreover, prefill cost also increases, which we cannot ignore: in today's common agent and coding scenarios, each round's prefill is quite long.
Therefore, an ideal attention design that is better than MLA must satisfy at least the following conditions:
1. Performance cannot be worse than MLA (guaranteeing effectiveness);
2. Training and prefill costs must at least not exceed those of MLA (computational efficiency);
3. KV cache smaller than MLA's (for ultra-long contexts);
4. Decoding compute smaller than MLA's (MTP-friendly).
At least as I see it now, there is currently no simple and elegant attention design that satisfies all the above characteristics simultaneously. We must therefore make trade-offs. In the context of hybridizing with KDA, some of MLA's issues are alleviated, so we still chose MLA.
DSV4 #
Here, let us take a brief interlude to discuss DSV4's attention. DSV4 seemingly abandoned MLA and redesigned a completely different attention mechanism, but if we examine it closely, we will find that it still carries the shadow of MLA and aligns with both of the aforementioned MLA blog posts and the four directions mentioned just now.
In The Road to Upgrading Transformers: 20. What Makes MLA Good? (Part 1), we experimentally found that the invisibly increased head_dims is key to MLA's performance, and then in The Road to Upgrading Transformers: 21. What Makes MLA Good? (Part 2), we pointed out that for a given KV cache size, the best-performing attention is "an MQA where head_dims equals the KV cache size, with K and V shared".
Thus, DSV4 directly replaces Attention with an MQA where head_dims=512 and K=V (with positional encoding being QKVO-RoPE) to guarantee performance, which is precisely MLA's decoding form. But this causes the computation for training and prefill to skyrocket, and because DSV4 has no linear attention, every layer has a KV cache, which is unsustainable even at only 512 dimensions per token. To address this, DSV4 introduced Sparse and Compress: Sparse saves compute, while Compress further compresses the KV cache and also saves compute.
Therefore, rather than saying DSV4 abandoned MLA, it is better to say that following the directions mentioned in the previous section, it pushed MLA to another extreme. However, such a generalization does not come without cost: first is the infrastructural complexity, and second, whether such aggressive Sparse and Compress are truly optimal feels like it still needs careful scrutiny. But all in all, moving from MLA to DSV4 is more like an inheritance and upgrade rather than an abandonment and reinvention.
Of course, the "Linear+Full" route also has its shortcomings, so compared to the Sparse route, which one will go further remains unknown for now.
NoPE #
There is another detail in K3's MLA: while maintaining the standard MLA structure, it directly removes RoPE, turning it into NoPE. This modification had already appeared in Kimi Linear, but it drew renewed discussion after K3 was released.
First, K3 can have RoPE added back; it is just that after adding RoPE, performance shows virtually no difference, so following the principle of parsimony, it was simply omitted. Note, however, that for an all-MLA model like K2, RoPE is critical, and removing RoPE leads to significant degradation. K3 can use NoPE because it is a hybrid "KDA+MLA" model.
Why can "KDA+MLA" use NoPE? In The Road to Upgrading Transformers: 6. Completeness Analysis of Rotary Position Embedding, we derived that powers of any orthogonal matrix can be used to construct a generalized RoPE. The commonly discussed RoPE chooses simple rotation matrices, whereas PaTH explored another choice—Householder matrices—and also achieved good performance.
In A Brief History of Linear Attention: From Imitation and Innovation to Giving Back, we derived that in the orthogonal case, PaTH can be equivalently written as
This equivalent form indicates that equipping
In addition, there is an aesthetic question: since MLA no longer includes RoPE, why retain the practice of separately concatenating an extra 64 dimensions?
There are many reasons for this, such as fitting the existing MLA infrastructure better without rewriting a whole codebase. More importantly, directly projecting a 576-dimensional latent and then projecting K and V with 192+128 dimensions would indeed be elegant, but it would increase computation without any performance benefit, leaving us worse off overall. Finally, K3 already introduces new variables such as KDA and AttnRes, so we did not want to introduce too many more into MLA—after all, you have to eat one bite at a time.
Summary #
In this post, I have briefly discussed K3's design choices and trade-offs across MoE and Attention. Overall, none of K3's modifications are particularly radical or flashy, and virtually every one of them is backed by clear motivations and experimental support. Balancing performance, efficiency, and stability remains the central theme of architectural design.
