Kimi Linear is a hybrid linear attention architecture from Moonshot AI, introduced in
KimiLinear
This model was published in HF papers on 2025-10-30 and contributed to Hugging Face Transformers on 2026-09-04.
Overview
Kimi Linear is a hybrid linear attention architecture from Moonshot AI, introduced in Kimi Linear: An Expressive, Efficient Attention Architecture.
At its core is Kimi Delta Attention (KDA), a refinement of Gated DeltaNet that gives each key channel its own forget gate, so the recurrent state decays per channel instead of per head. KDA is used in most layers; every fourth layer keeps a full-attention block that reuses DeepSeek-V3's Multi-head Latent Attention (MLA), and the feed-forward blocks are DeepSeek-V3-style MoE with a shared expert.
The abstract from the paper is the following:
We introduce Kimi Linear, a hybrid linear attention architecture that, for the first time, outperforms full attention under fair comparisons across various scenarios -- including short-context, long-context, and reinforcement learning (RL) scaling regimes. At its core lies Kimi Delta Attention (KDA), an expressive linear attention module that extends Gated DeltaNet with a finer-grained gating mechanism.
Two things are worth knowing when reading the modeling code:
- The model is NoPE. Every released checkpoint sets
mla_use_nope=True, so no rotary embedding is applied anywhere: the KDA layers encode position through their recurrence, and the full-attention layers are left without positional encoding. Theqk_rope_head_dimslice still exists in the projections, it is simply never rotated. - The layer pattern comes from the checkpoint.
linear_attn_configlistskda_layers/full_attn_layerswith 1-based indices; the config converts them into the standardlayer_typeslist.
This model was contributed by Remi Ouazan. The original code can be found here.
Usage examples
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "moonshotai/Kimi-Linear-48B-A3B-Instruct"
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_name)
messages = [{"role": "user", "content": "Tell me about the french revolution."}]
model_inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
generated_ids = model.generate(**model_inputs, max_new_tokens=128)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]) :]
print(tokenizer.decode(output_ids, skip_special_tokens=True))
The KDA layers run on a pure PyTorch implementation by default. Installing
kernels (pip install -U kernels) and passing use_kernels=True
in from_pretrained makes them dispatch to custom kernels instead, which is considerably faster for long sequences.
Notes
- Use left padding for batched generation. See Padding side.
KimiLinearConfig
[[autodoc]] KimiLinearConfig
KimiLinearModel
[[autodoc]] KimiLinearModel - forward
KimiLinearForCausalLM
[[autodoc]] KimiLinearForCausalLM - forward
Source and license
Source: Transformers documentation, adapted for this site. Licensing and attribution follow the terms of the upstream project.