Skip to content

Add HunyuanVideo ComfyUI LoRA export#1515

Open
Calamdor wants to merge 1 commit into
Nerogar:masterfrom
Calamdor:feature/hyv-comfyui-lora-export
Open

Add HunyuanVideo ComfyUI LoRA export#1515
Calamdor wants to merge 1 commit into
Nerogar:masterfrom
Calamdor:feature/hyv-comfyui-lora-export

Conversation

@Calamdor

Copy link
Copy Markdown
Contributor

Redo of PR #1374

This version focused on using Flux.2 as the template for integration.
100% AI Generated code. More Spec Based programming compared to 1374.
Will close PR #1374

Very simple one way integration of HYV to ComfyUI conversion of Lora files using OneTrainer's Conversion Tool

Adds a one-way OT -> ComfyUI LoRA conversion for HunyuanVideo, exposed in
the Convert tool (Output Format: "Comfy LoRA"). Mirrors Flux2's convert_util
pattern approach.

- convert_hunyuan_video_lora_to_comfyui(): normalizes the input to OMI, then
  fuses OT's split Q/K/V (and single-block Q/K/V/MLP) adapters into the single
  fused projections ComfyUI expects via convert_util.lora_qkv(_mlp)_fusion,
  emitting native diffusion_model.* keys (e.g. double_blocks.N.img_attn.qkv).
  Conditioning/embedder layers are excluded (community convention); raises a
  clear NotImplementedError on DoRA. Uses strict=True so unexpected keys fail
  loudly rather than being silently dropped.
- LoRASaverMixin: single COMFY_LORA case delegating to a new overridable
  _get_comfy_state_dict hook (default raises NotImplementedError), so other
  model types are unaffected.
- HunyuanVideoLoRASaver: overrides the hook to call the converter.
- ConvertModelUI: adds the "Comfy LoRA" output format option.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dxqb

dxqb commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Looks good to me. I want to make this a larger PR though because Comfy has decided to stop supporting diffusers format for more models: Comfy-Org/ComfyUI#14182

The user should be able to choose output format:

  • diffusers format
  • original keys
  • [Comfy format]

For the last 2:
The difference between "original keys" and "Comfy format" would only be the "diffusion_model." prefix. Do you know if this is an invention by Comfy, or where does this come from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview merged in the preview branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants