Repository navigation
[diffusion] fix: keep a LoRA unmerged under merge_mode auto when merging would round its update away - #43385
Merged
mickqian merged 4 commits intoOct 10, 2026
Conversation
…ing would round its update away Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mickqian
requested review from
AgainstEntropy,
BBuf,
HaiShaw,
kevin-mii,
niehen6174,
wisclmy0611,
yichiche and
zijiexia
as code owners
October 9, 2026 13:56
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
…yle LoRAs keep merging Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the LoRA update CI's style LoRAs lose 14% (Wan Arcane-Jinx) and 31% (Z-Image anime) in a BF16 merge and pay up to +50% per step on the dynamic path, while distilled adapters such as MiniMax-H3 Turbo lose 75%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 tasks done
mickqian
deleted the
mick/diffusion-lora-auto-dynamic-when-merge-rounds
branch
October 10, 2026 07:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
--lora-merge-mode auto, the default, merges an adapter into regular BF16 weights. Distilled adapters carry updates far smaller than a BF16 ulp of the weights they modify, so the merge rounds most of the update away. The MiniMax-H3 Turbo LoRA (larryvrh/MiniMax-H3-Turbo-Lora) is one: a merge drops 77–97% of the update in typical layers, and 75% over the whole transformer.Nothing fails or warns when this happens. The output just comes out softer than the adapter's reference, which applies the LoRA at runtime for exactly this reason. So the default silently degrades these adapters.
Modifications
BaseLayerWithLoRA.merge_rounding_norms()estimates, over an even sample of rows, how much of the active update a merge into the weight dtype would round away. It uses the same slicing and scaling as the merge, and writes nothing.auto,set_lorawith one adapter now does the following:AUTO_MERGE_MAX_ROUNDING_LOSS), i.e. the merge would destroy most of the update, keeps the adapter dynamic and logs why;set_loracalls do not measure again.Cseti/Wan-LoRA-Arcane-Jinx-v1) and 31% (reverentelusarca/elusarca-anime-style-lora-z-image-turbo) in a merge. Earlier cuts at 10% and 30% made them dynamic, and the dynamic path then cost Wan2.1 1.3B +52% and Z-Image +44% per step, failing both cases' latency checks. At 50% they merge exactly as before, while the distilled H3 Turbo adapter (75%) stays dynamic.mergeanddynamicare unchanged, and so are FSDP-sharded and quantized weights, whichautoalready keeps dynamic.--lora-merge-modehelp and the MiniMax-H3 cookbook describe the new rule.Accuracy Tests
test_lora_auto_merge_rounding.py(new, CPU) checks:The existing LoRA unit tests still pass (27 passed).
End to end on 2×H200, MiniMax-H3 T2VA at Ulysses 2 with the Larry Turbo v4 adapter,
num_inference_steps: 9, same seed:--lora-merge-modeauto(this PR)95a418705f7bdynamic95a418705f7bmerge342c3151970fautonow gives the dynamic output byte for byte. Side by side, the merged video is visibly softer: the cats blur and the scene loses detail that the dynamic run keeps.Speed Tests and Profiling
Keeping the Turbo LoRA dynamic costs 1.8 s on the 9-point schedule (27.6 against 25.8 s), which is the price of getting the adapter's full effect. A faster dynamic path, for example adding the LoRA delta inside the second GEMM, can follow separately. Adapters whose updates survive a merge, which covers the usual style LoRAs, still merge as before.
Checklist
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ✅ Run #38026407983
Latest PR Test (Extra): ❌ Run #38026407773
Latest PR Test (AMD ROCm 10): ⏳ Run #38026407934