← 返回 2026-07-22

文本模板Token是扩散Transformer中的隐式语义寄存器 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 📅 2026-07-21 👍 73 2026-07-27 18:30
可解释性 扩散模型 文本到图像生成 模型加速 注意力机制

Chat模板token是DiT的隐式语义寄存器:语义走S→I→R间接回路,据此剪枝省20%注意力算力

前置知识

扩散Transformer(DiT)与联合注意力

DiT 是当前主流文生图模型的骨干网络,用 Transformer 替代 U-Net 迭代去噪潜变量。MMDiT(如 Qwen-Image)采用双流设计:文本与图像 token 在每个 block 内用各自独立的参数处理,但拼接成单一序列做 self-attention,即联合注意力(joint attention)。这与早期 U-Net 时代的 cross-attention 不同——文本不再是旁路信息,而是与图像 token 在同一个注意力计算里直接竞争与交互。把联合注意力矩阵按行(query)列(key)的文本/图像分段切分,可得到 T2T、T2I、I2T、I2I 四个子块。

全文的分析对象就是联合注意力中的 I2T 子块(图像 query 对文本 key 的注意力),所有注意力质量统计、masking 实验都建立在这个分解上。

Chat模板与LLM文本编码器

新一代文生图系统(Qwen-Image 用 Qwen2.5-VL-7B,FLUX.2 用 Mistral-3-24B)不再用 CLIP/T5 编码 prompt,而是把用户 prompt 包进对话模板后交给视觉语言模型:$c_{raw} = [r_{prefix};\ p;\ r_{suffix}]$,其中 $r_{prefix}$ 是系统消息和用户角色标记,$r_{suffix}$ 是 <|im_end|>、assistant 标记等结尾符。丢弃固定模板前缀后,保留的条件序列分成两段:语义 span $S$(prompt 内容词)与模板 span $R$(无内容的结构性对话 token)。

模板 token $R$ 正是论文的主角。没有这个背景就无法理解为什么条件序列里会存在一批'不该有语义'的 token,以及它们的角色为何令人意外。

注意力汇聚(Attention Sink)

在自回归 LLM 中发现的现象:某些几乎不承载语义内容的位置(典型是序列开头的 token)吸收与其信息量完全不成比例的巨大注意力质量,充当稳定的注意力锚点,使流式推理的 KV cache 得以稳定。研究表明 sink 在预训练中涌现而非初始化即有,并与 massive activation 等现象相关。多模态模型与扩散语言模型中也有类似的内容无关注意力集中现象。

论文发现 DiT 中模板 token 是支配性 sink,并进一步证明这种 sink 不是待消除的伪影,而是有功能语义角色的寄存器——这是对 attention sink 研究纲领的重要扩展。

Flow matching与去噪轨迹

流匹配是扩散模型的现代训练目标:给定带噪潜变量 $z$ 和时间步 $t \in [0,1]$,网络 $f_\theta(z,t,c)$ 预测速度场,采样器从纯噪声出发沿预测的速度场积分到干净潜变量,再经 VAE 解码成像素。'去噪轨迹'指从 $t=1$(纯噪声)到 $t=0$(干净图)的多步迭代过程,少步蒸馏模型把这个过程压缩到 2 步。

论文需要沿去噪轨迹聚合注意力统计(block×head×timestep),剪枝规则也特意只作用于后 80% 的去噪步,因为早期步负责提交物体身份。

因果干预与激活修补

可解释性的核心方法论:注意力权重只能显示相关性,要建立'某组件承载某信息'的因果结论,必须主动干预模型内部——替换另一条推理轨迹中对应组件的激活(activation patching / head transplantation)、在 softmax 前屏蔽某段注意力(causal masking)、或用统计均值替换某段表示,然后观察输出如何变化。因果效应的大小即组件功能的证据。

本文框架的三大工具——跨 prompt 模板交换、跨轨迹渐进头移植、逐层注意力 masking——全部是因果干预,论文所有关键结论都靠它们而非单纯看注意力图。

Classifier-Free Guidance(CFG)

