Manuscript Offprint

arXiv:2610.17829

QK-Edit: Revisiting Attention-based Injection in MM-DiT for Image and Video Editing

Tiancheng Shen, Zilong Huang, Xiangtai Li, Zhijie Lin, Jiyang Liu, Yitong Wang, Jiashi Feng, Ming-Hsuan Yang, Jun Hao Liew

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Tiancheng Shen 1,2,3,4^{1,2,3,4} Zilong Huang 2^{2} Xiangtai Li 2^{2} Zhijie Lin 2^{2} Jiyang Liu 3^{3}

Yitong Wang 3^{3} Jiashi Feng 2^{2} Ming-Hsuan Yang 1^{1} Jun Hao Liew 2^{2}

1^{1} UC Merced 2^{2} ByteDance Seed 3^{3} ByteDance Intelligent Creation 4^{4} CUHK

Image Editing

Figure

  • countryside

tulip → lion

real → origami

Video Editing

Figure

woman → polar bear

white → grey

horse → turtle

Figure 1. QK-Edit: A training-free, text-guided framework for high-fidelity image and video editing. Our method leverages strategic query-key manipulation within the vision components of Multimoda Self-Attention (MM-SA) in MM-DiTs to seamlessly perform diverse edits (e.g., object addition, object removal, object replacement, changing background, changing material, changing color, and style transformation etc.), while preserving structural consistency and visual details. Please refer to the supplementary material for more video results at higher resolutions (1K), different aspect ratios (landscape and portrait formats) and longer lengths (129 frames).

Abstract

Multimodal Diffusion Transformers (MM-DiTs) have recently emerged as a powerful framework for unified text-vision synthesis, surpassing traditional U-Net architectures in generative tasks. One key innovation lies in its Multimodal Self-Attention (MM-SA) interaction where image and text tokens are concatenated and processed via self-attention. However, this mechanism poses significant challenges for editing, rendering conventional U-Net-based attention manipulation methods ineffective. To address this limitation, we propose QK-Edit, a training-free framework that exploits the unique attention dynamics of MM-DiTs for precise text-guided image and video editing. By introducing a novel query-key manipulation strategy, our method isolates and adjusts critical attention components to achieve an optimal balance between prompt fidelity and structural consistency. This enables seamless edits across various tasks, including object addition, object removal, object replacement, changing background, changing material, changing color, and style transformation. Notably, it can be easily implemented with feature replacement in inference. QK-Edit demonstrates superior editing performance on state-of-the-art models, such as FLUX and HunyuanVideo, effectively bridging the gap between generative power and editable flexibility in MM-DiTs, and paving the way for scalable multimodal content creation.

1. Introduction

The emergence of Transformer-based diffusion models [50], particularly Multimodal Diffusion Transformers (MM-DiTs)[5, 16, 34, 70], has redefined the landscape of generative models for image and video synthesis. Unlike U-Net architectures[55], which separate text-vision Cross-Attention (CA) and vision-vision Self-Attention (SA), MM-DiTs leverage a Multimodal Self-Attention (MM-SA) mechanism to process multimodal inputs in a unified embedding space. MM-SA concatenates text and vision embeddings and computes self-attention on the joint embedding 1^{1}. This integration enables nuanced and coherent outputs, making MM-DiTs a cornerstone in models such as FLUX [5], Stable Diffusion 3.0 [16], HunyuanVideo [34], and CogVideo-X [70]. However, MM-SA introduces complexities that challenge existing editing paradigms based on attention manipulation [22, 61]. Specifically, due to the joint attention mechanism, textual and visual interactions become deeply intertwined within a single attention matrix, complicating the independent manipulation of textual and visual information. As a result, such editing methods for U-Net models become ineffective in Fig. 2.

Figure

Source Image

CA-based editing

SA-based editing

QK-Edit (Ours)

Figure 2. Directly applying CA-based and SA-based editing techniques designed for U-Net diffusion models to MM-DiTs can lead to undesirable results.

These complexities arise because such previous editing methods rely heavily on the modular nature of U-Net architectures [54], where cross-attention facilitates precise text-guided modifications, and self-attention ensures spatial consistency. In contrast, MM-DiTs integrate these attention mechanisms into a unified structure, making it challenging to independently control text-vision and vision-vision interactions without one adversely affecting the other. A naive solution is to decompose the MM-SA map into four quadrants, each representing a specific interaction between text and vision embeddings and directly apply previous CA-based or SA-based editing techniques such as P2P [22] or PnP [61] to the respective attention maps. However, this often leads to undesirable outputs, as illustrated in Fig. 2.

Through systematic analysis, we observe: (1) text-to-vision attention has negligible impact on the final generation, (2) vision-to-text attention relates vision region to the text token, and finally (3) vision-vision attention defines both spatial and temporal consistency within visual embeddings. As a result, simultaneous replacement of vision-to-text and vision-to-vision attention is necessary to enable precise control over spatial and temporal properties while adhering to the target prompt. Building upon these insights, we propose QK-Edit, a training-free editing framework that manipulates the attention quadrants of MM-DiTs to achieve high-fidelity edits. In practice, we leverage the fact that text-to-vision attention has minimal impact on the generation and replace the vision component in query and key embeddings of the target image or video with that of the source image or video during the denoising process. In practice, our proposed strategy is straightforward to implement, requiring only minimal code modifications.

Our QK-Edit can be seamlessly extended to image and video domains, demonstrating its versatility in various generative tasks. Extensive experiments validate the effectiveness of QK-Edit on state-of-the-art models such as FLUX [5] and HunyuanVideo [34], achieving superior results in tasks ranging from object-level modifications to global scene transformations. Notably, our method enables high-resolution, long-frame video editing with spatiotemporal consistency, overcoming the limitations of previous editing approaches. Furthermore, the training-free na-

1^{1}In this paper, “vision” refers to video or image data.

ture of QK-Edit ensures computational efficiency and broad applicability. QK-Edit represents a pivotal step in bridging the gap between the generative power and editable flexibility of Transformer-based diffusion models.

References (70)