Kimi Linear: A Hardware-Aware Architecture for Efficient Long-Context AI Inference
Moonshot AI has introduced another notable release. After the strong impression created by Kimi-K2 and its post-training strategy, the team has now presented Kimi Linear alongside Kimi-K2-Thinking, which is also worth exploring. Kimi Linear is a hybrid linear attention architecture that introduces a new attention method called Kimi Delta Attention, or KDA.
The release includes an open-source KDA kernel written in Triton, vLLM implementations, and both pre-trained and instruction-tuned model checkpoints. The model has 48 billion total parameters, 3 billion activated parameters, and supports a context length of 1 million tokens.
In this article, we will review the most important findings from the Kimi Linear paper and explain how the model can be run on a general GPU-based cloud server environment.
Key Takeaways
- Kimi Delta Attention, or KDA, is a linear attention mechanism that uses fine-grained, channel-wise gating. This improves memory handling and hardware efficiency compared with earlier approaches such as Gated DeltaNet, also known as GDN, and Mamba2.
- KDA uses a specialized version of Diagonal-Plus-Low-Rank, or DPLR, transition matrices to increase Tensor Core utilization.
- Kimi Linear uses a hybrid architecture with three KDA layers combined with one MLA layer. This design reduces KV cache usage by 75% and can deliver up to 6 times higher decoding throughput at a 1 million token context length.
In earlier explanations of FlashAttention, the attention mechanism and the need for hardware-aware algorithms were discussed. Creating attention mechanisms that are more aware of hardware limitations and more efficient with memory remains an active research area, so continued progress in this field is expected. Kimi Delta Attention is a form of linear attention that also includes gating. To make the motivation behind this new attention variant easier to understand, the following sections provide an overview of linear attention and explain how gating mechanisms support memory efficiency and numerical stability.
Primer on Linear Attention
Traditional attention calculates attention scores by applying softmax to a similarity matrix. This approach has quadratic time and memory complexity in relation to sequence length, commonly expressed as O(n²). Several linear attention variants aim to reduce the quadratic complexity of standard attention. Linear attention is an approximate attention method that improves efficiency while accepting some trade-off in accuracy.
In linear attention, the softmax operation used in traditional attention is replaced with a positive feature map. This feature map is designed so that the resulting kernel, calculated as a dot product, remains positive. This imitates the effect of softmax without requiring the explicit normalization step.
However, linear attention can struggle with long-context retrieval. This limitation is one of the reasons Kimi Linear uses a hybrid architecture, which will be explained later.
The Role of Gating
Efficiently managing information over long sequences is an ongoing challenge in AI model design. Gating mechanisms are intended to improve memory efficiency by adding a selective forgetting factor to the attention process. A similar concept is used in recurrent neural networks such as LSTMs.
Gating with Linear Attention
When gating is used with linear attention, the quadratic and continuously growing Key-Value cache of traditional attention is replaced by a fixed-size, matrix-valued state and learnable gates. As the sequence is processed, this allows the model to choose which information should be retained and which information should be forgotten.
Gating is frequently combined with a delta update rule, as seen in KDA and Gated DeltaNet. This enables more precise updates to memory. In this context, the delta update rule means calculating the difference, or delta, between new values and predicted values in order to update the hidden state that acts as the memory state.
Designing Hardware-Aware Algorithms
Designing hardware-aware algorithms requires understanding the hardware and rethinking the mathematics behind the computation. Modern GPUs perform especially well when workloads can be parallelized and are mainly based on matrix multiplications. By contrast, they are less efficient with sequential dependencies and operations that are not matrix multiplications. This creates a challenge for linear attention models such as KDA, because they are inherently recurrent.
For a recurrent method such as KDA, the goal is therefore to make the computation as easy to split into chunks as possible so it can be parallelized more effectively. At the same time, unnecessary non-matrix-multiplication operations should be removed if they do not change the final result. Reducing non-matmul FLOPs was also an important idea behind FlashAttention-2, because this helps maximize the use of Tensor Cores, which are optimized for accelerating matrix multiplication throughput.
The following section explains how the Kimi team applied this reasoning during the development of Kimi Linear.
As mentioned earlier, the KDA update is recurrent. It is a sequential, autoregressive process. In other words, to calculate the state at time St, the state at time St-1 must already be known. If this were implemented in a simple and direct way, the GPU would have to process tokens one after another, leaving a large amount of compute capacity unused.
To reduce this inefficiency, the equation for Sr[t] was split into chunks.
This step is important because it mathematically transforms a calculation that would otherwise need to happen sequentially into one that can be processed in parallel, allowing multiple chunks to be handled at the same time.
The researchers used the WY representation to pack a sequence of rank-1 updates into a compact form. This avoids costly matrix inversions during computation. In addition, they applied a UT, or Upper Triangular, transform to reduce the number of non-matmul FLOPs.
Kimi Linear Architecture
The Kimi team is also behind Moonlight, which builds on the success of Muon, an optimizer. Besides showing that Muon can scale for large-scale LLM training, Moonlight also serves as the backbone of the Kimi Linear model architecture.
The Kimi Linear architecture combines multiple KDA layers with standard full attention layers in a 3:1 ratio.
Hybridization
You may wonder why Kimi Linear uses a hybrid approach. In other words, why does the architecture combine global attention, or full MLA, with KDA? The reason is the weakness of linear attention in long-context retrieval. Global attention is more computationally expensive and more memory-intensive because it processes all token pairs, which can slow down inference. However, it is better at capturing the complete context and long-range dependencies.
Positional Encodings? NoPE
The standard transformer attention mechanism does not inherently understand the order of input elements. Because of this, explicit positional encodings are usually required to add sequence-order information. RoPE, or Rotary Position Embeddings, is one of the most widely used forms of positional encoding.
With Kimi Linear, the researchers chose not to use positional encodings and instead applied NoPE, which stands for No Position Encoding. NoPE allows these models to be converted into the more computationally efficient pure Multi-Query Attention, or MQA, format during inference. It also simplifies training on long contexts because there is no need to modify RoPE parameters, such as changing the frequency base or applying methods like YaRN.
The Kimi Linear technical report also references several papers that showed the effectiveness of omitting positional encodings with NoPE.
Implementation
Start by preparing a GPU-based cloud server. For this setup, an inference-optimized image is selected. To run this model, use a 4XH100 cluster.
Connect to the server through SSH by using your preferred IDE and the public IPv4 address. In this example, Cursor is used.
ssh root@your_server_ip
further:
apt install python3.10-venv
# Install PyTorch with CUDA 12.1 support, commonly used for H100 systems
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
# Install Hugging Face Transformers, Accelerate, and Kimi dependencies
pip install transformers accelerate bitsandbytes sentencepiece protobuf tiktoken
# Install the Flash Linear Attention core required by Kimi
pip install vllm
pip install -U fla-core
vllm serve moonshotai/Kimi-Linear-48B-A3B-Instruct \
--port 8000 \
--tensor-parallel-size 8 \
--max-model-len 1048576 \
--trust-remote-code
Final Thoughts
Kimi Linear is a hardware-aware architecture. Its central innovation is Kimi Delta Attention, or KDA, which uses fine-grained, channel-wise gating and mathematical changes such as chunking the recurrent update. These improvements support better memory management and stronger Tensor Core utilization. The hybrid architecture, based on a 3:1 ratio of KDA to full attention MLA, is designed to reduce the long-context retrieval weakness often associated with linear attention, while still preserving efficiency. The use of NoPE, or No Position Encoding, also simplifies training and makes the model easier to optimize for efficient Multi-Query Attention inference. As a result, the model achieves a 75% reduction in KV cache usage and up to 6 times higher decoding throughput at a 1 million token context length, helping make large language model deployment more scalable and cost-efficient.