采样时同时做条件预测和无条件预测,并沿两者之差外推放大:$\epsilon = \epsilon_u + s(\epsilon_c - \epsilon_u)$,引导尺度 $s$ 权衡文本依从性与生成多样性。$s=1$ 等价于纯条件采样,$s=4$ 是常用的强引导设置。

4.2 节用 CFG=1 与 CFG=4 的对比来分离模板 token 中残留的微弱语义:低引导下微弱语义不足以断言目标物体时,生成会塌缩到模型的无条件默认(普通人像),高引导则能恢复。

Register token(寄存器token)

人为加入的、不携带内容信息的空白 token,作为注意力与计算的缓冲区。在视觉 Transformer 中 register token 吸收高范数伪影,让注意力图和特征图更干净;在 LLM 中专用 sink token 集中弥散的 sink 行为、稳定流式推理。传统观点把寄存器视为被动的计算缓冲,不参与语义条件化。

论文证明 chat 模板 token 无需人工添加就自发成为'隐式'寄存器,而且主动参与语义的维护与传递——这超出了传统寄存器观,是本文对 register 概念的重新定义。

研究动机

现代文生图模型如何把文本信息真正'放进'生成过程?最自然的图景是逐层直接注入:在每一层去噪中,图像 token 都去 attend 那些显式编码了所求内容的 prompt token,语义全程锚定在文本源头。这个图景从未被因果验证。更关键的是,最新系统让问题变得复杂了:Qwen-Image、Qwen-Image-2512 等模型用 VLM(Qwen2.5-VL)按 chat 模板编码 prompt,进入 DiT 的条件序列既包含语义 prompt token $S$,也包含一批无任何 prompt 内容的结构性模板 token $R$(如 <|im_end|>、<|im_start|>assistant;FLUX.2 中保留的模板 token 多达 33 个)。每个条件 token 都能与图像 token 直接交互,到底哪些 token 在生成过程中承载和维护语义完全不清楚;随着 prompt 变长(DPG-Bench 平均 82.1 个内容词),少量固定的模板 token 与数量可变的语义 token 在注意力中如何分配也无人量化。如果'逐层直读 prompt'这个默认假设是错的,那么模型加速、语义编辑、蒸馏等下游设计都可能建立在错误的机制图景上。

本文的目标是本文的目标是建立一套面向大规模文生图 DiT 的因果可解释性框架,并系统回答五个递进的问题:(1) 描述性层面——沿整条去噪轨迹,图像流的文本注意力究竟落在哪些条件 token 上,模板 token 与语义 token 的注意力分配比例是多少;(2) 语义含量层面——模板 token 的编码器输出中是否携带 prompt 语义;(3) 因果功能层面——模板 token 在去噪计算中是否充当语义寄存器,语义又是通过什么路径、在第几层进入这些 token;(4) 结构层面——不同注意力头和不同深度在语义维护中如何分工;(5) 应用层面——能否把机制认识转化为与 prompt 无关、免训练的推理加速规则。

与已有工作不同的是,本文的独特切入角度有三点。第一,方法论上,它首次把 LLM 可解释性的工具箱(attention sink 分析、activation patching、head transplantation、causal masking)系统性地移植到带 LLM 文本编码器的大规模文生图 DiT 上,此前视觉生成侧的 sink 证据极为有限(仅有并发的 SD3/SDXL 工作,且不涉及因果验证)。第二,概念上,它不把 attention sink 当作应该消除的伪影,而是主动追问 sink 有没有功能——结果发现模板 token 兼具 sink 与语义寄存器双重角色,扩展了传统 register 观(人工添加的 norm sink 不参与语义)。第三,机制上,它颠覆了'逐层直读 prompt'的默认图景,提出语义注入遵循间接电路 $S \rightarrow I \rightarrow R$:语义先在第一块进入图像流,再由模板 token 从图像流读回,深层反复从寄存器取语义——'输入端编码语义的 token 未必是生成过程中维护语义的 token'。

核心方法

