Manuscript Offprint

arXiv:2611.01648

dKV Forcing: Separating Generation and Memory Representations through a Differentiable KV Cache

Zhiqi Li, Bo Zhu

Zhiqi Li Bo Zhu

Georgia Institute of Technology

zli3167@gatech.edu

Project page: https://zhiqili-cg.github.io/dKV-Forcing-Project

Code: https://github.com/ZhiqiLi-CG/dKV-Forcing

Figure

Figure 1. Trained on 5s clips, dKV Forcing generates up to four minutes. The top two rows are 60s generations and the bottom two are 240s generations, 12 and 46 times the training clip, with the time stamp drawn in each frame. The prompts are a cat and a dog in a sword fight, a child blowing bubbles, a cat drinking water, and a man wiping a kitchen counter. Subject, layout and lighting hold throughout while the motion continues; the same generations are compared with CF++ and SGF in Figures 4 and 6 and Appendix C.5.

Abstract

A causal video generator produces two key-value (KV) states for every segment: the KV it uses while denoising that segment, and the KV it writes into the cache for later segments to read. In a pretrained generator the two already differ substantially, later segments attend to them differently, and replacing the written KV with the generation KV degrades the continuation. We propose dKV Forcing (dKV denotes differentiable KV) to learn a dedicated memory representation from its future use: a writer-specific low-rank residual on the shared backbone separates memory writing from generation and is trained through the future reads of what it writes. Learning a write from its future use needs gradients through the cache, which the mutable cache in common use cannot provide. dKV Forcing replaces the training-time cache by persistent differentiable pages with local rematerialization and, in one temporal traversal, computes exactly the gradient that a two-pass reconstruction of the same objective computes. One traversal computes

the full memory gradient at 7% generator-update overhead over detached-write training, with 28% less resident memory and 20.8% shorter training cycles than the two-pass reconstruction. Over Self Gradient Forcing (SGF), the same objective trained with the same traversal, writer adaptation raises VBench-Long aesthetic quality by 6.6 points at 60s and 8.5 points at 240s with the highest subject and background consistency, and rollout dropout of the residual keeps most of this gain while restoring the motion of training without write gradients.

1. Introduction

Video diffusion transformers produce convincing clips, but they denoise every frame of a clip jointly, so generating one more second means recomputing the whole sequence [19]. Causal variants remove this constraint: they generate a video segment by segment (a latent frame, or a short chunk of frames), each new segment attending to a KV cache of

Figure

Figure 2. dKV Forcing: generation, memory writing and the memory gradient in one temporal traversal. For each segment the model runs a generation forward GθG_\theta, whose prediction x~its\tilde{x}_i^{t_s} enters the video loss, and a memory write Kθ,ϕ\mathcal{K}_{\theta,\phi}, which turns the detached prediction sg(xictx)\text{sg}(x_i^{\text{ctx}}) into the KV of that segment; θ\theta is the shared backbone and ϕ\phi the writer LoRA on the K and V projections, active only at the write. The written KV is committed once to a fresh slot of the page table and never modified afterwards. Later segments read the stored prefix through handles (teal). Both forwards are checkpointed in groups of blocks (gold ticks). In backward (purple, dashed) the gradient of the loss reaches every prediction, flows through the handles to every page it read, and on to the writer that produced that page; the stop-gradient keeps it from re-entering the prediction, and replay only reads the pages. Sampling substeps without gradient and the final, never-read write are omitted. Implementation details of each element are in Appendix B.4.

the segments already produced, and reach streaming speed on a single GPU [1, 7, 26]. In such a model the cache is the memory. What a later segment knows about the past is exactly what earlier segments wrote into the cache.

Training these models on the histories they generate themselves is what made them usable at length: Self Forcing rolls the model out during training and supervises the rollout with a video-level distribution-matching objective [7, 24, 25], removing the train-test gap that otherwise accumulates error over long generations. Building on it, Causal Forcing makes the teacher itself causal [34], and Causal Forcing++ accelerates the initialization through causal consistency distillation [32]. Their gradient, however, stops at the cache. Each segment is trained to generate well given the history it is handed, but no gradient reaches the operations that produced that history, so the model is never taught how to remember. The KV written into the cache comes from the same projections that denoise the current segment, and those projections are trained only for that denoising.

In the pretrained model the written KV already differs from the generation KV by a third of the key norm and 70% of the value norm, later segments attend to the two differently, and swapping the written KV for the generation KV causally degrades the continuation (Sec. 5.3). To let memory writing adapt independently of denoising, we introduce a writer-specific low-rank residual [6] on the shared backbone, active only when a segment is written into the cache, so that the write path has one set of parameters to itself

while the backbone stays shared and fully trained (Sec. 4).

Learning such a residual requires the gradient that previous recipes cut off [7, 32, 34]: from future reads back to past writes. Re-enabling that gradient through the ordinary KV cache is not enough. The cache is a mutable buffer written in place inside checkpointed forwards. During backward the replay re-executes those writes and attaches new graph to the same tensor, and training runs out of memory in the first backward pass, even on 5s clips (Sec. 3.4). Reconstructing the whole clip in a second differentiable forward, as Self Gradient Forcing does [35], avoids the failure, but pays for a second pass and for holding the whole-sequence graph at once. Appendix B.4 gives the code of both alternatives and of dKV Forcing.

We propose dKV Forcing (dKV denotes differentiable KV) to compute these future-read gradients within a single temporal traversal, with two execution structures designed for it: persistent differentiable pages and local rematerialization (Figure 2). At training time the inference cache becomes a set of pages: each write commits an immutable page outside any replay region; readers receive the captured prefix through data-free handles, so the graph holds handles while the page data stays outside it; and every graph-carrying forward is rematerialized locally in groups of blocks [2], which bounds the retained activation footprint independently of the persistent state. The traversal computes the exact gradient of the training objective without any second pass (Proposition 1), with 28% less resident memory and 20.8% shorter training cycles than the two-

Figure

Figure 3. Autograd graphs and backward replay under three cache execution strategies. Top: forward computation and retained graphs. Bottom: operations replayed during backward. (a) With a mutable cache, writes modify a shared tensor in place. Checkpoint replay repeats these writes, accumulating graphs until backward runs out of memory. (b) Two-pass reconstruction builds the rollout without a graph, then recomputes the entire sequence in a differentiable forward, with layer-wise replay during backward. (c) dKV Forcing commits each write to an immutable page outside replay. The graph retains handles and checkpoint boundaries, while backward reads the pages and reconstructs one block group at a time.

pass reconstruction (Sec. 5.2). Trained on 5 s clips of the 1.3B Causal Forcing++ generator, the writer residual raises VBench-Long aesthetic quality over SGF, the same objective without writer adaptation, by 6.6 points at 60 s and 8.5 points at 240 s with the highest subject and background consistency (Figure 1), and rollout dropout keeps most of this gain at the motion of detached-write training (Secs. 5.5–5.6).

Our contributions are as follows. (1) Differentiable memory writing: a single-traversal training method that carries the exact gradient from future reads back to past KV writes through persistent causal states and local rematerialization. (2) Writer-specific representation learning: a low-rank writer residual that learns the memory representation through its future reads while the generation backbone stays shared. (3) Long-horizon video generation: gains in quality, consistency and training cost at 60 s and 240 s from 5 s training clips.

References (34)