News › #llm

Ling-3.1-flash: an open 560B model that uses linear attention in 63 of 72 layers

5 min readVerified

InclusionAI released MIT-licensed weights for Ling-3.1-flash, a mixture-of-experts model that mixes Kimi Delta Attention (a linear attention with a fixed-size state) and full attention in a 7:1 ratio. We explain the delta-rule update, what it saves in memory, and what is still unpublished.

In short

Ant Group's InclusionAI team has published open weights for Ling-3.1-flash, a mixture-of-experts language model with about 560 billion total parameters, under the MIT license. Its main design idea is a hybrid attention stack: 63 of its 72 attention layers use Kimi Delta Attention (KDA), a form of linear attention with a fixed-size memory, and only 9 layers use full attention (gated Multi-Head Latent Attention, MLA). This matters because the memory that a model needs per conversation is now one of the main costs of serving long contexts, and a 7:1 hybrid is a large step away from the standard Transformer.

How it works

A normal attention layer keeps every past token's key and value in a cache (the KV cache). Each new token compares itself with all of them. The cache grows with every token, so a 1-million-token context needs a very large amount of GPU memory.

A linear-attention layer replaces this growing cache with a fixed-size state matrix per head. Each new token writes into the matrix, and each query reads from it. Analogy: full attention keeps every page of a notebook; linear attention keeps one whiteboard of fixed size that is updated after each token.

The weakness of simple linear attention is that it only adds to the whiteboard and never corrects it, so old and new facts blur together. KDA uses the delta rule: before writing a new value for a key, it first removes what the state currently returns for that key. It also has a learned forget gate for every channel, so the model can decide which parts of the state to keep and which to fade.

Ling-3.1-flash places one full-attention (MLA) layer after every seven KDA layers. The few full-attention layers keep exact access to every past token, which linear layers cannot guarantee.

Under the hood

KDA update (from the Kimi Linear paper). For each head, with key k_t, value v_t, query q_t, a per-channel decay vector α_t and a write strength β_t:

S_t = (I − β_t k_t k_tᵀ) · Diag(α_t) · S_{t−1} + β_t k_t v_tᵀ      S_t ∈ ℝ^{d_k × d_v}
o_t = S_tᵀ q_t
  • The term (I − β_t k_t k_tᵀ) erases the old association for key k_t before the new one is added. With β_t = 1 and unit-length keys, this is an exact overwrite.
  • Diag(α_t) is the difference from Gated DeltaNet, which uses a single scalar decay per head. KDA decays each key channel separately.
  • The state has d_k × d_v entries per head, independent of sequence length. Training uses a chunk-wise parallel form of this recurrence, not a token-by-token loop.

Published configuration (Hugging Face model card).

Property Value
Total parameters about 560B (the safetensors metadata lists 572B)
Active parameters per token 25B per the model card; the SGLang cookbook states about 17B
Layers 72 attention layers: 63 KDA + 9 gated MLA (7:1); 4 dense FFN layers
Experts 512 routed + 1 shared, 8 routed active per token
Hidden size / heads 4096 / 64
Vocabulary 157,184 tokens
Context 1M tokens per the model card; the SGLang cookbook lists 262,144 native and 1,048,576 with a YaRN override
Weights FP8 (E4M3, 128×128 blocks), MIT license

The two official sources disagree on active parameters and native context length. We report both values until the developers clarify.

Memory trade-off. Only 9 of 72 layers keep a growing KV cache. If each MLA layer cached as much per token as it would in an all-MLA model, the growing part of the cache would be 1/8 of an all-MLA model of the same depth. This is our own arithmetic, not a published measurement. For comparison, the Kimi Linear paper used a 3:1 ratio and reported up to 75% less KV cache and up to 6× higher decoding throughput at 1M context, for a smaller 48B model.

Serving numbers (SGLang cookbook, vendor-run). On 8× H200 with tensor parallelism and multi-token-prediction speculative decoding, batch-size-1 decoding reached 269.2 tokens/s. A 300,101-token prompt had a time-to-first-token of 15.4 s on H200 and 12.6 s on GB300.

Benchmarks. The model card lists, among others, SWE-bench Pro 68.74 and Terminal-Bench 4 46.03. These are self-reported, and the card does not explain the asterisks next to some values. No independent reproduction was available when this was written.

Limits and unknowns. There is no technical report or arXiv paper yet. The exact gate parameterization, the head dimensions of the KDA state, and training data size are not published. Linear-attention layers compress history, so exact recall of long passages depends on the 9 full-attention layers; how well this holds at 1M tokens has not been independently tested.

Try it yourself

1. See the delta rule work (CPU only, Python 3.13, NumPy 2.5). This toy stores 32 key/value pairs in one KDA state, then overwrites one key. Plain linear attention cannot overwrite; it only adds.

import numpy as np

d_k, d_v = 64, 64
rng = np.random.default_rng(0)
K = np.linalg.qr(rng.standard_normal((d_k, d_k)))[0].T   # 64 orthonormal unit keys
V = rng.standard_normal((d_k, d_v))

def kda_step(S, k, v, alpha, beta):
    S = alpha[:, None] * S                                # Diag(alpha) S
    return S - beta * np.outer(k, k @ S) + beta * np.outer(k, v)

def linear_step(S, k, v):
    return S + np.outer(k, v)

S_kda = np.zeros((d_k, d_v)); S_lin = np.zeros((d_k, d_v))
alpha = np.ones(d_k)
for i in range(32):
    S_kda = kda_step(S_kda, K[i], V[i], alpha, 1.0)
    S_lin = linear_step(S_lin, K[i], V[i])

v_new = rng.standard_normal(d_v)                          # overwrite key 0
S_kda = kda_step(S_kda, K[0], v_new, alpha, 1.0)
S_lin = linear_step(S_lin, K[0], v_new)

read = lambda S, q: S.T @ q
print("state entries:", S_kda.size)
print("KDA    error key 0:", round(float(np.linalg.norm(read(S_kda, K[0]) - v_new)), 4))
print("Linear error key 0:", round(float(np.linalg.norm(read(S_lin, K[0]) - v_new)), 4))
print("KDA    error key 5:", round(float(np.linalg.norm(read(S_kda, K[5]) - V[5])), 4))

Expected output:

state entries: 4096
KDA    error key 0: 0.0
Linear error key 0: 7.8593
KDA    error key 5: 0.0

Then try: set some entries of alpha below 1 and watch the stored values in those channels fade; or use random, non-orthogonal keys and store more than 64 pairs to see interference grow once the state is full.

2. Run the real model (needs a multi-GPU server). The SGLang cookbook gives a Docker image lmsysorg/sglang:dev-ling-3.1-flash and recommends tensor parallelism 8 on H200-class nodes (or 4 on GB300). A useful experiment: send prompts of 32K, 128K and 256K tokens and record GPU memory per request; with a 7:1 hybrid the growth per extra token should be much smaller than for a pure-attention model of similar size. We have not run this ourselves.

Sources

  1. Ling-3.1-flash model card (Hugging Face, inclusionAI)
  2. SGLang cookbook: Ling-3.1-flash
  3. Kimi Linear: An Expressive, Efficient Attention Architecture (arXiv:2510.26692)
  4. AlphaSignal: Ant Group's Ling-3.1-flash (secondary report)