先说直觉:模板 token 在编码器输出处几乎是白板,但在 DiT 内部,图像 token 的文本注意力却大量涌向它们,像一块吸引所有注意力的'海绵'。作者猜想这块海绵不是废料而是语义寄存器,并设计了一套递进的验证路线。技术路线分四步:第一步做 token 级注意力分解,把联合注意力矩阵切成 T2T/T2I/I2T/I2I 四块,统计 I2T 子块中每个 token 吸收的注意力质量 $m^{(l,h)}_K(Q)$,确认模板 span 是支配性 sink;第二步做 span 级条件干预,用跨 prompt 模板交换和'平均模板'替换检验模板 token 表示中的语义含量,发现它们携带的语义弱到可以忽略;第三步做跨轨迹头移植,把两条不同 prompt 轨迹的 per-head (q,k,v) 投影逐一互换,按'读语义程度'排序定位真正决定物体身份的头,证明读语义与携带语义解耦;第四步做逐层因果 masking,在 softmax 前屏蔽寄存器 token 对语义 span 或对图像流的注意力,定位语义进入寄存器的路径与时序。最后把'高语义读取注意力的头因果惰性'这一发现转化为免训练剪枝规则。整个框架在 Qwen-Image(60 块 × 24 头 = 1440 头的 20B 级 MMDiT)上运行,并推广到 FLUX.2、Krea-2-Turbo 等模型。

核心创新是证明'读 prompt 的'与'携带语义的'在 DiT 中是解耦的两套机制,并给出完整的间接电路。论文推翻了三个默认假设:(1) 推翻'深层持续直读 prompt'——图像 token 的文本注意力其实 76%~92% 落在模板 token 上;(2) 推翻'sink 是无功能伪影'——头移植实验显示,先移植最会读语义 token 的头($m^S$ 降序)不仅不能把苹果换成香蕉,反而让生成塌缩到无条件默认人像;反过来先移植几乎不读语义的头,仅 ~18% 的头(约 260/1440)就完成了物体身份翻转,说明物体身份存储在那些注意力上'看不见'的寄存器头里;(3) 推翻'寄存器从 prompt 直接取语义'——masking 实验显示屏蔽 $R\to S$ 注意力物体纹丝不动,屏蔽 $R\to I$ 注意力则物体在前两个 block 内消失,即语义路径是 $S \to I \to R$:第一块把 prompt 语义注入图像潜变量,第二块模板 token 再从图像流读回,此后深层反复 attend 寄存器取语义。这与已有工作的本质区别在于:LLM 的 sink 研究、ViT 的 register 研究都只处理注意力伪影或计算缓冲,从未证明 sink token 是生成过程中语义的主动载体。

方法步骤详情

方法步骤完整描述如下。第一步,条件序列构造:prompt $p$ 被包装为 $c_{raw}=[r_{prefix};\ p;\ r_{suffix}]$ 送入 Qwen2.5-VL,取末层隐藏态并丢弃固定的 34 个模板前缀位置,得到 $c=(c_1,\dots,c_{n_{cond}})$,按位置切分为语义 span $S$ 与模板 span $R$(如 "An apple" 为 $|S|=2$、$|R|=5$)。第二步,注意力质量度量:对每个 block $l$、head $h$ 的 post-softmax 联合注意力矩阵 $A^{(l,h)} \in \mathbb{R}^{(n_{cond}+n_{img})\times(n_{cond}+n_{img})}$,定义 $m^{(l,h)}_K(Q)=\frac{1}{|Q|}\sum_{i\in Q}\sum_{j\in K}A^{(l,h)}_{i,j}$,聚焦图像 query $Q=I$ 对条件 key $T=S\cup R$ 的 I2T 块,沿全部 $L\times H\times T$ 聚合得 $\bar{m}^R, \bar{m}^S$ 与 per-token 比值。第三步,span 干预:(a) 跨 prompt 交换 $[S_A; R_B]$——固定 seed 与采样器,保留 A 的内容词、换成 B 的模板 token,用 DINOv3 [CLS] 余弦相似度验证物体不变;(b) 平均模板替换——把 100 个 GenEval prompt 的 R 平均成单个 prompt 无关的 $\bar{R}$,替换 40 个 held-out prompt 的 R 构成 $[S; \bar{R}]$。第四步,跨轨迹头移植:同时跑 A="An apple" 与 B="A banana" 两条轨迹(2 步蒸馏 LoRA、只跑单步以固定时间步),第 $n$ 轮把 A 中按语义读取注意力 $m^S$ 排序后的前 $n$ 个头的 (q,k,v) 投影换成 B 的对应头,共 $L\times H=1440$ 头,观察图像何时翻转;另做 per-span 整段交换作为对照。第五步,逐层因果 masking:在寄存器 query $R$ 处 softmax 前屏蔽其对语义 token $S$ 或对图像潜变量的注意力,按前 $k$ 个 block 累积施加,比较物体何时塌缩;用'仅屏蔽第一块无效'这一事实推断 $S\to I$ 注入在第一块完成、$I\to R$ 在第二块完成。第六步,剪枝规则:按 $\bar{m}^S$ 降序对 1440 头排序,剪除 top-$K$ 头的全部 q/k/v 投影、输出投影与注意力计算,只在最后 80% 去噪步生效($f=0.2$,前 20% 步保留),joint-attention FLOPs 减少比例为 $(1-f)K/1440$。

