Songlin Yang Explains Attention Mechanisms from DeepSeek, Kimi, and MiniMax

ORIGINAL TITLE松琳解读 DeepSeek、Kimi 与 MiniMax 的注意力机制

From dynamic sparse attention to linear hybrid architectures, explore how long-context models trade off quality, memory access, and hardware efficiency.

SYSonglin Yang(松琳)Guest · MIT CSAIL
Channel
Zhang Xiaojun Podcast
Published
Feb 23, 2025
Video
2:36:13
Read
8 min
Slides
5
Original
Simplified Chinese
Open on YouTube
Scroll to read and the video shrinks to the bottom-right corner. Captions follow your reading language.
Reading languageAvailable in 2 languages
Machine-translated from the original Simplified Chinese. Turn on “Show original” to compare paragraph by paragraph.
SUMMARY

In 30 seconds

In February 2025, Zhang Xiaojun invites MIT CSAIL doctoral student Songlin Yang to explain DeepSeek’s Native Sparse Attention, Kimi’s MoBA, and MiniMax-01. The first two dynamically select attention blocks; the third combines linear and softmax attention. Yang moves from queries, keys, values, and grouped-query attention to GPU memory, tiled kernels, and recurrent states. He compares each paper’s design philosophy, experiments, and limitations. Because training conditions differ, cross-model comparisons require care.

  1. 1Two approachesDeepSeek and Kimi study dynamic sparse attention, while MiniMax mixes linear and softmax attention.
  2. 2NSA’s three branchesCompression, block selection, and sliding windows supply coarse, fine, and local information.
  3. 3Sharing and readsShared KV block selection within a group can reduce memory reads while limiting selection freedom.
  4. 4MoBA’s simple designMean pooling and block selection reduce additional structure, but reordering and training signals have costs.
  5. 5Linear attention stateHistorical key-value information can accumulate into a fixed-size matrix state for future queries.
  6. 6Comparisons need matched conditionsDifferences in data, scale, and implementation prevent a comprehensive ranking from published results alone.

Takeaways

  1. Dynamic sparse attention selects historical blocks based on each query, reducing unnecessary attention computation.
  2. NSA combines compression, block selection, and sliding windows, optimized for shared KV and hardware execution.
  3. MoBA’s simple block selection trades off indexing costs, block granularity, and training signals.
  4. Linear attention can use a fixed-size recurrent state, though retrieval may be limited.
  5. Hybrid architectures combine linear and softmax attention to balance costs and retrieval.
  6. Beyond theoretical complexity, memory access, matrix multiplication, and implementation determine actual speed.
FULL TEXT

Read the edited text by chapter

Transcript only
01

Long context and attention basics

Yang introduces the papers and self-attention costs, distinguishing dynamic sparse from linear attention.

Zhang Xiaojun invites MIT CSAIL doctoral student Songlin Yang to explain attention papers from DeepSeek, Kimi, and MiniMax. Yang studies hardware-efficient sequence modeling, especially linear attention.

Long chains of thought can increase computation at inference, but ordinary self-attention has quadratic sequence-computation costs and a KV cache that grows with length. The three papers approach these costs differently.

DeepSeek and Kimi use dynamic sparse attention: different queries can select different key-value blocks instead of following a predetermined sparse pattern. MiniMax combines linear attention with softmax attention.

Yang first explains attention: each token produces a query, key, and value. A query scores accessible keys, applies softmax, and uses the resulting weights to combine values. An autoregressive model masks future tokens.

He says both prefill for long inputs and token-by-token decoding need optimization. Long-document processing makes prefill especially relevant for Kimi, while long reasoning processes also make decoding efficiency important.

02

Three branches of DeepSeek NSA

He explains compression, selection, sliding windows, and gating, then compares how attention heads share KV.

DeepSeek’s Native Sparse Attention (NSA) aims to make dynamic sparse attention efficient to pretrain and compatible with hardware and inference architectures. Yang highlights training from scratch as a key difference from changing attention only at inference.

Yang introduces query-aware selection of key-value blocks: instead of every position reading the entire history, the current query selects blocks likely to be useful. Actual speed also depends on block organization and memory access.

NSA has three branches: coarse attention over compressed blocks, fine attention over selected blocks, and a sliding window over nearby tokens. Learned gates determine how each branch contributes to the output.

