Text Template Tokens Are Implicit Semantic Registers in Diffusion Transformers

Maohua Li, Qirui Li, Yanke Zhou, Yiduo Li, Zhaosheng Chi, Chao Xu, Cuifeng Shen, Yixuan Xu, Hanlin Tang, Kan Liu, Tao Lan, Lin Qu, Shao-Qun Zhang

Chat-template structural tokens in diffusion transformers act as implicit semantic registers that causally maintain object identity.

How do text-to-image diffusion transformers use chat-template tokens during denoising, and can we use this to interpret or prune the model?

Modern diffusion transformers treat chat-template structural tokens as inert formatting residue, yet these tokens compete for attention in the model's joint-attention stream. The authors show that these tokens function as dominant attention sinks and implicit semantic registers, acquiring object identity indirectly from image latents rather than directly from prompt tokens. This mechanism allows for a training-free pruning rule that removes 20% of attention FLOPs with only a 1.4-point drop in GenEval accuracy.

Paper Primer

In joint-attention diffusion transformers, all conditioning tokens—both the user's prompt and the chat template's structural delimiters—compete as keys for the image stream. The authors demonstrate that while structural tokens carry negligible prompt semantics at the encoder output, they emerge as the primary sites where the model routes and maintains object identity during denoising.

The method uses a causal interpretability framework to trace information flow: it combines token-level attention decomposition, span-level interventions, and cross-trajectory head transplantation. The core move is identifying that semantics are injected from prompt tokens into image latents first, and then read back into the structural "register" tokens, decoupling the tokens that encode the prompt from those that maintain it.

Structural template tokens act as dominant attention sinks and semantic registers.

Across benchmarks, structural tokens absorb 6–7× more attention per token than semantic prompt tokens, and transplanting these "register" heads flips object identity in the generated output. Structural tokens account for up to 78% of all image-to-text attention.

Prompt-reading heads are causally inert for object identity.

Heads that attend most strongly to prompt tokens fail to transfer object identity during head-transplantation experiments, whereas heads that attend to structural registers successfully flip the generated object. Pruning the top 25% of semantic-reading heads removes 20% of attention FLOPs with a minimal 1.4-point accuracy drop.

Why do these structural tokens become registers if they carry no prompt content?

The model learns to route semantics from the image latents into these content-free slots early in the denoising process, effectively using them as stable "registers" to hold object identity throughout the generation trajectory.

Does this register behavior depend on the specific model architecture?

No; the authors observe this sink behavior across multiple architectures, including dual-stream MMDiTs like Qwen-Image, single-stream flow-matching models like Krea-2-Turbo, and large-scale rectified-flow models like FLUX.2.

This paper shifts the understanding of diffusion transformers from "prompt-to-image" conditioning to a "register-mediated" mechanism, where the tokens that define the prompt at input are not the ones that maintain it during generation.

Researchers can now prune diffusion transformers by targeting "semantic-reading" heads that are causally inert, enabling significant compute savings without retraining.

Introduction: The Black Box of DiTs

We expose hidden semantic registers in diffusion transformers and prune redundant heads without retraining.

Modern text‑to‑image diffusion transformers (Diffusion Transformers, DiTs) jointly attend over text and image tokens, yet we lack a mechanistic view of how conditioning information flows during denoising. This gap is especially acute for the chat‑template tokens that appear only as formatting but may become hidden computational registers.

We need a causal lens on diffusion transformers because seemingly inert formatting tokens can silently store and route semantic content, and because heads that merely attend to prompt tokens may be computationally wasteful.

**Figure 1.** Overview of proposed causal interpretability framework.

The need for causal interpretability in large‑scale diffusion models is paramount: it reveals hidden semantic registers and guides training‑free efficiency gains.

Architecture and Attention Dynamics

Defines the MMDiT backbone, token partitions, and joint attention mass used for analysis.

