Skip to content

[LoRA] strip the stale text_model. prefix from Kohya CLIP text-encoder LoRAs on transformers >= 5.6 - #1

Closed
christopher5106 wants to merge 1 commit into
mainfrom
fix_clip_text_model_prefix
Closed

christopher5106 wants to merge 1 commit into
mainfrom
fix_clip_text_model_prefix

Conversation

@christopher5106

@christopher5106 christopher5106 commented Sep 30, 2026 •

Copy link
Copy Markdown

Upstream: fixed upstream by huggingface#14872, another contributor's PR merged on 2026-09-28, which applies the same text_model. strip. The bug is huggingface#13984. This branch is now redundant: it is due for deletion, and this PR will be closed at the next re-sync.

Problem: transformers 5.6 flattened CLIPTextModel, so its modules are no longer nested under text_model.. Loading a Kohya FLUX.1 LoRA that carries CLIP text-encoder weights (lora_te1_* keys) still produces text_model.-prefixed names, matches no module, and fails with an IndexError on an empty rank.

Change: lora_base.py strips the stale text_model. prefix when the text encoder has no such submodule (8 lines).

Test: test_kohya_clip_text_encoder_lora_under_flattened_clip in tests/pipelines/flux/test_pipeline_flux.py fails without the patch and passes with it.

In scenario: yes, cherry-picked.

This PR documents a fix branch of this fork and is not meant to be merged. It is closed once the change is merged upstream, and the branch is then deleted.

…t-encoder LoRAs on transformers >= 5.6

transformers 5.6 flattened CLIPTextModel, so named_modules() no longer yields
`text_model.*` names while kohya-converted FLUX LoRAs still carry that prefix.
The rank dict came out empty and _create_lora_config raised IndexError
(huggingface#13984). Upstream closed the fix (huggingface#14029) wanting a
general solution; this carries it on the scenario branch until one lands.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 4148971)
@christopher5106
christopher5106 deleted the fix_clip_text_model_prefix branch September 30, 2026 11:27
@christopher5106

Copy link
Copy Markdown
Author

Merged upstream as huggingface#14872. The branch is deleted and scenario is rebased without it.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant