Commit 6d71b76
Complete Kohya LoRA conversion for Qwen and Z-Image (#14080)
* Fix Kohya LoRA conversion for Z-Image modules whose names contain underscores
_convert_non_diffusers_z_image_lora_to_diffusers reverses Kohya's `.`->`_`
flattening with a blanket `_`->`.` split, guarded only by a small
protected-n-gram list (attention to_q/k/v/out, feed_forward) plus post-hoc
fixes for context_refiner/noise_refiner. Z-Image's other modules whose names
contain underscores were over-split: all_final_layer, all_x_embedder,
adaLN_modulation, cap_embedder and t_embedder came out as all.final.layer,
adaLN.modulation, ... and failed to load with "unexpected keys".
Extend the existing dot->underscore post-normalization to re-merge these
names, so Kohya (lora_unet_) Z-Image LoRAs load.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Fix Kohya LoRA conversion for Qwen top-level (non-block) modules
_convert_non_diffusers_qwen_lora_to_diffusers's convert_key hardcodes the
transformer_blocks prefix and assumes every lora_unet_ key lives under a block:
it strips a transformer_blocks_ prefix and re-prepends transformer_blocks.,
which collapses the top-level modules (img_in, txt_in, proj_out, norm_out.linear,
time_text_embed.timestep_embedder.linear_1/2) onto each other. They end up as
transformer_blocks..weight / ...a.down.weight and trip the 'state_dict should be
empty' guard.
Resolve these six modules via an explicit flattened->dotted map before the block
logic runs, preserving the .lora_down/.lora_up/.alpha suffix, so Kohya (lora_unet_)
Qwen LoRAs load.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>1 parent b549ca9 commit 6d71b76
1 file changed
Lines changed: 37 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2232 | 2232 | | |
2233 | 2233 | | |
2234 | 2234 | | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
2235 | 2249 | | |
2236 | 2250 | | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
2237 | 2255 | | |
2238 | 2256 | | |
2239 | 2257 | | |
| |||
2803 | 2821 | | |
2804 | 2822 | | |
2805 | 2823 | | |
2806 | | - | |
2807 | | - | |
2808 | | - | |
2809 | | - | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
2810 | 2836 | | |
2811 | 2837 | | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
2812 | 2845 | | |
2813 | 2846 | | |
2814 | 2847 | | |
| |||
0 commit comments