Skip to content

fix(lora): only drop adapter from _merged_adapters when unfused from all components - #14385

Open
AloysJehwin wants to merge 2 commits into
huggingface:mainfrom
AloysJehwin:fix/unfuse-lora-merged-adapters-sync
Open

fix(lora): only drop adapter from _merged_adapters when unfused from all components#14385
AloysJehwin wants to merge 2 commits into
huggingface:mainfrom
AloysJehwin:fix/unfuse-lora-merged-adapters-sync

Conversation

@AloysJehwin

Copy link
Copy Markdown

Fixes #14214

When unfuse_lora(components=[...]) is called with a subset of components, the current code removes the adapter from _merged_adapters as soon as it's unfused from the first component — even if it's still physically fused into the others. So num_fused_loras/fused_loras report nothing fused while the remaining components silently still have the LoRA baked in.

The fix: call module.unmerge() as before, then recompute _merged_adapters by scanning all loadable components for adapters that are still physically merged (via BaseTunerLayer.merged_adapters). That way the set only loses an adapter once it's gone from everything.

Verified with the reproduction script from the issue — num_fused_loras correctly stays at 1 after unfusing only text_encoder, and the unet is confirmed still merged at the PEFT level.

…all components

Signed-off-by: Aloys Jehwin <aloysjehwin@gmail.com>
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.

unfuse_lora(components=[...]) desyncs _merged_adapters/num_fused_loras from actual per-component PEFT merge state

1 participant