CodecOPSD Explained: Codec-Based Token Pruning for Faster Video Generation
CodecOPSD uses H.264 motion and residual signals to drop redundant condition tokens before a diffusion model runs, then trains a small LoRA to keep quality. The released code reports about 70% fewer tokens and 1.9x faster denoising on MiniMax-H3 Ref2VA, up to 8.4x with heavy references. This guide explains the mechanism, real benchmark numbers, supported models and the consumer-GPU path, and states the license and verification limits plainly.
View 2 referencesAllow the functional cookie to save your likes. Privacy details
What is CodecOPSD?
CodecOPSD is an open research method that removes redundant conditioning tokens from image and video diffusion models before the denoiser runs. It reuses H.264 motion vectors and residuals as a pruning signal, then trains a small LoRA so the model stays accurate with far fewer input tokens.
The full name is On-Policy Codec Distillation.
The method comes from the paper On-Policy Codec Distillation for Efficient All-in-One Video Generation (arXiv:2611.31184) and a public GitHub repository, with inference code released on 22 November 2026. It targets a specific bottleneck: the growing cost of conditioning, not the denoising steps themselves.
Why do condition tokens dominate multi-reference generation cost?
Sequence-wise generators such as MiniMax-H3 append every reference image or video to one input sequence, so attention cost grows quadratically as conditions accumulate. When a creator supplies a sketch, depth map, identity photo and motion clip, conditioning can dominate compute even though much of that signal repeats across frames.
Most acceleration work optimises sampling steps, FlashAttention, quantization or caching, but none of those reduce the number of tokens entering the model. CodecOPSD works at the input source, so it is orthogonal to those techniques and can be combined with them.
How does codec pruning decide which tokens to drop?
Codec pruning re-encodes each reference with H.264 and assigns every token a motion score and a residual score from the blocks it covers. Tokens the encoder predicts almost entirely from neighbouring frames are discarded, while genuinely new content is kept.
The selection runs on a CPU alongside the VAE encoder, adding no measured time. Thresholds are per modality: the defaults are 5.0 motion and 1.0 residual for videos, and 4.0 motion and 1.5 residual for pictures. A dynamic drop rate adapts to each condition rather than applying one fixed ratio.
What does on-policy self-distillation add?
Simple supervised fine-tuning left a clear quality gap on pruned inputs, so CodecOPSD uses on-policy self-distillation. A frozen teacher model sees the tokens that pruning removed as privileged information and gives dense guidance at every state of the student's own rollout, letting the student match teacher quality with fewer tokens.
Teacher and student share the same base weights; only the LoRA and the available tokens differ. The repository notes that codec pruning alone already works well in many cases, especially on images, while the LoRA preserves quality at more aggressive drop rates.
How fast is CodecOPSD in practice?
The released code reports roughly 70% average condition-token reduction on MiniMax-H3 Ref2VA with about 1.9x faster denoising, and up to 8.4x with heavier pruning. On MiniMax-H3-Image it drops 65% of reference tokens for close to 2x faster denoising. Gains grow with more conditions, longer frames and higher resolution.
All figures below are denoising times on the named GPU, not end-to-end wall time.
| Setting | Hardware | Teacher | With CodecOPSD | Token change |
|---|---|---|---|---|
| 2 images + 3 videos, 768p, 243 frames, 90% video drop | B200 | 1013 s | 121 s (8.4x) | 232k to 24k (-90%) |
| 3 images + 3 videos, 768p, 124 frames, 90% drop | H200 | 731 s | 108 s (6.8x) | 133k to 22k (-83%) |
| 6 references to one image, 1664 x 2496 | H200 | 29.7 s | 9.5 s (3.1x) | 17.3k to 4.0k (-77%) |
| 16 references to one image, 2048 x 3072 | H200 | 302.9 s | 39.6 s (7.6x) | 98.6k to 17.1k (-83%) |
Which models and modalities does CodecOPSD support?
The method was scaled to 16 condition modalities in the authors' own video diffusion model: segmentation, bounding boxes, identity, sketch, edge, depth, surface normal, pose, sparse and dense tracks, blur, grayscale, first-last frame interpolation, continuation, inpainting and outpainting. Released checkpoints target MiniMax-H3 Ref2VA and MiniMax-H3-Image, with extensions listed for Qwen-Image 2.1, FLUX 3 Image Klein and Cosmos 3 Nano.
Loras are published under HikariDawn on Hugging Face, alongside Gradio demos.
Can CodecOPSD run on consumer GPUs?
Yes. Alongside the 80 GB+ workstation path, the repository ships an extreme demo tuned for 12-32 GB cards including RTX 3090, 4090 and 5090. It uses INT8 weights, a four-step adapter, aggressive offload and SageAttention2. On an RTX 5090 a five-second 480p clip completes in about 31 seconds end to end.
The team reports tested support for RTX 4070 (12 GB), RTX 5060 Ti (16 GB) and the 24 GB 3090 and 4090, with roughly 2x faster denoising.
How do I install and run CodecOPSD?
Installation expects Linux x86_64, Python 3.12 and an NVIDIA GPU. The project pins transformers 5.14.1 and imageio-ffmpeg 0.7.0 because the LoRAs were trained against that text encoder and the x264 build is part of pruning. Models download on first use, and a dry-run command lists them before you commit disk space.
git clone https://github.com/Kiteretsu77/CodecOPSD.git && cd CodecOPSD
conda create -n codecopsd python=3.12 -y && conda activate codecopsd
pip install -e ".[app]"
python app.py ref2va # also: ref2image, ref2va_extreme
python -m codecopsd.download --dry-run
The video demo defaults to 480p with a 70% video drop rate; the image demo follows the first reference's aspect ratio. Disk requirements are about 115 GB for video, 104 GB for image and 71 GB for the consumer path.
What are the license and quality limits of CodecOPSD?
The code is free for research use, including commercial research, but commercial deployment requires a separate license from the authors. The underlying MiniMax-H3 weights carry the MiniMax Community License, and the authors note the training code is still being verified.
Treat published speedups as results on named GPUs and settings, not universal guarantees. Quality is described as almost unchanged rather than identical, so visual comparison against the teacher is advisable for production work.
Frequently asked questions about CodecOPSD
These answers address the questions readers most often ask after encountering CodecOPSD: whether it needs training, which GPUs work, how it compares with FlashAttention or quantization, and whether quality truly holds. Keep in mind that the method targets conditioning tokens, so it complements rather than replaces denoiser-side acceleration.
Does CodecOPSD require retraining the base model?
No. Inference uses a small LoRA loaded on top of the released base model; the base weights stay frozen. Codec pruning itself is training-free and can be applied without the LoRA, though the LoRA is what preserves quality at higher drop rates. Training code exists for researchers who want to adapt the approach to other models.
Is CodecOPSD compatible with FlashAttention or quantization?
Yes in principle. The authors explicitly describe token pruning as orthogonal and pluggable into fewer-step sampling, FlashAttention, quantization, feature caching and sparse attention, because those methods change the denoiser while CodecOPSD changes the input. The released demos already combine pruning with FP8 and INT8 weights and SageAttention2.
Does pruning hurt image quality?
The reported results show almost no quality drop at recommended drop rates, and the on-policy distillation step exists specifically to close the gap left by plain fine-tuning. However, the paper's own examples use extreme 90% drops for illustration, and the repository warns that training code is still being checked. Validate on your own references before relying on it.
Bottom line
CodecOPSD is most useful when a workflow stacks many references or long video conditions, where conditioning cost grows fastest. For a single short prompt with one reference, the overhead and disk footprint are unlikely to pay off. It is a research release with a research license, so check permissions before any commercial deployment.