NSA’s three attention branches
SLIDE 1 / 5NSA’s three attention branchesThe paper’s diagram shows compression, selection, and sliding-window branches and their gated output.

The compression branch represents each block and scores its relevance to the query. The selection branch then attends more finely to high-scoring blocks, preserving a global overview without fine-grained computation over every token.

The sliding-window branch uses the observation that nearby tokens are often important in language. Asked how the branches balance global and local information, Yang says the model learns the gate weights rather than using fixed human-assigned proportions.

He emphasizes that compression, block selection, and sliding windows are not all new ideas. The paper’s contribution lies in combining and implementing them to use hardware effectively during training and inference.

To explain grouped-query attention (GQA), Yang compares multi-head and multi-query attention. Multi-query attention shares keys and values across query heads to shrink the inference KV cache; GQA sits between fully separate and fully shared representations.

In GQA, if heads in a group select different KV blocks, the system must read the union of their selections. Sharing a selection within the group can reduce reads, but limits each head’s freedom to choose independently.

NSA aggregates attention scores within a group and selects shared blocks. Yang sees this as a deliberate tradeoff: fewer memory accesses improve hardware efficiency, while architectural choices seek to preserve sufficient expressive power.

03

Hardware, memory, and training results

From FlashAttention tiling to NSA’s matrix operations, he discusses hardware efficiency and the reported experiments.

He reviews FlashAttention’s tiled computation: load portions of queries, keys, and values into fast memory and compute within blocks, reducing transfers of intermediates to and from GPU memory. Data movement can bottleneck speed alongside arithmetic.

Dynamic sparsity introduces a problem: different positions in a query block may need different KV blocks. Simply retaining contiguous tiling can require reading their union, wasting bandwidth. Sparsity does not automatically mean faster hardware execution.

NSA packs multiple query heads sharing KV into matrix operations, reducing unnecessary reads while using GPU Tensor Cores. Yang uses this to show why an algorithm’s expression and its hardware execution must be considered together.

Matrix multiplication also has size constraints. To satisfy hardware requirements while retaining selection diversity across groups, the paper increases the number of heads and expands the projection. Yang calls this a bold but purposeful architectural choice.

In the paper’s reported training loss and several evaluations, NSA performs well against its full-attention baseline and is better on some measures. Yang finds this compelling, but the results are comparisons under the paper’s experimental conditions.

He distinguishes two approaches: approximating attention at inference after training a full-attention model can introduce error, while pretraining a sparse architecture lets the model adapt to it. Whether it is better still requires validation across settings.

NSA long-context evaluations
SLIDE 2 / 5NSA long-context evaluationsThe paper’s table compares NSA and several baselines across LongBench tasks.

He also compares retaining the entire KV cache with evicting cache entries: discarded information might be needed later. NSA dynamically selects blocks to read, which is different from permanently deleting unselected history.

The paper’s performance plot compares kernels with similar implementation approaches. Yang points to speedups on long sequences and emphasizes that decoding may be memory-bandwidth-bound; actual gains depend on hardware, length, and implementation.

In the ablation discussion, the compression branch supplies coarse information and also provides a training signal for block selection. Yang considers this useful for end-to-end training; looking only at computation on selected blocks misses part of the design.

Yang describes the contribution mainly as engineering and hardware-software co-design: existing ideas are adapted to shared KV, tiled reads, and matrix multiplication. He particularly admires the kernel design.

Zhang asks why he calls it a “brutal hardware aesthetic.” Yang says shared selections, more heads, and multiple branches fit together to balance speed and model quality under hardware constraints.

04

Tradeoffs in Kimi’s MoBA

MoBA uses simple block selection; Yang examines reordering overhead, granularity, and fine-tuning signals.

The second paper is Kimi’s MoBA. Yang says it also selects blocks based on queries and supports pretraining, but uses a simpler design: mean pooling represents blocks, followed mainly by attention over selected blocks.

MoBA omits NSA’s compression-output and sliding-window-output branches, and different attention heads can select their own KV blocks. Yang says this brings simplicity and flexibility, but different implementation costs from NSA.

To reuse FlashAttention, MoBA must gather queries selecting the same KV block into contiguous tensors. Indexing and reordering have costs of their own, which can become significant when blocks are too small.

Comparing the papers’ block-size choices, he notes that larger blocks can reduce reordering overhead but make selection coarser. Smaller blocks can be more flexible while increasing scheduling and memory-operation costs.

MoBA encounters sparse training signals during supervised fine-tuning: when loss applies mainly to the answer, unselected prefix blocks may receive insufficient gradients. The paper mitigates this by using full attention in the final layers.

Because MoBA’s block selection adds no extra parameters, it can switch relatively easily between sparse and full attention. Yang corrects his initial reading: the mixed-training example is an ablation in the paper.

The Kimi paper also evaluates longer contexts and discusses practical use. Yang frames the designs as different priorities: NSA stresses hardware-software alignment, while MoBA favors simplicity. A universal winner, he says, should not be assumed.

Both approaches seek faster training and inference, but benefits differ by sequence length and implementation. Yang notes that contiguous block reads and matrix operations are common hardware principles; theoretical complexity alone is insufficient.

05

MiniMax’s hybrid architecture

He explains matrix states, recurrent formulations, and chunkwise parallel training for linear attention.

The third paper is MiniMax-01. Its hybrid architecture places one softmax-attention layer after every seven Lightning Attention layers, repeating the pattern across 80 layers. Linear attention is Yang’s main research area.

MiniMax-Text-01 hybrid architecture
SLIDE 3 / 5MiniMax-Text-01 hybrid architectureThe architecture diagram combines linear attention, softmax attention, and expert modules.

To explain linear attention, he starts with a simplified form without softmax. Associativity lets the outer products of past keys and values accumulate into a matrix state, which the current query then reads.

A matrix state for linear attention
SLIDE 4 / 5A matrix state for linear attentionThe speaker’s slide uses associativity to show how historical key-value information accumulates in a matrix state.

This state can be written as the hidden state of a recurrent neural network: each step incorporates new key-value information into a fixed-size matrix. Unlike a KV cache that retains the full history, the past is compressed into the state.

Yang compares matrix states with traditional vector states in terms of memory capacity and notes that expanding state must also be hardware-efficient. Linear theoretical complexity does not guarantee efficient GPU utilization during training.

Computing token by token limits parallelism and makes efficient matrix multiplication difficult, while computing over the whole sequence can incur quadratic cost. A chunkwise form seeks the benefits of both.

The chunkwise algorithm divides the sequence into chunks: historical information passes through states between chunks while local contributions are computed in parallel. Yang stresses that this reformulation is mathematically equivalent, not necessarily a lossy approximation.

Within each chunk, multiple token updates can be packed into matrix multiplication, and queries can batch their reads of the prior state. This makes linear attention easier to map onto current GPU compute units.

Chunkwise state updates
SLIDE 5 / 5Chunkwise state updatesThe slide shows matrix operations within chunks and state passing between them.

With fixed chunk size, Yang says, this training approach avoids constructing quadratic interactions across the whole sequence. He mentions long video sequences as a possible application, with actual results dependent on the task and implementation.

He introduces the open-source Flash Linear Attention library, which implements several hardware-efficient linear-attention models. Beyond chunk computation, input/output and memory access also require optimization.

06

Linear attention and retrieval

Yang compares decay, recurrent models, and full attention, and analyzes hybrid architectures and engineering scale.

Early linear attention was often questioned for its language-modeling performance. Yang says decay and gating have improved it, and compares Lightning Attention’s fixed decay with data-dependent decay.

He explains Mamba-2 through a linear-attention lens, connecting seemingly different recurrent, parallel, and chunkwise expressions. The models nevertheless retain their own parameterizations and design choices.

Hybrid architectures seek to combine two strengths: a fixed-size recurrent state compresses history, while full attention retains a KV cache that can retrieve details on demand. Yang likens the latter to consulting a book when needed.

Pure recurrent or linear attention can be constrained by fixed state capacity on exact retrieval tasks. Adding some softmax-attention layers may compensate; he also discusses how recurrence can provide position-related information.

MiniMax’s hybrid model still has some full-attention layers, so long-sequence costs do not disappear entirely, but the many linear layers can reduce them. Yang sees the paper as evidence that the hybrid approach can scale to a large model.