技术新颖性

技术新颖性体现在五个层面。(1) 框架层面:这是首个面向大规模文生图 DiT 的系统性因果可解释性框架,把 token 分解、span 干预、头移植、逐层 masking 四种干预组合成可复用的流水线,并在 60 块 × 24 头 = 1440 头的 20B 级模型上实际可行(作者开源了代码)。(2) 概念层面:明确区分'注意力模式'与'因果功能'——模板 token 的 sink 模式(描述性)与寄存器功能(因果性)由不同的实验分别确立,这种严谨性在视觉生成可解释性工作中少见。(3) 机制层面:$S \to I \to R$ 间接电路及'第一块完成语义注入、第二块完成读回'的时序定位是全新发现;深度剖面(模板 per-token 注意力在第一块接近零、block 11 才达半平台、block 20 达峰值)进一步排除了'输入嵌入伪影'解释,支持这是学到的、深度局域化的机制。(4) 泛化层面:同一现象在 Qwen-Image/2512、FLUX.2(32B、Mistral-3 编码器、sink 分散于系统块)、Krea-2-Turbo(12B 单流)、2 步蒸馏模型、指令编辑模型、中英文 prompt 上均成立,证明这是 LLM 编码器 + 联合注意力这一架构范式的普遍性质。(5) 应用层面:把'高 $m^S$ 头因果惰性'这一机制发现直接转成 prompt 无关、免训练、无需逐 prompt 剖析的剪枝规则,完成了从机制到系统的闭环。

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 the template tokens.
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 the template tokens.
Overview of our causal interpretability framework.
Figure 6: Overview of our causal interpretability framework.
Chat-templated text conditioning in Qwen-Image.
Figure 7: Chat-templated text conditioning in Qwen-Image.

实验结果

