h3.c icon indicating copy to clipboard operation
h3.c copied to clipboard

Feature request: LoRA support

Open dogjamboree opened this issue 3 months ago • 4 comments

Thanks for a great program! It would be great to see LoRA support added.

dogjamboree avatar Aug 16 '26 19:08 dogjamboree

it works in #14 but only for turbo

monotected avatar Aug 18 '26 01:08 monotected

from an M5 Max / 128 GB user. h3.c is the fastest H3 runtime on this machine: Ref2VA at 832×480, 124 frames, 16 steps, BF16, renders in ~4.4 min. The same shot in another runtime, 8-bit with the lightx2v Ref2VA Turbo LoRA at 8 steps, took ~7.75 min. So LoRA support in h3.c would be the best of both.

Two requests:

  • Merging the offline fold approach from #14 (or an equivalent) would already cover this.
  • Please consider the Ref2VA adapters too, not only FL2VA: e.g. lightx2v/Minimax-h3-Turbo minimax_h3_ref2v_turbo_8step_v1.0_768p (split qkv). It needs a video shift of 6 rather than 12, so a --video-shift option (or reading it from the adapter) would be needed alongside the fold.

crashtestoz avatar Oct 05 '26 10:10 crashtestoz

Lawd knows open source just ain't the same without the loras!

Metal native training support would be awesome

openSourcerer9000 avatar Oct 21 '26 01:10 openSourcerer9000

Production data point: LoRA works on h3.c, both runtime-merged and offline-folded.

We run h3.c in a vertical-video production line on M3 Max and needed the MiniMax-H3 Turbo (4-step distilled) adapters. Two approaches, both working:

  1. Runtime merge — a ~300-line C module (h3_lora.c) hooks the loader and merges the ComfyUI generic LoRA format (lora_A/lora_B/alpha, including the fused-QKV block-diagonal trick and the SwiGLU gate/value order) at load time. Costs 45-60s per run, verified bit-exact against a numpy reference on 4096 elements (qkv + fc1 layers).

  2. Offline fold — bake the adapter into a new checkpoint once, then the engine sees a native 4-step model with zero changes. On APFS the clone is copy-on-write (~50s, a couple GB, not a second 40GB model).

Benchmarks (M3 Max 128GB, 480x640, 107 frames, same prompt/seed):

Config Denoise
Base model, 20 steps ~1074 s
Runtime-merged Turbo, 4 step ~189 s
Folded Turbo, 4 step ~85 s
+ layers 40 + reuse 2 ~65 s

End-to-end with load + VAE: ~19 min -> ~2.9 min.

We position the folded checkpoints as a draft/storyboard tool upstream of the official API — the speedup makes "try a few more takes" cheap, rather than claiming parity with the full-quality pipeline. For slow/medium-paced content the 4-step output held up well in our A/B tests, but we treat it as a previz-grade asset, not an end-frame substitute.

The folded checkpoints (MiniMax-H3 Community License — Model Derivatives with the required notices; no weights beyond the documented merge) are distributed on ModelScope (a network-reachability choice, not a platform preference):

  • https://modelscope.cn/models/luckybeet/MiniMax-H3-FL2V-Turbo-4Step
  • https://modelscope.cn/models/luckybeet/MiniMax-H3-Ref2V-Turbo-4Step

with a consumer-side wrapper + recipes at https://github.com/luckybeet/h3-turbo-models

Not opening a PR for now — if you're open to upstreaming LoRA support, we'd happily rework the runtime-merge module to your code conventions (header layout, memory management, build system). The trickiest part is not the math, it's the format traps; happy to document whatever you want to know.

Thanks for h3.c — it runs a 22B video model in unified memory, which still feels like magic.

luckybeet avatar Nov 19 '26 03:11 luckybeet