Flux Control and HunyuanVideo LoRA converters swap the scale/shift halves of `lora_A` in `final_layer`
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
調査の方向性
Read loaders/lora_conversion_utils.py and the existing test_lora_bfl_final_layer_modulation test. The issue identifies both affected converters and proposes one test per converter, checking that only lora_B is swapped; run those tests to confirm the converted delta matches the expected scale/shift order. A pull request is already open for this issue.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
final_layer.adaLN_modulation.1 in the original checkpoints orders its output (shift, scale), and diffusers' norm_out.linear orders it (scale, shift), so the converters swap the two halves. For a LoRA only lora_B should be swapped: its rows are the layer's outputs. lora_A is (rank, in), so swapping its halves reorders the rank dimension and the converted delta is wrong.
Two converters in loaders/lora_conversion_utils.py swap both:
_convert_bfl_flux_control_lora_to_diffusers:swap_scale_shiftis applied for everylora_key, includinglora_A(weight and bias)._convert_hunyuan_video_lora_to_diffusers:remap_norm_scale_shift_swaps everyfinal_layer.adaLN_modulation.1key,lora_Aincluded.
The kohya Flux converter already swaps only lora_B. This is the same class of bug #15276 fixed for Flux2.
Reproduction
import torch
from diffusers.loaders.lora_conversion_utils import _convert_bfl_flux_control_lora_to_diffusers
RANK, INNER = 4, 3072
torch.manual_seed(0)
class FillingDict(dict):
# dummy tensors for the keys the converter pops that this repro doesn't care about
def pop(self, key, *default):
if key in self:
return super().pop(key)
if default:
return default[0]
return torch.zeros(21504, RANK) if ".lora_B." in key else torch.zeros(RANK, 8)
lora_A = torch.randn(RANK, INNER)
lora_B = torch.randn(2 * INNER, RANK) # rows: (shift, scale)
sd = FillingDict({
"final_layer.adaLN_modulation.1.lora_A.weight": lora_A.clone(),
"final_layer.adaLN_modulation.1.lora_B.weight": lora_B.clone(),
"double_blocks.0.img_attn.norm.query_norm.scale": torch.ones(1),
})
out = _convert_bfl_flux_control_lora_to_diffusers(sd)
A = out["transformer.norm_out.linear.lora_A.weight"]
B = out["transformer.norm_out.linear.lora_B.weight"]
shift, scale = (lora_B @ lora_A).chunk(2, dim=0)
expected = torch.cat([scale, shift])
print(torch.allclose(B @ A, expected, atol=1e-4), (B @ A - expected).abs().max().item())
print(torch.allclose(B @ lora_A, expected, atol=1e-4)) # lora_A left as is
Logs
False 39.052650451660156
True
The HunyuanVideo converter gives the same result (max error 17.05 in the equivalent check).
System Info
diffusers main @ 43e3002, torch 2.15.0, Python 3.12, macOS (CPU).
Who can help?
@sayakpaul
I have a fix with tests for both converters (swap only lora_B; one test per converter in the style of test_lora_bfl_final_layer_modulation, both fail on main) and can open a PR if you'd like. It may change the expected slices of the slow Flux Control LoRA integration tests, which I can't regenerate without a GPU.
- 主要言語
- Python
- スター
- 34.9k
- フォーク
- 7.5k
- 平均マージ
- 3日 16時間
- マージ済み PR(30日)
- 65
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
huggingface/diffusers のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
huggingface/diffusers#15363 ·
メンテナーはふだん 1 日以内に返信
-
`ZImageImg2ImgPipeline` / `ZImageInpaintPipeline`: explicit height/width different from the input image raises RuntimeError対応中かも @chessing234 が 1 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
huggingface/diffusers#15337 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Multi-vector textual inversion uses only the first vector when the token has uppercase letters (transformers v5)対応中かも @sunhouy が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
huggingface/diffusers#15313 ·
メンテナーはふだん 1 日以内に返信
-
TCDScheduler advances the generator on the final step of a strength-truncated custom schedule対応中かも @SIDDARTHAREDDY8 が 5 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
huggingface/diffusers#15288 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
unload_textual_inversion(token) leaves the extra tokens of a multi-vector embedding behind, so it can't be loaded again対応中かも @sohailshk が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
huggingface/diffusers#15211 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
huggingface/diffusers の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 1 日以内に返信
-
Unused loot bag group names left in dreamcraft en_US.lang対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンStatus: Triage Suggestion
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
GTNewHorizons/GT-New-Horizons-Modpack#27789 ·
メンテナーはふだん 1 日以内に返信
-
bug frontend sev-5
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
-
core good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
b4b code health next
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信