论文的实验证据链可以逐环分析。(1) 模板 token 是支配性 sink(Table 1、Fig 3):在 "An apple" 上,模板 span 吸收 $\bar{m}^R=0.23$ 对语义 span 的 $\bar{m}^S=0.020$——span 级 11 倍、per-token 4.6 倍、98% 的 (t,l,h) 位点模板超过语义;最强单头 $m^R=0.998$,最高噪声级 <|im_end|> 一枚 token 独吸 13% 的全部图像 query 注意力(超过内容名词 "apple" 的 6 倍)。规模化验证:GenEval(553 条 prompt、平均 7.9 内容词)上 $\bar{m}^R=0.19$ vs $\bar{m}^S=0.046$,76% 的 I2T 注意力落在模板 span,per-token 6.4 倍,89% 位点模板胜出,91% 位点注意力最高的文本 token 是模板 token,其中 <|im_end|> 在 54% 位点独占鳌头;DPG-Bench(1,065 条、平均 82.1 内容词)span 级比例反转(Pr=12%)但 per-token 比反升至 7.2 倍——sink 随 prompt 变长反而更强;中文 Qwen-Image-Bench(1,000 条)同样成立(Pr=22%、6.2 倍)。(2) 模板 token 语义极弱(Fig 4):跨 prompt 交换 $[S_A;R_B]$ 后 DINO 相似度高达 0.95~0.999;用 100 个 prompt 的平均模板 $\bar{R}$ 替换后,模板表示仅变化相对 L2 0.36、首步预测仅扰动 1.8%,图像相似度中位数 0.99、均值 0.93;CFG=1 下少数失败案例塌缩到模型的无条件默认(普通人像),提高 CFG 即可恢复。(3) 寄存器因果证据(Fig 5):按 $m^S$ 降序移植头不传递身份且塌缩到默认人像,升序移植仅 ~18%(约 260/1440 头)即把苹果翻成香蕉;屏蔽 $R\to S$ 注意力物体不变,屏蔽 $R\to I$ 注意力物体在前两块内消失,而仅屏蔽第一块几乎无效。(4) 头与深度分工(Fig 16、17):驱动身份转移的 top-270 头呈双峰分布——early(L1-10)89 个、middle(L11-50)96 个、late(L51-60)85 个;early 组单独即可双向干净翻转身份(commit),middle 组单独几乎不改变身份(carry),late 组翻转但带残余畸变(refine);沉默少量 I2I 集中的 rendering 头即让输出碎裂成不连贯的马赛克。(5) 剪枝收益(Table 2):K=360(剪 1/4 头)削减 20% joint-attention FLOPs,GenEval 仅从 76.1 降到 74.7(-1.4 分);K=216 更划算(75.8 分、LPIPS 0.21、HPSv3 9.47、省 12%);对照实验证明排序至关重要——K=288 时本文 $\bar{m}^S$ 排序得 75.5,按模板 sink $\bar{m}^R$ 排序仅 69.6,随机剪枝崩到 51.3(HPSv3 相应 9.29 / 8.03 / 4.86)。(6) 跨模型泛化:FLUX.2(32B、Mistral-3 编码器)上模板 span 吸收 $\bar{m}^R=0.22$ vs $\bar{m}^S=0.016$,92% 的 I2T 注意力落在模板,per-token 3.3 倍、99.8% 位点胜出,sink 分散在系统消息块("that" 在 33% 位点居首);Krea-2-Turbo(12B 单流)67%、3.1 倍;2 步蒸馏后 sink 几乎无损(77%、6.8 倍);编辑模型 Qwen-Image-Edit-2511 上 per-token 模板注意力是 vision token 的 7.7 倍、指令 token 的 13.8 倍、参考图 latent 的 194 倍,在 100% 的编辑中居首。(7) 时间与深度结构(Fig 15):模板 per-token 注意力从 $t=1.0$ 的 0.050 缓降到 $t=0$ 的 0.035,语义 token 从 0.009 降到 0.004,优势比从 5.3 倍扩大到 7.7 倍;深度上第一块近零、block 11 达半平台、block 20 达峰——支持 sink 是学到的、深度局域化的机制而非输入伪影。