He credits chunkwise algorithms, expert parallelism, pipelines, and other engineering optimizations with enabling scale. Earlier smaller hybrid models provided precedents; one contribution of MiniMax was extending the approach to a larger scale.

Asked which approach takes greater architectural risk, Yang says dynamic sparsity that retains the KV cache can feel more familiar, while scaling a linear/full-attention hybrid still faces retrieval concerns despite prior examples.

07

Comparisons, open research, and the future

He emphasizes limits to cross-model comparison and shares views on publishing, architectural innovation, and research directions.

He cautions that models differ in training data, scale, and experimental conditions, making it hard to rank architectures solely from published results. Fairer conclusions require broader comparisons under matched conditions.

On companies publishing papers and opening technology, Yang says this can build technical influence and help challengers create communities. His views about specific commercial benefits are personal assessments.

Of the three papers, he favors NSA: it enables efficient training of dynamic sparse attention and shows competitive results in the paper’s comparisons. Kimi’s minimalist design also impresses him.

Looking ahead in architecture research, he mentions positional encoding, sparse attention, linear attention, and long convolutions. Research topics can rise and fall, so they need continuing experimental evaluation rather than judgments based on a moment’s popularity.

Finally, Yang thinks technical progress by Chinese teams could make them more attractive to researchers overseas. Zhang closes by inviting listeners to continue the discussion.

More from this channel

1:59:52EN
Zhang Xiaojun Podcast· Oct 21, 2026Podcast · 2 speakersDavid Qian on Succession, Robotics, and Finding His Own AmbitionGuest David Qian (Qian Cheng) · Host 张小珺Ecovacs CEO David Qian reflects on inheriting a founder-built company, learning to lead through mistakes, and choosing a patient path in robotics. His account treats succession as an ongoing effort to build the company for a new era, not a finish line.Enterprise & strategyLeadershipCompany Building+2
2:51:18EN
Zhang Xiaojun Podcast· Oct 15, 2026Podcast · 2 speakersLindon Gao on Building Dyna Robotics and Finding a Path Through the FogGuest Lindon Gao · Host 张小珺Dyna Robotics CEO Lindon Gao explains why his company builds intelligence through real workflows, how hardware and research must evolve together, and how a founder can find clarity by letting go of the need to be right.RoboticsProduct StrategyModels & training+2
2:51:18ZH → English
Zhang Xiaojun Podcast· Oct 15, 2026Podcast · 2 speakersDyna Robotics Founder Lindon Gao on Moving From Robot Tasks to WorkflowsGuest Lindon Gao · Host 张小珺From cashierless retail to robotics, Gao discusses product research, deployment challenges and finding a direction in uncertainty.RoboticsCompany BuildingFounders+2
2:34:18EN
Zhang Xiaojun Podcast· Sep 3, 2026Podcast · 2 speakersZeng Ming on AI’s New Era: Why Great Companies and New Organizations EmergeGuest Zeng Ming · Host 张小珺Zeng Ming argues that AI is changing the foundations of business: models will become infrastructure, while new Agent-native applications and organizations create the next wave of value. His advice to founders is to embrace uncertainty, rethink strategy continuously, and build around meaningful work rather than inherited structures.AI StrategyEnterprise & strategyAgents+2
2:34:18ZH → English
Zhang Xiaojun Podcast· Sep 3, 2026Podcast · 2 speakersMing Zeng on AI’s Three Stages of Industrialization and the Decline of the Corporate FormGuest 曾鸣 · Host 张小珺Strategist Ming Zeng draws on the histories of the internet, the Industrial Revolution and electrification to argue that AI is moving from infrastructure to agent applications and eventually to native applications. He believes the old corporate hierarchy will struggle to survive a paradigm shift; next-generation organizations will be rebuilt around tasks, creativity and human–AI collaboration.AI StrategyStrategyAgents+2
1:09:50ZH → English
Zhang Xiaojun Podcast· Aug 19, 2026Podcast · 2 speakersJonathan Su on AI Research, Education and Happiness as a High-School StudentGuest 苏庭灏 · Host 张小珺From learning Transformers and publishing a paper to thinking about motivation, uncertainty and human connection.AI researchEducationMachine Learning+2