Revealing the Attention Floating Mechanism in Masked Diffusion Models

Xin Dai, Pengcheng Huang, Zhenghao Liu, Shuo Wang, Yukun Yan, Chaojun Xiao, Yu Gu, Ge Yu, Maosong Sun · DOI

Abstract

Masked diffusion models (MDMs), which leverage bidirectional attention and a denoising process, are narrowing the performance gap with autoregressive models (ARMs). However, their internal attention mechanisms remain under-explored. This paper investigates the attention behaviors in MDMs, revealing the phenomenon of Attention Floating. Unlike ARMs, where attention converges to a fixed sink, MDMs exhibit dynamic, dispersed attention anchors that shift across denoising steps and layers. Further analysis reveals its Shallow Structure-Aware, Deep Content-Focused attention mechanism: shallow layers utilize floating tokens to build a global structural framework, while deeper layers allocate more capability toward capturing semantic content. Empirically, this distinctive attention pattern provides a mechanistic explanation for the strong in-context learning capabilities of MDMs, allowing them to double the performance compared to ARMs in knowledge-intensive tasks.

Introduction

In the landscape of Large Language Models (LLMs), Autoregressive Models (ARMs) like GPT are the standard, predicting text sequentially from left to right. However, ARMs are prone to "attention sinks," where a disproportionate amount of attention is directed toward initial tokens (e.g., <BOS>). This rigid flow often results in the "lost-in-the-middle" phenomenon, where models struggle to retrieve information placed in the center of long contexts.

Masked Diffusion Models (MDMs) offer a compelling alternative by starting with a fully masked sequence and iteratively "denoising" it using bidirectional attention. While MDMs show competitive performance, the underlying mechanics of their attention remained a "black box." This study aims to elucidate these mechanisms, identifying a novel behavior termed "Attention Floating."

Methods

To analyze MDM behavior, the researchers utilized several diagnostic techniques:

  • Attention Visualization: Mapping attention weight shifts across 32 layers and multiple denoising steps.
  • Geometric Decomposition: Decomposing the $QK^\top$ attention score into vector norms (signal magnitude) and angular alignment (semantic relevance) to distinguish between "loud" tokens and "relevant" ones.
  • Retrieval Head Analysis: Identifying specific transformer heads dedicated to "needle-in-the-haystack" information retrieval.
  • Region-Level Attention Flow: Aggregating scores to track information movement between the Query, Evidence Documents, and the generated Answer.

Datasets

The study evaluated MDMs (specifically Llada and Dream) against benchmarks including:

  • Open-Domain QA: Natural Questions (NQ), TriviaQA, and MS MARCO QA.
  • Multi-hop QA: HotpotQA.
  • Slot Filling: T-REx.
  • Reasoning: GSM8K and 2WikiMQA.

The Attention Floating Mechanism

The core discovery is the contrast between the "Attention Sink" in ARMs and "Attention Floating" in MDMs. In ARMs, attention remains anchored to fixed initial tokens. In MDMs, attention anchors are dynamic, shifting across different tokens depending on the layer and denoising step.

Comparison between Attention Sinks in ARMs and Attention Floating in MDMs.

Shallow-to-Deep Transition

The model exhibits a distinct functional transition across its depth:

  1. Shallow Layers (Structure-Aware): Early layers focus on "floating tokens" such as punctuation, newlines, and mask tokens. These act as structural controllers, establishing the global layout and sequence boundaries.
  2. Deep Layers (Content-Focused): As denoising progresses and layers deepen, attention shifts from structural anchors to semantic content, focusing on the specific facts required to generate the answer.
Attention floating patterns in shallow (Layer 0) vs. deep (Layer 31) layers.

Key Results

  • Superior RAG Performance: MDMs excel in Retrieval-Augmented Generation. The Llada model achieved a +25.68 point gain with RAG, significantly outperforming the +7.37 point gain of the autoregressive Llama.
  • Robustness to Noise: MDMs are more resilient to distractor documents, maintaining performance even as irrelevant information is added to the prompt.
  • Mitigating "Lost-in-the-Middle": Unlike the U-shaped performance curve of ARMs, MDMs maintain stable performance regardless of where key information is positioned within the context.

Limitations and Future Work

This study focuses on Masked Diffusion; future research should investigate if these patterns hold across other diffusion variants. Additionally, while this work provides a mechanistic understanding, future efforts could translate these insights into more efficient training objectives or inference techniques that explicitly leverage floating signals to reduce the computational cost of multi-step denoising.

Summary updated

BibTeX
@misc{dai2026revealing,
  author = {Xin Dai and Pengcheng Huang and Zhenghao Liu and Shuo Wang and Yukun Yan and Chaojun Xiao and Yu Gu and Ge Yu and Maosong Sun},
  title = {{Revealing the Attention Floating Mechanism in Masked Diffusion Models}},
  year = {2026},
  eprint = {2601.07894},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2601.07894},
}
Figure