Attention statistics across prompt benchmarks, in which |S| is the mean number of semantic tokens per prompt, mR denotes image-to-text attention mass assigned to trailing template tokens, mS denotes mass assigned to semantic prompt tokens, mtokR/mtokS denotes the average mass per template token divided by the average mass per semantic token, and Pr[mR > mS] is the fraction of step–layer–head sites where template mass exceeds semantic mass.
Table 1: Attention statistics across prompt benchmarks, in which |S| is the mean number of semantic tokens per prompt, mR denotes image-to-text attention mass assigned to trailing template tokens, mS denotes mass assigned to semantic prompt tokens, mtokR/mtokS denotes the average mass per template token divided by the average mass per semantic token, and Pr[mR > mS] is the fraction of step–layer–head sites where template mass exceeds semantic mass.
Training-free late-step head pruning on Qwen-Image-2512, evaluated on GenEval. K is the number of silenced heads out of 1,440, while K=0 is the unpruned baseline.
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, while K=0 is the unpruned baseline.
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 mR, the image-to-template-token attention mass. Attention concentrates as a sharp ridge over the template span R while attention among image tokens stays low.
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 mR, the image-to-template-token attention mass. Attention concentrates as a sharp ridge over the template span R while attention among image tokens stays low.
Template tokens carry semantics, but only weakly. (a) Cross-prompt swap substitutes another prompt's template tokens, [SA; RB], with little effect on the object. (b) Average on template tokens replaces R with a single prompt-agnostic average R̄, [S; R̄], which can occasionally cause large semantic changes. Increasing the guidance scale (CFG) largely resolves these deviations. (c) Recomputing the average R̄ from the same prompts with the "a photo of" prefix stripped leaves the result essentially unchanged from (b).
Figure 4: Template tokens carry semantics, but only weakly. (a) Cross-prompt swap substitutes another prompt's template tokens, [SA; RB], with little effect on the object. (b) Average on template tokens replaces R with a single prompt-agnostic average R̄, [S; R̄], which can occasionally cause large semantic changes. Increasing the guidance scale (CFG) largely resolves these deviations. (c) Recomputing the average R̄ from the same prompts with the "a photo of" prefix stripped leaves the result essentially unchanged from (b).
Template tokens act as the implicit semantic registers in the denoising process. (a) Progressive head swap, ordering heads by their semantic-span attention mS. Swapping high-to-low (mS↓, bottom) barely transfers the identity and even collapses to the unconditional portrait; the reverse order (mS↑, top) flips apple to banana after only ∼18% of the heads. (b) Progressive attention masking over layers. Blocking R→S attention leaves the apple largely intact, while blocking R→I attention quickly erases the object identity.
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 mS. Swapping high-to-low (mS↓, bottom) barely transfers the identity and even collapses to the unconditional portrait; the reverse order (mS↑, top) flips apple to banana after only ∼18% of the heads. (b) Progressive attention masking over layers. Blocking R→S attention leaves the apple largely intact, while blocking R→I attention quickly erases the object identity.
Per-span progressive swap. The (q, k, v) of one span—semantic S (top) or template R (bottom)—is copied from B into A over the first r blocks. Swapping S preserves the apple; swapping R disrupts it early.
Figure 8: Per-span progressive swap. The (q, k, v) of one span—semantic S (top) or template R (bottom)—is copied from B into A over the first r blocks. Swapping S preserves the apple; swapping R disrupts it early.
Results for the progressive head-swap experiment on FLUX.2.
Figure 9: Results for the progressive head-swap experiment on FLUX.2.
Results for the progressive head-swap experiment on Krea-2-Turbo.
Figure 10: Results for the progressive head-swap experiment on Krea-2-Turbo.
Temporal and depth structure of the template sink on Qwen-Image-2512, aggregated over GenEval prompts.
Figure 15: Temporal and depth structure of the template sink on Qwen-Image-2512, aggregated over GenEval prompts.
Layer distribution of the first 270 heads in the reverse semantic-attention order (mS↑). Top panels show the swap results for different layer groups; bottom shows how these heads are distributed across transformer layers.
Figure 16: Layer distribution of the first 270 heads in the reverse semantic-attention order (mS↑). Top panels show the swap results for different layer groups; bottom shows how these heads are distributed across transformer layers.
Qualitative results of silencing rendering heads.
Figure 17: Qualitative results of silencing rendering heads.
Qualitative results of head pruning.
Figure 18: Qualitative results of head pruning.
查看结构化数据
任务指标本文基线提升
免训练加速(Qwen-Image-2512,剪 K=360 头,最后 80% 去噪步) GenEval 准确率 / joint-attention FLOPs 74.7 分,FLOPs -20.0% 76.1 分(未剪枝 K=0),HPSv3 9.56 仅 -1.4 分换取 20% 注意力算力削减
免训练加速轻量档(K=216) GenEval / LPIPS / HPSv3 75.8 / 0.21 / 9.47 76.1 / – / 9.56(未剪枝) 12% FLOPs 削减,语义正确性几乎无损(作者推荐档位)
剪枝排序消融(K=288) GenEval 准确率 / HPSv3 75.5 / 9.29(按 $\bar{m}^S$ 降序) 69.6 / 8.03(按模板 sink $\bar{m}^R$ 排序);51.3 / 4.86(随机) +5.9 分与 +24.2 分,证明'剪哪些头'比'剪多少'重要
I2T 注意力分布(Qwen-Image,GenEval 553 条) 模板 span 注意力质量 $\bar{m}^R$ 0.19,76% 的 I2T 注意力,per-token 6.4× 语义 span $\bar{m}^S$=0.046 89% 位点模板>语义,91% 位点 top-1 是模板 token
跨模型泛化(FLUX.2,32B + Mistral-3 编码器) I2T 注意力落于模板 span 的比例 92%($\bar{m}^R$=0.22 vs $\bar{m}^S$=0.016,per-token 3.3×,99.8% 位点) 语义 span 仅占约 8% 证明 chat-template sink 跨编码器、模板与架构普遍存在
编辑模型中的寄存器角色(Qwen-Image-Edit-2511,GEdit-Bench) per-token I2T 注意力比 模板 token = 7.7× vision token、13.8× 指令 token、194× 参考图 latent 三种真实信息载体(vision/指令/参考图) 100% 的编辑中模板 token 的 per-token 注意力排名第一
物体身份因果定位(跨轨迹头移植,Qwen-Image-2512 2步蒸馏 LoRA 单步) 翻转 apple→banana 所需移植头数 按 $m^S$ 升序仅 ~18%(≈260/1440 头)即完成翻转 按 $m^S$ 降序先移植语义读取头:身份不翻转且塌缩到无条件默认人像 证明'读语义'与'携带语义'彻底解耦