This section grounds the core MMDiT building blocks, the token split used by the chat template, and the attention‑mass metric that underpins the later pruning analysis.

The model stacks transformer blocks that each process image latents and text conditioning together, but keep separate per‑modality parameters while sharing a single joint self‑attention.

How does MMDiT differ from a vanilla transformer that simply concatenates text and image tokens?

In a vanilla transformer the same linear projections are applied to all tokens, so there is no modality‑specific parameterization. MMDiT keeps separate projection matrices for text and image within each block, preserving distinct feature spaces before they meet in the shared attention matrix.

Self‑attention is computed over the full $[c; z]$ sequence, then the resulting matrix is sliced into four quadrants that describe how each modality queries the other.

Why does the paper concentrate on the I2T block rather than the other three quadrants?

The I2T block is the only cross‑modal pathway that lets image latents attend to text keys; the other blocks either stay within a single modality (T2T, I2I) or describe how text queries image keys (T2I), which does not affect the image generation process.

The image shows a curly brace pointing downwards towards the text "dropped prefix".

**Figure 2** Joint attention partition in MMDiT. Rows are queries and columns are keys, yielding T2T, T2I, I2T, and I2I regions over concatenated text and image tokens. We mainly focus on the I2T block to measure the attention mass received by text keys, especially structural chat-template tokens.

Chat-Template Tokens as Semantic Registers

We expose how chat‑template tokens act as implicit semantic registers and enable training‑free head pruning.

We now detail the causal interpretability framework that reveals how the trailing chat‑template tokens become the model’s implicit semantic registers.

We treat the model as a plumbing system: token‑level attention decomposition measures flow through each pipe, span‑level conditioning interventions block or reroute whole sections, cross‑trajectory head transplantation swaps individual valves, and layer‑wise causal masking closes specific junctions to see what downstream water (semantic content) remains.

How does this differ from a standard attention‑heatmap inspection?

A heatmap only shows where attention lands; the framework actively intervenes (swaps, masks, replaces spans) and measures the downstream image change, turning a passive observation into a causal experiment.

Compute I2T mass for each head; the top head assigns $m_R$ = 0.998 to the template span.

Per‑token mass: template tokens receive ≈ 0.20 each, content tokens ≈ 0.018 each → 11× per‑token gap.

Swap the template span with an average template \bar{R} and observe a DINO similarity of 0.93, indicating minimal semantic change.

The example shows that even with a tiny prompt the model’s attention overwhelmingly sinks into the template tokens, yet those tokens contribute little semantic content.

Across the denoising trajectory the model’s image queries pour the vast majority of their attention into the trailing template span, treating it as a massive sink.

Why does a single delimiter token dominate attention instead of the semantic nouns?

Because the delimiter sits at the boundary of the template span, its position aligns with the model’s positional encoding that the attention mechanism has learned to treat as a high‑frequency anchor, making it an easy attractor for query vectors.

The highest‑attention head places 99.8 % of its image‑to‑template mass on the structural span.

Measured on a single‑step run for the prompt “An apple” (both model checkpoints).

Per‑token attention on template tokens exceeds that on content tokens by up to 13 times.

Mean per‑token mass $\bar{m}_R / \bar{m}_S$ = 13× for the minimal prompt; 6–7× for longer prompts.

**Figure 7** Per-span progressive swap. The $(q, k, v)$ of one span—semantic $\mathcal{S}$ (top) or structural $\mathcal{R}$ (bottom)—is copied from $B$ into $A$ over the first $r$ blocks. Swapping $\mathcal{S}$ preserves the apple; swapping $\mathcal{R}$ disrupts it early.

**Figure 3.** 3D surfaces of full query–key attention maps for the prompt “An apple” on Qwen-Image and Qwen-Image-2512. Columns show Top-n heads ranked by $m_{\mathcal{R}}$, the image-to-structural-token attention mass. Attention concentrates as a sharp ridge over the structural span $\mathcal{R}$ while attention among image tokens stays low. The text and image token ranges are displayed with a nonuniform axis scale for readability, and orange markers denote the structural token span $\mathcal{R}$.

