GLM-5.2: Learned Sparse Attention, the Other Road to Long Context
Two schools for breaking the cost of long context
Facing the exploding cost of attention over long contexts, two strategies compete in 2025-2026. The first compresses the past into a fixed-size memory: that is linear attention (Kimi K3 lesson). The second keeps everything but consults only a selection: that is trainable sparse attention, embodied by DeepSeek and then by GLM-5.2.
Back to the case-file analogy: full attention re-reads the entire file before every sentence; linear attention works from a summary card; sparse attention keeps the whole file at hand but uses an index to open only the right pages.
GLM-5.2 in brief
Zhipu AI / Z.ai (Beijing) released GLM-5.2 on June 13, 2026, under the MIT license (open weights on Hugging Face). The spec sheet:
- Mixture-of-Experts of roughly 750 billion parameters, with ~40 billion active per token;
- one-million-token context, output up to 131,072 tokens;
- tuned for coding, tool use and long-horizon agentic tasks;
- two reasoning modes: "High" (capped thinking budget, fast, default) and "Max" (larger budget for hard problems).
On several coding and agent benchmarks, GLM-5.2 lands within a point or two of the best US models, at a fraction of the price, one of the symbols of the Chinese labs' 2026 catch-up.

Learned sparse attention: the indexer
Unlike a fixed sparse pattern (sliding window, blocks, sparse attention lesson), learned sparse attention lets the model decide for itself where to look. The principle, brought to scale by DeepSeek in late 2025 with its DSA mechanism (DeepSeek Sparse Attention):
- A lightweight component (the indexer (lightning indexer)) quickly scans the whole context and assigns a relevance score to every past token.
- Only the few thousand best-scored tokens (the top-k) are kept.
- The expensive full attention is applied only to that selection.
The cost of the ranking is small (the indexer is tiny compared to the attention layers), and the model keeps exact access to the selected tokens, no compression, no summary.

Computing one index per attention layer is still redundant: neighboring layers often look at the same places. GLM-5.2 introduces IndexShare: a single indexer is shared across several sparse layers. The index is built once and reused several times, amortizing the cost of the selection.

On top of this comes improved multi-token prediction (MTP): the model predicts several tokens ahead to feed speculative decoding, a small predictor proposes, the big model verifies in one pass (~20% higher acceptance rates, hence noticeably faster generation).
Linear vs sparse: the match-up
| Linear attention (Kimi K3) | Sparse attention (DeepSeek, GLM-5.2) | |
|---|---|---|
| Principle | compress the past into a fixed-size state | keep everything, consult only a selection |
| Memory | constant, whatever the context length | the full KV cache stays stored |
| Exact recall | approximate, hence the 3:1 hybrids | exact, on the selected tokens |
| Risk | losing a detail crushed by compression | the indexer missing the right token |
| The bet | "you can summarize without losing (much)" | "you can predict where to look" |
Neither school has won: Moonshot (Kimi) bets on the first, DeepSeek and Zhipu on the second, and recent work explores combinations of the two.
Two developments since this page was written. GLM-5.3 (August 14, 2026) is a post-training pass over the same base, aimed at coding and cybersecurity: Zhipu reports 66.9% on DeepSWE (some twenty points above GLM-5.2) and open weights published about two weeks after launch; a GLM-5.2 Turbo variant followed on August 17. And on August 11, Mistral opened its platform to third-party open models starting with GLM-5.2, served from its European regions with the same guarantees as its own models (see sovereignty at Mistral): a Chinese open-weights model, hosted in Europe, sold by a French lab. The open-weights market is decoupling from the hosting market.
Key takeaways
- GLM-5.2 = ~750 B MoE (40 B active), 1 M context, MIT license, aimed at coding and agents.
- Its answer to long context is learned sparse attention: a light indexer selects which tokens to look at; the expensive attention applies only to them.
- IndexShare shares the indexer across several layers to amortize its cost.
- It is the competing route to linear attention: no compression of the past, but selective consultation, two different bets on the same question.
1. In GLM-5.2's learned sparse attention, what is the indexer's job?
2. Compared with Kimi K3's linear attention, what does GLM-5.2's sparse attention change on the memory side?
3. Why does GLM-5.2 share a single indexer across several layers (IndexShare)?
4. What is the specific risk of each of the two long-context schools?