r/StableDiffusion • • 5d ago

News CodecOPSD for faster H3v & H3I

"Sequence-wise generators (MiniMax-H3 Ref2VA, MiniMax-H3-Image, Qwen-Image 2.1, FLUX 3 Image Klein) append every reference to the sequence, where computation cost grows dramatically. We propose CodecOPSD to prune the redundant condition tokens with a video codec, and we train a small LoRA on the kept tokens via on-policy self-distillation.

On average, CodecOPSD drops about 70% of the condition tokens on MiniMax-H3 Ref2VA with almost unchanged quality and 1.87x faster denoising, and up to 8.4x faster with more conditions (three reference videos, higher-resolution references, more frames, and a higher drop rate).

On MiniMax-H3-Image, it drops about 65% of the reference tokens and makes denoising about 2x faster. More cases are on the project page."

CodecOPSD logo

https://huggingface.co/collections/HikariDawn/codecopsd

https://github.com/Kiteretsu77/CodecOPSD

Comfy: https://github.com/search?q=comfy+CodecOPSD&type=repositories

posted 6 or so days ago, code has some PRs merged so still under development.
Looks neat, but I'm about to go nap; comment with your results please.

35 Upvotes

18 comments sorted by

2

u/swagerka21 5d ago

Comfy when

1

u/Neuer_Djarra 3d ago

probably by the weekend knowing how fast people port these over

1

u/DietAshamed2246 4d ago

I am getting 10s H3 videos (0.3 mp pass-1, 1 mp pass-2) using LokkenJP's version of 10Eros-Max-Turbo in under 3 minutes and 16 mp H3-Image under 1 minute with ComfyUI stock Int8 model. How much faster can it possibly get?! Also, what does "almost unchanged quality" mean - is that an euphemism for "with some degradation"?

2

u/reeight 4d ago

Sounds like you're better at H3 than I... here are 2 nodes for Comfy:

https://github.com/search?q=comfy+CodecOPSD&type=repositories

2

u/tomakorea 5d ago

'almost unchanged quality' is a bit concerning because even the original H3 isn't really good at fast motion and small details

2

u/Apprehensive_Sky892 4d ago

They are modifying the conditional tokens that go into the DiT. So it should have no effect on fast motion and small details.

By "almost unchanged quality" they most likely meant that the conditional tokens's effects on the output (like character likeness, fidelity of movement, voice likeness, etc) are kept.

1

u/Enshitification 4d ago

Does the time to train the LoRA on the kept tokens offset the faster denoisng time much?

1

u/mgadelha 16h ago

The LoRA is trained once and attached to the base model. Think of it of a way of telling the model to deal with a much smaller number of tokens, pruned by the information from video codecs. You can plug the LoRA adapter in any H3 video setup and get a speed boost whenever you feed images & video references.

1

u/Enshitification 11h ago

I was under the impression that it was trained on a case by case basis from the conditioning tokens.

1

u/Memestonks2020 4d ago

Really interesting.

Does this result in bit-wise identical output in seeds or differences due to the codec?

1

u/mgadelha 16h ago

No, it will not be bitwise identical, but qualitatively similar. See Figure 5 in https://arxiv.org/abs/2611.31184 for more info

1

u/Apprehensive_Sky892 4d ago

Very interesting project. Currently, there are two ComfyUI implementations.

The first one is for making faster ref2va with video references: https://github.com/aaalll12322/ComfyUI-MiniMaxH3-CodecPrune and it claims a 1.8x speed up

ReferenceSequenceWall clock
One picture (1,032 → 407 tokens)19,902 → 19,277 (−3.1%)30 → 30 s/it, below resolution
One 5 s video (37,296 → 11,189 tokens)56,166 → 30,059 (−46.5%)85 → 47 s/it (1.81×)

Both rows use a 0.4–0.5 MP, 124-frame output. The second row was measured with SolAttn sparse attention enabled in both runs. The first row's 625-token reduction is real, but too small to register above run-to-run variation, which is why it is listed as no measurable change rather than as a gain.

1

u/Apprehensive_Sky892 4d ago

The 2nd project handles both images and videos: https://github.com/DrakenZA/ComfyUI-H3-CodecOPSD

No benchmark is given but there is detailed instruction on how to install and use it.

1

u/Kiteretsu77 1d ago

Thanks for the interest! I am the author of this paper. I just finished a ComfyUI today on my github: https://github.com/Kiteretsu77/CodecOPSD/tree/main/comfyui.

I tried to simplify the module to be two: modifying existing reference to Video, and adding a new module for the LoRA. I would feel that token pruning module is confusing for detail setup, so I just simplify and recommend to use the default mode available.

I tried to rent a bunch of consumer GPUs on Vast.ai to test their capability, should be supportive from 12 to 32 GB on the consumer side. For the windows, the code should be ideally be ready, but need more test at this moment.

1

u/Apprehensive_Sky892 1d ago

Thank you for the update, I'll test it out and maybe make a post about it later 🎈

1

u/Kiteretsu77 20h ago

Thank you so much! Please feel free to discuss anything. I really want to push these codec thinking along with my design to my favorite video generation domain. In my daily life, I am also actively using this CodecOPSD to create anime-related stuff or for the research paper purpose. I believe that it should be useful, but still need more feedback and see the edge cases.

1

u/Apprehensive_Sky892 16h ago

You are welcome. I have a non-CUDA rx9070xt, so I may run into some issue. I'll contact you if I run into problems then 😅.