{"slug": "use-h-264-to-decide-which-tokens-of-video-diffusion-condition-can-skip", "title": "Use H.264 to decide which tokens of video diffusion condition can skip", "summary": "CodecOPSD, a method that uses a video codec to prune redundant condition tokens before the diffusion transformer (DiT) and then trains a small LoRA on the kept tokens via on-policy self-distillation, cut denoising time on MiniMax-H3 Ref2VA from 1013 s to 121 s (8.4x faster) in an extreme setting that pruned 90% of three reference videos' tokens, reducing tokens from 232k to 24k and VLM tokens from 47.7k to 11.0k. The project released inference and training code for MiniMax-H3 Ref2VA and MiniMax-H3-Image on 2026-11-22, published models and Hugging Face Spaces on 2026-11-24 and 2026-11-27, optimized MiniMax-H3 Ref2VA for 12 to 32 GB consumer GPUs (RTX 3090, 4090, 5090) on 2026-11-30, and shipped a ComfyUI integration on 2026-12-02. Other reported speedups include 6.8x on an anime two-shot case (731 s to 108 s), 3.1x on a six-reference desk scene (29.7 s to 9.5 s) and 7.6x on a 16-reference group photo (302.9 s to 39.6 s).", "body_md": "Sequence-wise generators (MiniMax-H3 Ref2VA, MiniMax-H3-Image, Qwen-Image 2.1, FLUX 3 Image Klein) append every\nreference to the sequence, where computation cost grows dramatically.\nWe propose **CodecOPSD** to prune the redundant condition tokens with a video codec, and we train a small LoRA on the\nkept tokens via on-policy self-distillation.\n\nOn average, CodecOPSD drops **consumer GPUs (12 to 32 GB)**: a 5 s 480p video in [Consumer GPUs](#consumer_gpus)).\n\nOn MiniMax-H3-Image, it drops [project page](https://kiteretsu77.github.io/CodecOPSD_website/).\n\n🎬 [Visualization](#visualization) **|** 🔥 [News](#news) **|** 🔧 [Installation](#installation) **|** ⚡ [Quickstart](#quick_start) **|**  [ComfyUI](#comfyui) **|** 🚀 [Inference](#inference) **|** 🧩 [Codec Pruning](#codec_pruning) **|** 🏋️ [Train](#training)\n\n⭐ **If you like CodecOPSD, please help ⭐⭐star⭐⭐ this repo. Thanks!** 🤗\n\n**Teacher** = the released model, every condition token.\n\n**+ CodecOPSD** (student) = the same model with codec pruning and the CodecOPSD LoRA.\n\nEverything else is the same; only the number of condition tokens differs. Times are denoising times.\n\n**Silver wolf in a dusk desert**: 2 pictures + 3 videos → 768p, 243 frames, Pika H3 Flex 6 steps, B200.\n\n<sub>Extreme setting: 90% of the three videos' tokens pruned, in the DiT and in the VLM.</sub>\n\n| Teacher (all tokens) <sub>1013 s</sub> | **+ CodecOPSD** :**8.4x faster**<sub>121 s · tokens 232k → 24k (−90%) · VLM 47.7k → 11.0k (−77%)</sub> | \n|---|---|\n\n**Anime duel in two shots**: 3 pictures + 3 videos → 768p, 124 frames, Pika H3 Flex 6 steps, H200.\n\n<sub>Extreme setting: 90% of the two effect videos' tokens pruned, in the DiT and in the VLM.</sub>\n\n| Teacher (all tokens) <sub>731 s</sub> | **+ CodecOPSD** :**6.8x faster**<sub>108 s · tokens 133k → 22k (−83%)</sub> | \n|---|---|\n\n**H3 Ref2VA Gallery** (click to open it)\n\n**6 references -> 1 desk scene**: 6 pictures -> image (distilled 6 steps), 1664 x 2496, 1x H200. Put the \"laptop\",\n\"lamp\", \"plant\", \"mug\", and \"headphones\" onto the \"desk\" in the evening, in the same camera view, with a \"CodecOPSD\"\nlogo printed on the mug.\n\n| Teacher (all tokens) <sub>29.7 s</sub> | **+ CodecOPSD** :**3.1x faster**<sub>9.5 s · tokens 17.3k → 4.0k (−77%)</sub> | \n|---|---|\n\n**16 references -> 1 group photo**: 16 pictures -> image (distilled 6 steps), 2048 x 3072, 1x H200\n\n| Teacher (all tokens) <sub>302.9 s</sub> | **+ CodecOPSD** :**7.6x faster**<sub>39.6 s · tokens 98.6k → 17.1k (−83%)</sub> | \n|---|---|\n\n**H3-Image Gallery** (click to open it)\n\nCodec pruning drops the redundant condition tokens of every reference before the DiT, and the student LoRA is distilled on its own rollouts from the teacher, which sees every condition token:\n\n- **2026-11-22** : Code release: inference and training of CodecOPSD for MiniMax-H3 Ref2VA and MiniMax-H3-Image, one-line\ninference, and Gradio demos.\n- **2026-11-23** :[Project page](https://kiteretsu77.github.io/CodecOPSD_website/) with the Ref2VA and image galleries.\n- **2026-11-24** : H3-Ref2VA on Hugging Face:[model](https://huggingface.co/HikariDawn/CodecOPSD-H3-Ref2VA) and[Space](https://huggingface.co/spaces/HikariDawn/CodecOPSD-H3-Ref2VA) .\n- **2026-11-27** : H3-Image on Hugging Face:[model](https://huggingface.co/HikariDawn/CodecOPSD-H3-Image) and[Space](https://huggingface.co/spaces/HikariDawn/CodecOPSD-H3-Image) .\n- **2026-11-30** : Fully optimized MiniMax-H3 Ref2VA for edge GPUs (12 to 32 GB): see[Consumer GPUs](#consumer_gpus) .\n- **2026-12-02** : CodecOPSD in ComfyUI on its native MiniMax-H3 Ref2VA, with example workflows: see[ComfyUI](#comfyui) .\n-  [ComfyUI version](#comfyui)\n- Check the training code\n- Extend to Cosmos 3 Nano\n- Extend to Qwen-Image 2.1\n- Extend to FLUX 3 Image Klein\n\nLinux x86_64, Python 3.12, and an NVIDIA GPU with 80 GB or more (141 GB or more keeps every model on the GPU). On a\n12 to 32 GB GPU with 64 GB of CPU memory, optimized for the RTX 3090, 4090 and 5090, video runs at 480p: see\n[Consumer GPUs](#consumer_gpus).\n\n```\ngit clone https://github.com/Kiteretsu77/CodecOPSD.git && cd CodecOPSD\nconda create -n codecopsd python=3.12 -y && conda activate codecopsd\npip install -e \".[app]\"                 # PyTorch 2.8, diffusers 0.43, transformers 5.14.1; [app] adds Gradio\n```\n\n- `transformers` 5.14.1 and`imageio-ffmpeg` 0.7.0 are pinned: the LoRAs were trained on that text encoder's vision\nfeatures, and the x264 build is part of codec pruning.\n- The models download on first use (see [Quick Start](#quick_start) );`python -m codecopsd.download` downloads them ahead\n(`--dry-run` lists them and their sizes).\n\nWe also built a demo optimized for Hugging Face Spaces:\n[CodecOPSD-H3-Ref2VA](https://huggingface.co/spaces/HikariDawn/CodecOPSD-H3-Ref2VA) generates a 5-second 480p video\nfrom multiple reference pictures and videos in about 30 seconds end to end.\n\n**Video:** MiniMax-H3 [Pika H3 Flex](https://huggingface.co/Pika-Labs/Pika-H3-Flex), 6 steps\n\n```\npython app.py ref2va\n```\n\n**Image:** MiniMax-H3 \n\n```\npython app.py ref2image\n```\n\n **:** MiniMax-H3 Ref2VA, optimized for RTX 3090, 4090 and 5090\n\n```\npython app.py ref2va_extreme\n```\n\nSupports 12 to 32 GB GPUs: tested on the RTX 4070 (12 GB), RTX 5060 Ti (16 GB), RTX 3090 and 4090 (24 GB), and RTX 5090 (32 GB).\n\nOn an \n\nEvery demo prints a public link when it starts: open it and click an example. The first launch downloads the models.\n\nWhat the extreme app has ([docs/consumer_gpus.md](https://github.com/Kiteretsu77/CodecOPSD/blob/main/docs/consumer_gpus.md)):\n\n- INT8 MiniMax-H3 Ref2VA ([Comfy-Org](https://huggingface.co/Comfy-Org/MiniMax-H3) ) with the 4-step[pi-H3](https://huggingface.co/Lakonik/pi-H3) adapter\n- TAEH3 encoder and [Sol-H3-VAE](https://huggingface.co/Efficient-Large-Model/Sol-H3-VAE) decoder\n- Automatic GPU memory plans with per-request block streaming\n- Page-locked CPU offload\n- [SageAttention2](https://github.com/thu-ml/SageAttention) (when installed), fused Triton kernels, INT8 and FP8 kernels\nper RTX generation\n- Optional audio\n\n## Model weights and storage, demo options\n\n| Demo | GPU | CPU memory | Disk | \n|---|---|---|---|\n| Video | 80 GB or more | 128 GB | 115 GB | \n| Image | 80 GB or more | 128 GB | 104 GB | \n| Consumer GPUs | 12 to 32 GB | 64 GB | 71 GB | \n\n- Weights go to `models/` (a symlink to a larger disk works): the released models at pinned revisions, our LoRAs and\nexamples from[CodecOPSD-H3-Ref2VA](https://huggingface.co/HikariDawn/CodecOPSD-H3-Ref2VA) and[CodecOPSD-H3-Image](https://huggingface.co/HikariDawn/CodecOPSD-H3-Image) . All three demos share the FP8 VLM and\ntake 212 GB together;`python -m codecopsd.download --dry-run` lists every file.\n- `--no-share` : a local page only;`--no-download` : no downloads.\n- \"Where the time went\" under each result lists the stages; outputs/app/stats.jsonl keeps one line per run.\n\nCodecOPSD also runs in ComfyUI on its native MiniMax-H3 Ref2VA, as sample code for Linux. It changes only\n\n1. \n$\\color{#1a7f37}{\\boldsymbol{\\mathsf{MiniMax\\ H3\\ Reference\\ to\\ Video\\ with\\ CodecOPSD}}}$ : our reference encode, with codec pruning on the references.\n2. \n$\\color{#1a7f37}{\\boldsymbol{\\mathsf{CodecOPSD\\ LoRA}}}$ : our LoRA on the reference rows, and the drop of the pruned tokens before the DiT.\n\n- **Works on:** RTX 3080 Ti, RTX 4070 / 4070 SUPER / 4070 Ti / 4070 Ti SUPER, RTX 4080 / 4080 SUPER, RTX 4090,\nRTX 5060 Ti 16 GB, RTX 5070 / 5070 Ti, RTX 5080, RTX 5090 (12-32 GB GPU memory)\n- **Min CPU memory requirement:** 32 GB\n\nInstructions are in [comfyui/README.md](https://github.com/Kiteretsu77/CodecOPSD/blob/main/comfyui/README.md).\n\n**Video:** MiniMax-H3 \n\n``` php\n# a bundled example -> outputs/\npython inference/generate.py minimax_h3_ref2va --example dog_frisbee\n\n# your own inputs: <Picture 1>, <Picture 2>, <Video 1> in the prompt are the references in order\npython inference/generate.py minimax_h3_ref2va --prompt-file prompt.txt \\\n    --reference man.jpg --reference street.jpg --reference camera.mp4 --out out.mp4\n```\n\nOn a 12 to 32 GB GPU: `python inference/generate.py minimax_h3_ref2va_extreme` ([Consumer GPUs](https://github.com/Kiteretsu77/CodecOPSD/blob/main/docs/consumer_gpus.md)).\n\n## Python, settings, bundled examples\n\n``` python\nimport torch\nfrom diffusers.utils import export_to_video\nfrom codecopsd import MiniMaxH3CodecOPSDPipeline\nfrom codecopsd.pipelines.minimax_h3_ref2va import load_reference\n\npipe = MiniMaxH3CodecOPSDPipeline.from_minimax_h3(\n    \"models/MiniMax-H3-Ref2VA\", text_encoder_fp8=\"fp8\",\n    text_encoder_path=\"models/MiniMax-H3-ModelOpt-Mixed9-Dynamic-FP8/Ref2VA/text_encoder\")\npipe.load_condition_lora(\"HikariDawn/CodecOPSD-H3-Ref2VA\", weight_name=\"codecopsd_minimax_h3_ref2va.safetensors\")\npipe.enable_model_cpu_offload()\n\nvideo = pipe(\n    prompt=\"The golden retriever from <Picture 1> chases and catches a flying red frisbee on the park lawn of \"\n           \"<Picture 2>, running like the dog in <Video 1>. The camera tracks the dog.\",\n    references=[load_reference(f) for f in [\"dog.jpg\", \"park.jpg\", \"dog_running.mp4\"]],\n    generator=torch.Generator().manual_seed(42),\n).frames[0]\nexport_to_video(video, \"output.mp4\", fps=24)\n```\n\n| Setting | Flag | Default (as the demo) | \n|---|---|---|\n| Output size, height x width | `--height` ,`--width` | 480 x 832 (480p); 768 x 1344 = 768p | \n| Frames, 24 fps, 17n + 5 | `--frames` | 124 (5.2 s), up to 243 | \n| Seed | `--seed` | 42 | \n| Sampler | `--sampler` | `pika` : Pika H3 Flex, 6 steps (`base` : 50 steps) | \n| Video references | `--video-drop` | `0.7` : drop 70 % (recommended) | \n| Codec thresholds, videos | `--video-thresholds MOTION_PX RESIDUAL` | 5.0 1.0 | \n| Codec thresholds, pictures | `--picture-thresholds MOTION_PX RESIDUAL` | 4.0 1.5 | \n| Text encoder pruning | `--vlm-drop` ,`--vlm-scale` | pictures: the thresholds x 0.25; videos: the transformer's tokens | \n| Text encoder weights | `--text-encoder` | `fp8` | \n| Attention | `--attention` | `auto` : cuDNN on H100 / H200 / B200, SDPA on A100 | \n| GPU placement | `--offload` | `auto` : every model on the GPU from 150 GB, else one at a time | \n| GPU memory | `--gpu-memory` | the GPU's own; a smaller number caps the process to it, to check that a run fits | \n| Time per stage | `--stats` | off: prints where the seconds went, stage by stage | \n| Mode | `--mode` | `compress` : CodecOPSD (`baseline` : the teacher, every token) | \n\nBundled video examples: every folder in `assets/examples/minimax_h3_ref2va/` (`dog_frisbee`, `dolly_zoom_desert`, `wolf`,\n`candy`, `deep_sea`, `qinglong`, `blanket`, ...).\n\n**Image:** MiniMax-H3 \n\n``` php\n# a bundled example -> outputs/\npython inference/generate.py minimax_h3_image --example desk_setup_edit\n\n# your own inputs: <Picture 1>, <Picture 2> in the prompt are the images in order\npython inference/generate.py minimax_h3_image --prompt \"Put the lamp <Picture 1> on the desk in <Picture 2>.\" \\\n    --image lamp.jpg --image desk.jpg --out out.png\n```\n\n## Python, settings, bundled examples\n\n``` python\nimport torch\nfrom PIL import Image\nfrom codecopsd import MiniMaxH3ImageCodecOPSDPipeline\n\npipe = MiniMaxH3ImageCodecOPSDPipeline.from_minimax_h3_image(\n    \"models/MiniMax-H3-Image\", text_encoder_fp8=\"fp8\",\n    text_encoder_path=\"models/MiniMax-H3-ModelOpt-Mixed9-Dynamic-FP8/Ref2VA/text_encoder\")\npipe.load_condition_lora(\"HikariDawn/CodecOPSD-H3-Image\", weight_name=\"codecopsd_minimax_h3_image.safetensors\")\npipe.enable_model_cpu_offload()\n\nimage = pipe(\n    prompt=\"Put the lamp <Picture 1> on the desk in <Picture 2>.\",\n    images=[Image.open(\"lamp.jpg\"), Image.open(\"desk.jpg\")],\n    generator=torch.Generator().manual_seed(42),\n).images[0]\nimage.save(\"output.png\")\n```\n\n| Setting | Flag | Default (as the demo) | \n|---|---|---|\n| Output size, height x width | `--height` ,`--width` | the first picture's aspect ratio on the 2048 x 2048 area | \n| Steps |  | the released 6-step grid | \n| Seed | `--seed` | 42 | \n| Codec thresholds, pictures | `--picture-thresholds MOTION_PX RESIDUAL` | 4.0 1.5 (the residual threshold falls with the short side above 1024 px) | \n| Text encoder pruning | `--vlm-drop` ,`--vlm-scale` | the picture thresholds x 0.25 | \n| Text encoder weights | `--text-encoder` | `fp8` | \n| Attention | `--attention` | `auto` : cuDNN on H100 / H200 / B200, SDPA on A100 | \n| GPU placement | `--offload` | `auto` : every model on the GPU from 150 GB, else one at a time | \n| Mode | `--mode` | `compress` : CodecOPSD (`baseline` : the teacher, every token) | \n\nBundled image examples: every folder in `assets/examples/minimax_h3_image/` (`desk_setup_edit`, `product_poster`,\n`farm_barn`, `lineart_to_photo`, ...).\n\n## Every extra acceleration (on by default), few-step samplers\n\nOn top of CodecOPSD (codec pruning and the CodecOPSD LoRA), every item below is merged into this repo and on by default:\n\n- Text encoder (VLM) pruning: it reads the kept vision tokens\n- Few-step sampler: Pika H3 Flex, 6 steps\n- FP8 text encoder\n- Video VAE decoder in bf16\n- AdaLN as per-timestep tables: less GPU memory, same output\n- Attention kernel per GPU: cuDNN on H100 / H200 / B200, SDPA on A100\n- GPU placement: every model resident from 150 GB, else model offload or block streaming (`--offload` )\n- 12 to 32 GB GPUs: the extreme path with its own transformer choices ([Consumer GPUs](https://github.com/Kiteretsu77/CodecOPSD/blob/main/docs/consumer_gpus.md) )\n\n| `--sampler` | Files (next to `MiniMax-H3-Ref2VA/` ) | Steps | \n|---|---|---|\n| `pika` (default) | [Pika H3 Flex](https://huggingface.co/Pika-Labs/Pika-H3-Flex)`Pika-H3-Flex/ref2va/adapter.safetensors` | 6 | \n| `base` (baseline) | none | 50 | \n\nPika H3 Flex reproduces its release bit for bit. Codec pruning runs on the CPU while the GPU encodes the same references with the VAE, so it always finishes first; latents, masks, and text embeddings are bit-identical in every GPU placement.\n\nCodec pruning decides, before the model runs, which condition tokens to drop: it re-encodes each reference with H.264 and drops the tokens the encoder spends neither motion nor residual on. It reads pixels alone (no model, no GPU) and runs on the CPU while the VAE encodes, so it adds no time.\n\nIt is also a training-free design: on the released models without the LoRA, codec pruning already provides good results in many cases, especially on images. The CodecOPSD LoRA keeps the teacher's quality at larger drops.\n\nThe mask decides which condition tokens the model reads. Two modes: **threshold** keeps a token when the codec spends\nmotion or residual on it, so the drop follows the content; **priority drop** drops a fixed share of a video's tokens,\nthe least informative first. Everything below is already the default, so nothing needs tuning.\n\n**Pictures and general videos** (MiniMax-H3 Ref2VA and MiniMax-H3-Image): the settings we ship and find stable.\n\n| Condition | Mode | Setting | \n|---|---|---|\n| Pictures | threshold | a fixed residual threshold (default `--picture-thresholds 4.0 1.5` ); the VLM uses 0.25 x the thresholds and keeps more of each picture, where we observed closer facial similarity (default`--vlm-scale 0.25` ) | \n| General videos (RGB footage) | priority drop | drop 70 %, the most stable (default `--video-drop 0.7` ); 66 to 75 % also work, lower for strong camera motion or busy scenes; the VLM reuses the same mask (default) | \n\n**Condition videos** (sketch, surface normal, depth, edge, ...): the threshold, for an almost lossless drop (the\noutput stays as close to the full-token one as a change of seed). Regular conditions share one setting; sparse marks\nget lower thresholds so that their small moving parts stay. Pass the `kind` to `drop_mask` (all in\n[`codec_pruning.yaml`](https://github.com/Kiteretsu77/CodecOPSD/blob/main/src/codecopsd/configs/codec_pruning.yaml), `conditions`):\n\n| Condition | `kind` | Motion px / residual | Why | \n|---|---|---|---|\n| Regular: sketch, surface normal, depth, edge, segmentation, human pose, dense tracks, grayscale, inpainting, outpainting, given frames | `\"video\"` (default) | 5 / 1.0 | dense maps | \n| Motion tracks | `\"motion_track\"` | 1 / 0.5 | small markers that move a little | \n| Boxes | `\"bbox\"` | 1 / 0.1 | flat shapes, only the corners move | \n| Blur, low resolution | `\"degradation\"` | 5 / 1.0, x264 preset veryfast | a finer motion search on degraded footage | \n\nMotion px at 480 x 640, scaled with the size. Flags and Python calls: [docs/mask_settings.md](https://github.com/Kiteretsu77/CodecOPSD/blob/main/docs/mask_settings.md).\n\nPrune the tokens of any condition in a few lines (`python inference/test_drop_mask.py` checks it):\n\n``` python\nimport torch\nfrom codecopsd.codec_pruning import drop_mask\n\nvideo = torch.rand(124, 3, 480, 832) * 2 - 1   # a condition video [T, 3, H, W], float in [-1, 1] or uint8\npicture = torch.rand(3, 1536, 1536) * 2 - 1    # a condition picture [3, H, W]\n\ndropped = drop_mask(video, drop=0.7)           # bool [37, 15, 26] = [T', H / 32, W / 32], True = drop\ndropped = drop_mask(video)                     # no rate: the threshold decision\ndropped_picture = drop_mask(picture)           # bool [1, 48, 48]; pictures use the threshold decision\n\ntokens = torch.randn(*dropped.shape, 64)       # your condition tokens on the same grid [T', H / 32, W / 32, C]\nkept = tokens[~dropped]                        # [N_kept, C]: give these to the model\npositions = (~dropped).nonzero()               # [N_kept, 3]: their (t, h, w) positions, for the rotary embedding\n```\n\nThe token grid follows MiniMax-H3's VAE (32 x 32 pixels per token); for another VAE, see\n[docs/codec_pruning.md](https://github.com/Kiteretsu77/CodecOPSD/blob/main/docs/codec_pruning.md).\n\n📄 **Documents**: [codec pruning in your own model](https://github.com/Kiteretsu77/CodecOPSD/blob/main/docs/codec_pruning.md) **|** [mask settings](https://github.com/Kiteretsu77/CodecOPSD/blob/main/docs/mask_settings.md)\n**|** [training](https://github.com/Kiteretsu77/CodecOPSD/blob/main/docs/training.md) **|** [consumer GPUs](https://github.com/Kiteretsu77/CodecOPSD/blob/main/docs/consumer_gpus.md)\n\n## Repo layout\n\n```\napp.py                            the Gradio demos: python app.py ref2va | ref2va_extreme (the default) | ref2image\ninference/\n  generate.py                     one-line inference of every model (bundled examples or your own inputs)\n  cli/                            each model's command line: minimax_h3_ref2va.py, minimax_h3_ref2va_extreme.py,\n                                  minimax_h3_image.py, cosmos3.py\n  demo/                           the Gradio demo, one module per part (demo/__init__.py lists them)\n  load.py                         the models, building a pipeline, offload (shared)\n  extreme/                        the consumer GPU path only (app.py ref2va_extreme): transformer choices (pi-H3,\n                                  Pika H3 Flex, HyperFlow H3 Flash), memory plans, INT8 and fused kernels,\n                                  SageAttention2, TAEH3, the Sol-H3-VAE decoder\n  hardware.py                     the GPU, CPU memory and kernels of this machine (python -m inference.hardware)\n  examples.py, utils.py           the bundled examples' flags; dropped-token counts, run summary lines\n  vlm_fp8.py                      saves the FP8 VLM once from the bf16 release (python -m inference.vlm_fp8)\n  test_drop_mask.py               drop_mask on synthetic inputs (CPU, about 20 s)\nassets/examples/                  bundled examples: <model>/<name>/example.json + prompt.txt (media downloaded on first use)\ndocs/                             codec_pruning.md, mask_settings.md, training.md, consumer_gpus.md\nsrc/codecopsd/\n  codec_pruning/                  codec pruning: drop_mask, submit_prune, README\n  configs/                        every setting, commented (codec_pruning.yaml: the thresholds and the priority drop)\n  download.py                     the first-use download into models/ and assets/examples/refs/\n  attention.py                    attention kernels of the transformer\n  offload.py                      pinned model offload, layer streaming\n  stats.py                        where the seconds of a request go, stage by stage\n  models/                         condition-row LoRA transformers, FP8 linears\n  pipelines/minimax_h3_ref2va/    Ref2VA (reference to video): MiniMaxH3CodecOPSDPipeline, few-step samplers, VLM drop\n  pipelines/minimax_h3_image/     reference to image: MiniMaxH3ImageCodecOPSDPipeline\nscripts/\n  train_minimax_h3_ref2va.py      training for MiniMax-H3 Ref2VA (encode, train)\n  train_minimax_h3_image.py       training for MiniMax-H3-Image (encode, train)\n  convert_minimax_h3_lora.py      training checkpoint -> LoRA (.safetensors), both models\n  download_examples.py            the bundled examples' media into assets/examples/refs/\n```\n\nWarning\n\n**Need more check.** The training code and its guide are still being verified.\n\nSample training code for 4 GPUs, for MiniMax-H3-Image and MiniMax-H3 Ref2VA: [docs/training.md](https://github.com/Kiteretsu77/CodecOPSD/blob/main/docs/training.md).\n\nThe CodecOPSD code is free for research: anyone, companies included, may use, modify and share it for research and\npublish papers and results built on it. Commercial use needs a license from us: please contact TODO. Full terms:\n[LICENSE](https://github.com/Kiteretsu77/CodecOPSD/blob/main/LICENSE).\n\nThe models keep their own licenses: MiniMax-H3, MiniMax-H3-Image, and the weights built on them (the CodecOPSD LoRAs,\nPika H3 Flex, pi-H3, Comfy-Org's INT8 MiniMax-H3, HyperFlow H3 Flash) are under the MiniMax Community License\n([MiniMax-H3](https://huggingface.co/MiniMaxAI/MiniMax-H3/blob/main/LICENSE),\n[MiniMax-H3-Image](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image/blob/main/LICENSE)).\n`inference/extreme/models/hyperflow_flash/` and `inference/extreme/models/int8.py` are HyperFlow H3 Flash's model\ncode, under its own Apache 2.0 License (Video Rebirth, [hyperflow-h3-flash](https://github.com/Video-Rebirth/hyperflow-h3-flash)).\n\nUsers are responsible for their use of the code, the models, and the generated content, and should follow the applicable laws and the licenses above. The authors are not responsible for any misuse.\n\n```\n@article{wang2026codecopsd,\n  title   = {On-Policy Codec Distillation for Efficient All-in-One Video Generation},\n  author  = {Wang, Boyang and Blackburn-Matzen, Kevin and Saha, Oindrila and Gadelha, Matheus and Cheng, Zezhou},\n  journal = {arXiv preprint arXiv:2611.31184},\n  year    = {2026}\n}\n```\n\nWe thank MiniMax for [MiniMax-H3](https://huggingface.co/MiniMaxAI/MiniMax-H3) and\n[MiniMax-H3-Image](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image), Pika for\n[Pika H3 Flex](https://huggingface.co/Pika-Labs/Pika-H3-Flex), Lakonik for [pi-H3](https://huggingface.co/Lakonik/pi-H3),\nComfy-Org for the [INT8 MiniMax-H3](https://huggingface.co/Comfy-Org/MiniMax-H3), and Video Rebirth for\n[HyperFlow H3 Flash](https://huggingface.co/VideoRebirthAI/hyperflow-h3-flash). Our code builds on\n[diffusers](https://github.com/huggingface/diffusers), and codec pruning uses FFmpeg and x264.", "url": "https://wpnews.pro/news/use-h-264-to-decide-which-tokens-of-video-diffusion-condition-can-skip", "canonical_source": "https://github.com/Kiteretsu77/CodecOPSD", "published_at": "2026-12-03 03:12:53+00:00", "updated_at": "2026-12-03 03:16:46.783541+00:00", "lang": "en", "topics": ["generative-ai", "ai-research", "ai-tools", "computer-vision", "ai-infrastructure"], "entities": ["CodecOPSD", "MiniMax-H3 Ref2VA", "MiniMax-H3-Image", "Qwen-Image 2.1", "FLUX 3 Image Klein", "ComfyUI", "Hugging Face", "Cosmos 3 Nano"], "also_reported_by": [], "takeaway": "CodecOPSD prunes up to 90% of reference-video condition tokens with a video codec and distills a LoRA on the kept tokens, cutting MiniMax-H3 Ref2VA denoising from 1013 s to 121 s (8.4x) and tokens from 232k to 24k.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/use-h-264-to-decide-which-tokens-of-video-diffusion-condition-can-skip", "markdown": "https://wpnews.pro/news/use-h-264-to-decide-which-tokens-of-video-diffusion-condition-can-skip.md", "text": "https://wpnews.pro/news/use-h-264-to-decide-which-tokens-of-video-diffusion-condition-can-skip.txt", "jsonld": "https://wpnews.pro/news/use-h-264-to-decide-which-tokens-of-video-diffusion-condition-can-skip.jsonld"}}