局限与改进

作者在附录 A 中承认的局限有:研究以分析为主,剪枝规则只是对机制发现的'naive first-cut'式应用,更精巧的设计——例如保留寄存器位置作为 key 的 sink-aware 稀疏注意力——可能带来大得多的收益;模板 token 最初为何、如何演化成语义寄存器这一问题完全留白。我自己的观察补充如下:(1) 剪枝实验只在 Qwen-Image-2512 + GenEval 上报告,且感知质量衰减快于语义正确性(K=360 时 LPIPS 已达 0.39、HPSv3 从 9.56 掉到 8.76),意味着'正确但变丑',在审美敏感的实际产品中可用档位其实更接近 K=216;(2) 头移植与 masking 的主实验在 2 步蒸馏 LoRA 上只跑单步以固定时间步,这简化了分析,但与原生 50 步的动力学不同,虽然附录显示蒸馏模型的 sink 统计完好,因果时序结论(第一块注入、第二块读回)外推到多步全轨迹仍需直接验证;(3) masking 采用'前 k 块累积'的粗粒度窗口,无法区分块内更精细的时序效应;(4) 分析局限于联合注意力架构(MMDiT 双流与单流),cross-attention 架构(PixArt-Σ、SDXL 等 CLIP/T5 系)中没有模板 token,对应机制是否存在未讨论;(5) 模板 span 的界定依赖具体 chat 模板的格式约定,对任意新编码器如何自动划分 $S$/$R$ 缺乏通用规则;(6) 剪枝评估只用 GenEval 一个基准,长 prompt、密集构图、文字渲染等场景的鲁棒性未知。

独立分析的弱点

