On-Policy Codec Distillation for Efficient All-in-One Video Generation
Boyang Wang, Kevin Blackburn-Matzen, Oindrila Saha, Matheus Gadelha, Zezhou Cheng
cs.CV
2026-11-24
H.264 motion vectors and residuals pick which condition tokens to keep; on-policy distillation adapts the model: 66% fewer tokens, 2.3x faster denoising, teacher-level quality.
All-in-one generative models tokenize every condition (identity, sketch, depth, pose, motion track, reference image) and concatenate all of it into one input sequence, so attention cost grows quadratically with each added condition. A 121-frame generation with 16 condition types can carry 24,800 condition tokens, and conditioning ends up dominating inference cost.
Existing acceleration work (fewer sampling steps, FlashAttention, quantization, feature caching, sparse attention) targets the denoiser and leaves this alone. The redundancy on the condition side is large: static backgrounds repeat every frame, and a motion path covers a few pixels. Deciding which pixels carry genuinely new information is exactly the problem video codecs solved decades ago.
Two pieces: prune, then teach.
Codec pruning. Run each condition through H.264 (x264, B-frames off, single forward reference) and read two signals: the motion vector (how far a block moved from the previous frame) and the residual (what is left after the move). A 3D VAE token covers 32×32 pixels over 8 frames, while codec blocks are 16×16 down to 4×4, so pixel-level signals aggregate onto the token grid and each token gets a motion score and a residual score (max over frames). Two modes:
The whole thing runs in real time on CPU, 1.13 seconds per case in parallel with the VAE and text encoders, against 23.8 s on GPU for DINO attention and 75 s for DeepGaze saliency. H.264 is a deliberate choice: H.265 and AV1 blocks reach 64×64 and 128×128 and straddle token boundaries, and their motion is no longer a single displacement. H.264 macroblocks fall inside tokens, and encoding is fastest (0.06 s for a 49-frame 480×640 clip). Four decoder fixes matter too; without them flat backgrounds read as new content and identity references only prune 14.4% instead of 74.8%.
On-policy self-distillation (OPSD). Plain SFT on pruned conditions leaves a visible gap to the dense model. CodecOPSD freezes the teacher and feeds it the dropped tokens as privileged information. The student (same base model, LoRA only on the condition-token projections) rolls out its own trajectory from pure noise, and at the first N high-noise states teacher and student see the same noisy latent while the loss is the squared difference of their velocity predictions. No ground truth is involved. The size of the information gap is the key knob: shrinking it (teacher also pruned) or growing it (student drops 90%) both hurt, with FID rising from 23.0 to 23.7 and 23.8.
The main testbed is an internal 22B DiT (16B loaded) with 16 condition modalities, evaluated on 2,000 clips from VidGen-1M. At the same budget of 66% average token drop:
| Method | FID ↓ | FVD ↓ | LPIPS ↓ | Selection time |
| Dense teacher | 22.4 | 118.0 | 0.273 | 0 |
| Training-free, Random | 29.2 | 161.2 | 0.351 | 0 |
| Training-free, DINO attention | 28.8 | 151.1 | 0.368 | 23.8 s (GPU) |
| Training-free, Codec | 24.5 | 132.3 | 0.307 | 1.13 s (CPU) |
| SFT + Codec | 23.8 | 130.9 | 0.297 | 1.13 s (CPU) |
| CodecOPSD | 23.0 | 113.8 | 0.278 | 1.13 s (CPU) |
CodecOPSD is best on 10 of 12 metrics, and its FVD (113.8) even lands slightly below the teacher (118.0). In a blind study with 20 raters and 384 judgments, 92% rated it equal or better on condition following and 88% on visual quality; no VBench score moved by more than 1.0 point. The gap between the SFT row and the CodecOPSD row is the distillation doing its job: same token selection, SFT cannot close the quality gap, on-policy distillation can.
On the inference side, denoising is 1.54× faster with one condition and 2.30× with five, without KV cache; the demo case with all 16 conditions prunes 89% of tokens for 3.1×. With KV cache the speedup shrinks to 1.15–1.37×, but the cache itself is 62–73% smaller. The per-condition "free drop" (maximum drop staying within the teacher's ±2σ seed noise) ranges from 26–71% for dense conditions to 80–94% for sparse ones (pose, identity, boxes, tracks).
Transfers hold up on three external models: MiniMax-H3 Ref2VA drops 71.6% of DiT condition tokens and 36.2% of VLM tokens on 237 OmniVBench cases for 1.87× faster denoising on average, with no overall score down more than 0.6 and up to 3.72× with many references; MiniMax-H3-Image is 3.06× faster at 2048², where the dense model OOMs past 12 reference images on a 141 GB H200 while this one fits 16; Cosmos3-Nano stays within the teacher's ±2σ on all six tasks, 2.30× faster on video-to-audio. Figure 1 reports up to 8.4× in extreme settings (2048p, 16 identity images).
Condition tokens are the overlooked cost in all-in-one models, and they grow with every reference a user brings. The approach is orthogonal to step distillation, FlashAttention, quantization, and caching, and the paper validates it stacked on the 8-step FastH3-Omni sampler.
The most reusable idea for inference engineers is outsourcing token selection to the codec: H.264 runs in real time on every phone, uses no GPU, and needs no trained scoring network. Teams building controllable generation can lift the selection rule directly. The distillation design carries a transferable lesson as well: the privileged information is exactly the dropped tokens, an information gap of the right inferable size, and both smaller and larger gaps lose points.
To be honest about its place: this is solid systems acceleration work. Codec-based pruning is not new (VLM work already used it for understanding); the contribution is moving it to generation, where pruned content still has to appear in the output and therefore needs conservative selection plus distillation. Incremental but well executed.