We gradually replace the (q, k, v) projections of selected heads in one generation run with those from another run, observing when the generated object identity changes.

Why doesn’t swapping the heads that attend most to the semantic tokens change the object?

Those heads mainly pass the semantic tokens’ signals forward without writing them into the internal registers; the registers are updated by heads that attend elsewhere, so swapping the high‑semantic heads leaves the stored object unchanged.

We block attention from the template registers $R$ to either the semantic span $S$ or the image latents $I$ in a specific block and measure the effect on the generated image.

Why does disabling $Rarrow I$ attention erase the object while disabling $Rarrow S$ does not?

$R$ gathers its content from the image latents; cutting that pathway removes the stored object representation. The semantic span merely provides a cue that the registers ignore.

Pruning the 360 heads with highest $\bar{m}_S$ cuts 20 % of joint‑attention FLOPs while degrading GenEval accuracy by only 1.4 points.

Table 2 shows GenEval = 74.7 (vs 76.1 baseline) after pruning 360 heads (≈ 20 % FLOP reduction).

**Table 2.** Training-free late-step head pruning on Qwen-Image-2512, evaluated on GenEval. $K$ is the number of silenced heads out of 1,440; $K=0$ is the unpruned baseline.

**Table 1.** Attention statistics across prompt benchmarks. $\overline{|S|}$ is the mean number of semantic tokens per prompt. $m_{\mathcal{R}}$ denotes image-to-text attention mass assigned to trailing structural template tokens, and $m_{\mathcal{S}}$ denotes mass assigned to semantic prompt tokens. Bars denote means and tildes denote medians, averaged over prompt-level statistics. $\overline{m_{\mathcal{R}}^{\text{tok}}} / \overline{m_{\mathcal{S}}^{\text{tok}}}$ denotes the average mass per structural token divided by the average mass per semantic token. $\text{Pr}[m_{\mathcal{R}} > m_{\mathcal{S}}]$ is the fraction of step-layer-head sites where structural mass exceeds semantic mass.

**Figure 4** Structural template tokens carry semantics, but only weakly. (a) Cross-prompt swap substitutes another prompt’s template tokens, $[S^A; R^B]$, with little effect on the object. (b) Average on structural tokens replaces $R$ with a single prompt-agnostic average $\bar{R}$, $[S; \bar{R}]$, which can occasionally cause large semantic changes. Increasing the guidance scale (CFG) largely resolves these deviations. (c) Recomputing the average $\bar{R}$ from the same prompts with the “a photo of” prefix stripped leaves the result essentially unchanged from (b).

**Figure 5.** Template tokens act as the implicit semantic registers in the denoising process. (a) Progressive head swap, ordering heads by their semantic-span attention $m_s$. Swapping high-to-low ($m_s\downarrow$, bottom) barely transfers the identity and even collapses to the unconditional portrait; the reverse order ($m_s\uparrow$, top) flips apple to banana after only ~18% of the heads. (b) Progressive attention masking over layers. Blocking $\mathcal{R}arrow\mathcal{S}$ attention leaves the apple largely intact, while blocking $\mathcal{R}arrow\mathcal{I}$ attention quickly erases the object identity.

Together these probes reveal a three‑stage causal flow: early heads commit object identity into the template registers, middle heads carry it forward unchanged, and late heads refine visual details.

Limitations and Pruning Results

Limits of the analysis and directions for extending head‑pruning.

The paper showed that chat‑template tokens act as implicit semantic registers and can be used to prune attention heads without retraining.

A head is removed if its attention mass on the structural token span is low, because those heads contribute little to the image‑generation signal.

How does this pruning differ from standard magnitude‑based weight pruning?