以下是独立于作者的弱点分析,每条附改进方向。(1) 感知质量是剪枝的主要代价:K=360 时 LPIPS 0.39、HPSv3 从 9.56 降至 8.76,且 Fig 18 的定性结果显示细节纹理随预算增大逐渐糊化。改进方向:sink-aware 稀疏注意力——保留寄存器位置作为 key(作者在附录 A 也承认这一点),只剪除其对应的 query 侧计算或 value/output 投影,把'维护语义所需的读取'与'渲染细节所需的计算'分离,理论上能保住更多感知质量。(2) 排序是静态且 prompt 无关的:$\bar{m}^S$ 是跨数据集聚合量,特定 prompt 下被剪的头可能恰好参与关键语义(例如多物体、属性绑定的 prompt)。改进方向:训练一个轻量 per-prompt 头选择器,或按去噪步动态路由——前 20% 步全保留的设定已经暗示时序自适应有价值。(3) 对涌现机制沉默:论文无法回答'为什么内容为空的 token 会变成寄存器',也就无法预测新架构是否自动获得该性质、训练配方如何促进它。改进方向:沿预训练 checkpoint 序列追踪 sink 的出现时间与深度剖面(类比 LLM 中 sink 在预训练中涌现的研究)。(4) 因果实验在单步蒸馏设置下完成,多步原生轨迹上的重复验证(例如滑动窗口 masking)仍是空白。(5) CFG=1 下的失败尾部(Fig 4b 中相似度低至 0.35~0.56 的个例,物体被整体替换或数量改变)说明对模板表示的粗暴操作在高保真场景有风险。改进方向:两阶段采样——先用高 CFG 锚定语义再放宽。(6) 编辑模型分析只给了 per-token 注意力统计,寄存器与 vision token、参考图 latent 之间的竞争关系缺乏因果干预实验。

未来方向

作者明确提出的方向有两个:其一是把剪枝升级为 sink-aware 稀疏注意力,保留寄存器位置为 key 而剪除其余,预期收益远超当前 20%;其二是解释内容为空的模板 token 为何会演化成语义寄存器,这需要训练动力学层面的追踪。基于论文成果还可以延伸:(3) 显式寄存器架构设计——训练时就加入专用语义寄存器 token 并施加结构约束(如只允许在指定层读写),把偶然涌现变成可控设计,可能同时提升效率与可控性;(4) 寄存器作为编辑接口——既然物体身份存于寄存器状态,直接改写寄存器表示有望实现免训练的属性替换、概念擦除或风格迁移,比修改 prompt 或微调 LoRA 更精准;(5) 蒸馏对齐——少步蒸馏时对齐 $S\to I\to R$ 电路的层间时序,或能缓解蒸馏常见的语义漂移;(6) 系统工程落地——把 20% FLOPs 削减与 KV cache 压缩、头并行策略结合,转化为实际延迟与显存收益;(7) 利用 early commit / middle carry / late refine 的三段分工做分块缓存或步间特征复用,middle 40 层几乎不重写身份,是缓存的理想目标;(8) 把分析扩展到视频生成 DiT 与多模态条件(编辑、identity 保持)下的寄存器竞争格局。

复现评估

复现条件总体良好。代码已开源(GitHub: Met4physics/DiT-Interpretability),覆盖注意力统计、span 交换、头移植、masking 与剪枝全流程。涉及模型全部公开可得:Qwen-Image、Qwen-Image-2512、Qwen-Image-Edit-2511(HuggingFace 开源权重)、FLUX.2、Krea-2-Turbo,以及社区发布的 2 步蒸馏 LoRA(Wuli-art)。评估数据均为标准公开基准:GenEval(553 条)、DPG-Bench(1,065 条)、Qwen-Image-Bench(1,000 条中文)、GEdit-Bench。作者报告的环境为 PyTorch 2.12.1 + DiffSynth-Studio v1.1.7,NVIDIA H20(1,024GB 显存)+ 192 核 CPU,固定随机种子 42,保证逐图可复现。这是纯分析性工作,无需任何训练,主要算力开销在于推理时缓存并检查 1440 个头的注意力矩阵与 q/k/v 投影;头移植和 masking 用标准 PyTorch forward hook 即可实现。难度评估:中等偏高——难点不在算法(所有干预都概念简单),而在资源:H20 1TB 显存配置少见,在 20B 级模型上缓存全量 per-head 注意力矩阵需要大显存或 offload 策略;若只在 Qwen-Image 上以 bf16、单张 80GB A100/H100、适当分辨率做核心实验(注意力统计 + 单步头移植)是可行的,FLUX.2 32B 的复现则需要多卡。总体属于可复现性较好的机制分析论文。