Persistent differentiable 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.
Training KV cache writing takes no second pass. It takes a KV cache built for gradients: persistent pages, local rematerialization, and a writer that learns what to store from its future reads.
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 60 s and 8.5 points at 240 s 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.
Three training recipes, one prompt. Drag the timeline to compare.
Same initialization, data, schedule and training seed for all three. Ticks mark the frames shown in the paper.
One training step on a 5 s clip: 21 latent frames forward, then backward. Click any element for details and code.
Measured memory of the same step (rank 0, 4 H100, batch 2), aligned frame by frame. Click to jump.
Click any element in the animation for its explanation and code.
Learn each write from its future reads, in one pass.
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.
Every graph-carrying forward is rematerialized locally in groups of blocks. The retained activation footprint is bounded independently of the persistent state, and no second pass over the clip is needed.
A rank-64 residual on the K and V projections is active only when a segment writes its memory. It learns what to remember from the gradients of future reads while the generation backbone stays shared.
1.3B causal generator, 5 s training clips, three training seeds.
| Method | Aesthetic ↑ | Imaging ↑ | Subject ↑ | Background ↑ | Dynamic ↑ |
|---|---|---|---|---|---|
| 60 s | |||||
| CF++ | 52.7±1.4 | 63.3±1.6 | 94.7±1.3 | 94.5±0.7 | 76.5±19.0 |
| SGF | 56.2±1.4 | 67.4±2.2 | 96.5±0.4 | 95.7±0.5 | 38.5±6.9 |
| Writer LoRA | 62.8±0.4 | 69.7±0.6 | 98.2±0.2 | 96.9±0.2 | 21.8±17.5 |
| dKV Forcing (ours) | 59.8±1.3 | 68.8±1.3 | 96.6±1.2 | 94.8±1.1 | 71.4±34.5 |
| 240 s | |||||
| CF++ | 49.0±2.5 | 61.7±2.7 | 93.8±1.0 | 94.4±0.7 | 81.7±14.9 |
| SGF | 51.3±1.7 | 64.6±3.5 | 95.9±0.3 | 95.3±0.4 | 38.9±7.4 |
| Writer LoRA | 59.8±1.4 | 67.7±1.3 | 97.7±0.3 | 96.4±0.3 | 20.5±19.2 |
| dKV Forcing (ours) | 57.4±0.4 | 68.2±0.5 | 96.2±1.0 | 94.8±0.7 | 72.0±33.8 |
Writer LoRA = SGF + writer residual. Full tables in the paper.
| Method | Cycle (s) | vs. two-pass | Generator update (s) | Generator peak (GiB) | Resident (GiB) |
|---|---|---|---|---|---|
| Two-pass reconstruction | 122.8 | — | 35.7 | 69.9 | 40.7 |
| CF++ (no memory gradient) | 104.7 | −14.8% | 31.8 | 55.9 | 40.7 |
| Mutable cache, write differentiated | out of memory in the first generator backward | ||||
| dKV Forcing (default) | 97.3 | −20.8% | 33.9 | 62.1 | 29.2 |
| dKV Forcing (fused) | 95.9 | −21.9% | 32.4 | 65.6 | 29.2 |
| dKV Forcing (hidden) | 105.9 | −13.7% | 43.1 | 56.1 | 29.3 |
| dKV Forcing (fused+hidden) | 100.9 | −17.8% | 37.0 | 58.9 | 29.3 |
All executions match the two-pass gradient to 4.1×10⁻¹² in fp64.
The writer residual raises fidelity. Rollout dropout of the residual brings the motion back: at 240 s, 57.4 aesthetic and 72 dynamic against 51.3 and 39 for SGF.
@article{li2026dkvforcing,
title = {dKV Forcing: Separating Generation and Memory Representations
through a Differentiable KV Cache},
author = {Li, Zhiqi and Zhu, Bo},
journal = {arXiv preprint},
year = {2026}
}