Standard magnitude pruning removes parameters with small absolute values, regardless of their functional role. Training‑free head pruning instead looks at a functional signal—how much a head attends to the structural register—so it discards heads that are behaviorally irrelevant even if their weights are large.

The analysis is purely analytical; the pruning rule is a naive first‑cut that may leave substantial head‑capacity unused.

**Figure.** Qualitative comparison of image generation results across different pruning budgets and control methods. The left section shows results using the proposed ranking method with increasing pruning budgets (K=0 to K=400), while the right section shows control experiments with structured and random pruning at K=288.

Future work could explore sink‑aware sparse attention that retains register positions as keys, and investigate why structural tokens become registers in the first place.

Training‑free head pruning offers a smooth trade‑off: modest budgets preserve object identity while higher budgets mainly affect perceptual fidelity.

Questions & answers

What is the main contribution of this paper?

The paper demonstrates that chat-template structural delimiter tokens in diffusion transformers function as dominant attention sinks and implicit semantic registers, acquiring object identity indirectly from image latents rather than directly from prompt tokens, and leverages this finding to derive a training-free attention-head pruning rule.

What problem does this paper address?

The paper addresses the lack of mechanistic understanding of how conditioning information flows during denoising in text-to-image diffusion transformers, particularly the hidden computational role of chat-template formatting tokens that are typically treated as inert residue.

Why does understanding chat-template tokens matter?

These structural tokens compete for attention in the model's joint-attention stream, and understanding their role reveals both a previously unknown 'register-mediated' conditioning mechanism and practical opportunities for training-free compute savings.

How does the paper's causal interpretability framework work?

The framework combines token-level attention decomposition, span-level interventions (swapping, masking, and replacing token spans), and cross-trajectory head transplantation to trace information flow, turning passive attention observations into causal experiments that measure downstream image changes.

How do structural tokens become semantic registers if they carry no prompt content?

The model learns to route semantics from image latents into these content-free structural slots early in the denoising process, effectively using them as stable registers to hold object identity throughout the generation trajectory rather than reading semantics directly from prompt tokens.

What is the three-stage causal flow the paper identifies?

The paper identifies that early attention heads commit object identity into the template registers, middle heads carry that identity forward unchanged, and late heads refine visual details.

Why do delimiter tokens dominate attention instead of semantic noun tokens?

The delimiter sits at the boundary of the template span, and its position aligns with the model's positional encoding in a way the attention mechanism has learned to treat as a high-frequency anchor, making it an easy attractor for query vectors.

Why does disabling register-to-image (R→I) attention erase the object while disabling register-to-semantic-span (R→S) attention does not?

The register gathers its object representation from image latents via the R→I pathway; cutting that pathway removes the stored object identity, while the semantic span provides only a cue that the registers functionally ignore.

What are the key quantitative results of the pruning method?

The training-free pruning rule removes 20% of attention FLOPs with only a 1.4-point drop in GenEval accuracy.

Does the register behavior depend on a specific model architecture?

No; the paper observes this attention-sink and register behavior across multiple architectures, including dual-stream MMDiTs like Qwen-Image, single-stream flow-matching models like Krea-2-Turbo, and large-scale rectified-flow models like FLUX.2.

How does MMDiT differ from a vanilla transformer for joint text-image processing?

A vanilla transformer applies the same linear projections to all tokens with no modality-specific parameterization, whereas MMDiT keeps separate projection matrices for text and image tokens within each block, preserving distinct feature spaces before they meet in the shared attention matrix.

Why does the paper focus on the image-to-text (I2T) attention block?

The I2T block is the only cross-modal pathway that lets image latents attend to text keys; the other quadrants either stay within a single modality (T2T, I2I) or describe text attending to image keys (T2I), which does not affect the image generation process.

How does this pruning approach differ from standard magnitude-based weight pruning?

Standard magnitude pruning removes parameters with small absolute values regardless of functional role, whereas this training-free head pruning uses a functional signal—how much a head attends to the structural register—discarding heads that are behaviorally irrelevant even if their weights are large.

What are the limitations of the pruning method acknowledged by the paper?

The paper states the analysis is purely analytical and the pruning rule is a naive first-cut that may leave substantial head capacity unused; it does not explore more sophisticated sink-aware sparse attention strategies.

What future directions does the paper suggest?

The paper suggests future work could explore sink-aware sparse attention that retains register positions as keys and investigate why structural tokens become registers in the first place.

How does this paper shift the conceptual understanding of diffusion transformer conditioning?

The paper shifts the understanding from a direct 'prompt-to-image' conditioning model to a 'register-mediated' mechanism, where the tokens that define the prompt at input are not the ones that maintain semantic content during generation.

What benchmark is used to evaluate the pruning results?

The paper uses GenEval accuracy as the evaluation metric for the pruning experiments, reporting a 1.4-point drop when removing 20% of attention FLOPs.

What is the practical implication of this work for model efficiency?

Researchers can prune diffusion transformers by targeting 'semantic-reading' heads that are causally inert with respect to object identity, enabling significant compute savings without any retraining.

Key terms

Diffusion Transformer (DiT)
A class of generative image model that uses a transformer architecture to iteratively denoise latent representations, conditioned on text and other inputs.
MMDiT (Multimodal Diffusion Transformer)
A diffusion transformer variant that maintains separate linear projection matrices for text and image tokens within each block before combining them in a shared attention operation, preserving modality-specific feature spaces.
chat-template tokens
Structural delimiter and formatting tokens added by a chat template around a user's prompt (e.g., special start/end tokens), which carry no semantic content from the user's text.
attention sink
A token position that disproportionately attracts attention mass from many query vectors, acting as a dominant attractor in the attention distribution regardless of its semantic content.
semantic register
A token slot that stores and maintains a stable representation of semantic content (such as object identity) throughout a model's computation, even if that token did not originally encode that content.
I2T block (image-to-text attention block)
The cross-modal attention quadrant in which image latent tokens act as queries and text tokens act as keys and values, allowing image representations to read information from text.
joint-attention stream
The shared attention computation in which both text and image tokens participate together as keys and queries, allowing cross-modal information exchange.
causal interpretability framework
An analysis methodology that uses active interventions—such as swapping, masking, or transplanting token spans or attention heads—to establish cause-and-effect relationships in a model's information flow, rather than passively observing attention weights.
span-level intervention
An interpretability technique that replaces or masks a contiguous group of tokens (a span) in the model's input or activations to measure the causal effect of that span on the model's output.
cross-trajectory head transplantation
An interpretability technique that swaps the activations or outputs of specific attention heads between two different generation runs to test whether those heads causally determine a particular aspect of the output.
training-free pruning
A method for reducing a model's computational cost by removing components (here, attention heads) based on analytical criteria derived from the existing model, without any additional training or fine-tuning.
attention FLOPs
The floating-point operations consumed specifically by the attention computation in a transformer, which scale with the number of active attention heads and sequence length.
GenEval
A benchmark used to evaluate the semantic accuracy of text-to-image generation models, measuring how well generated images match the objects and attributes described in prompts.
dual-stream MMDiT
An MMDiT architecture that processes text and image tokens through separate parallel streams with distinct parameters before combining them, as opposed to a single unified stream.
single-stream flow-matching model
A generative model architecture that processes all tokens (text and image) through a single unified transformer stream using a flow-matching training objective.
rectified flow
A generative modeling framework that trains a model to transport data along straight-line paths between noise and data distributions, used as the training objective in models like FLUX.
attention mass
A metric quantifying the total amount of attention weight directed toward a particular token or set of tokens across queries, used to identify dominant attention sinks.
denoising trajectory
The sequence of iterative steps a diffusion model takes to progressively remove noise from a latent representation and produce a final generated image.

Read the original paper

Open the simplified reader on Paperglide

Browse all simplified papers