Skip to content

[LoRA] accept fal Kontext LoRAs whose embedder keys lack the base_model.model. prefix - #14918

Open
christopher5106 wants to merge 3 commits into
huggingface:mainfrom
scenario-labs:fix_fal_kontext_loras
Open

christopher5106 wants to merge 3 commits into
huggingface:mainfrom
scenario-labs:fix_fal_kontext_loras

Conversation

@christopher5106

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #14917

Some fal FLUX.1 Kontext LoRAs store the block keys under base_model.model. but the global embedder keys (time_in, vector_in, txt_in, img_in, guidance_in) without that prefix. _convert_fal_kontext_lora_to_diffusers does not map those keys, so they are left in original_state_dict and loading fails with "original_state_dict should be empty at this point".

This PR maps the unprefixed embedder keys to their diffusers names (time_text_embed.*_embedder.linear_{1,2}, context_embedder, x_embedder) before that check. Files without these keys convert exactly as before.

The reproduction in #14917 fails on main and converts all 1006 keys with this change.

Before submitting

  • Did you use an AI agent (Claude Code, Codex, Cursor, etc.) to help with this PR? Yes, Claude Code.
    • Read the Coding with AI agents guide.
    • Self-review notes, final round:
      • The converter does not map the embedder keys when they do carry the base_model.model. prefix either. I left that case out because I have not seen such a file.
      • Only lora_A / lora_B weights are mapped for the embedders, like the rest of this converter. No bias or alpha keys appear on these modules in the files I have seen.
      • No test added: the change is in a private converter and the layout is third-party, so the reproduction lives in the issue.
  • Did you read the contributor guideline?
  • Was this discussed/approved via a GitHub issue? fal FLUX.1 Kontext LoRAs with unprefixed embedder keys fail in _convert_fal_kontext_lora_to_diffusers #14917, with a CPU-only reproduction.

Who can review?

@sayakpaul @BenjaminBossan

…ase_model.model. prefix

Some fal-kontext LoRAs store time_in / vector_in / txt_in / img_in / guidance_in
without the `base_model.model.` prefix the block keys use, so
`_convert_fal_kontext_lora_to_diffusers` left them in `original_state_dict`
and raised "`original_state_dict` should be empty at this point". Map them to
their diffusers names before that check.

Rebuilt from 02abf7eb1 (2026-04-15) without its Kohya
Flux.2 hunks, which upstream now covers with
`_convert_kohya_flux2_lora_to_diffusers`.
diffusers does not unit-test private converter functions against
third-party checkpoint layouts; the fix is reproducible through
FluxPipeline.lora_state_dict (see the linked issue).

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Do you have an example LoRA checkpoint?

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@christopher5106

christopher5106 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

I was not able to find out how users got this lora.

The unprefixed embedder names do exist in one place: Black Forest Labs' official Control LoRAs. Those use that naming on every key, with no prefix anywhere.

So our users' file mixes two formats. That points to a merged or hand-converted file rather than a trainer's direct output, but nothing confirms it.

│ Source │ Result │
│ fal's Kontext trainer, fal and comfy formats │ Ruled out by training │
│ fal's fast, portrait and turbo FLUX.1 trainers │ Ruled out by training │
│ Our Kohya Kontext trainer, minimal run on dev │ Ruled out: 1,128 tensors under lora_unet_ and lora_te1_, no prefix, no embedders │
│ musubi-tuner │ Ruled out by code: it saves FLUX keys under lora_unet as well │
│ Our own copies of the diffusers converter │ None writes this layout │
│ 2,492 FLUX.1 LoRA repos on the Hub, authenticated scan │ 36 files use the prefix, none has embedder keys

@sayakpaul

Copy link
Copy Markdown
Member

Then how did you come up with this PR if you don't have a real checkpoint?

This branch has not been deployed

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

Labels

fixes-issue lora size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fal FLUX.1 Kontext LoRAs with unprefixed embedder keys fail in _convert_fal_kontext_lora_to_diffusers

3 participants