invoke-ai/InvokeAI · error · ValueError
The SDXL LoRA could only be partially converted to diffusers
Error message
The SDXL LoRA could only be partially converted to diffusers format. converted={converted_count}, not_converted={not_converted_count} What it means
convert_sdxl_keys_to_diffusers_format counts keys it successfully converted and keys it left unconverted. If both counts are positive, the file is a mix of recognized and unrecognized layouts; loading only part of it would silently leave some layers unapplied, so the converter raises instead.
Source
Thrown at invokeai/backend/patches/lora_conversions/sdxl_lora_conversion_utils.py:57
position = bisect.bisect_right(stability_unet_keys, search_key)
map_key = stability_unet_keys[position - 1]
# Now, check if the map_key *actually* matches the search_key.
if search_key.startswith(map_key):
new_key = full_key.replace(map_key, SDXL_UNET_STABILITY_TO_DIFFUSERS_MAP[map_key])
new_state_dict[new_key] = value
converted_count += 1
else:
new_state_dict[full_key] = value
not_converted_count += 1
elif full_key.startswith("lora_te1_") or full_key.startswith("lora_te2_"):
# The CLIP text encoders have the same keys in both Stability AI and diffusers formats.
new_state_dict[full_key] = value
continue
else:
raise ValueError(f"Unrecognized SDXL LoRA key prefix: '{full_key}'.")
if converted_count > 0 and not_converted_count > 0:
raise ValueError(
f"The SDXL LoRA could only be partially converted to diffusers format. converted={converted_count},"
f" not_converted={not_converted_count}"
)
return new_state_dict
# code from
# https://github.com/bmaltais/kohya_ss/blob/2accb1305979ba62f5077a23aabac23b4c37e935/networks/lora_diffusers.py#L15C1-L97C32
def _make_sdxl_unet_conversion_map() -> List[Tuple[str, str]]:
"""Create a dict mapping state_dict keys from Stability AI SDXL format to diffusers SDXL format."""
unet_conversion_map_layer: list[tuple[str, str]] = []
for i in range(3): # num_blocks is 3 in sdxl
# loop over downblocks/upblocks
for j in range(2):
# loop over resnets/attentions for downblocks
hf_down_res_prefix = f"down_blocks.{i}.resnets.{j}."View on GitHub (pinned to 0b6a024f2f)
Solutions
- Log which keys were not converted and add/fix conversion rules or rename those keys to a supported format.
- Split the state dict: convert/load the convertible portion with this loader and handle the rest separately.
- Re-export the LoRA so all keys use one consistent SDXL naming convention.
Example fix
// before: mixed file 'lora_unet_blocks_0...': ok (converts) 'weird_prefix_blocks_1...': not converted -> raises // after 'lora_unet_blocks_0...': ok 'lora_unet_blocks_1...': renamed to supported prefix
Defensive patterns
Strategy: validation
Validate before calling
def is_fully_convertible(state_dict, convert_key) -> bool:
return all(convert_key(k) is not None for k in state_dict) Type guard
def keys_are_homogeneous(state_dict: dict[str, object]) -> bool:
prefixes = {k.split('_', 2)[0] + '_' + k.split('_', 2)[1] if k.count('_') > 1 else k for k in state_dict if isinstance(k, str)}
return len({p for p in prefixes}) <= 3 Try / catch
try:
sd = convert_sdxl_keys_to_diffusers_format(state_dict)
except ValueError as e:
if 'could only be partially converted' in str(e):
logger.error('Mixed-layout SDXL LoRA: %s', e)
# split state dict; convert/load each portion with the right loader
else:
raise Prevention
- Reject or split LoRA files that mix multiple naming conventions.
- Log non-converting keys in a pre-pass so you know what will fail.
- Re-export merged LoRAs with a single consistent key scheme.
When it happens
Trigger: Calling convert_sdxl_keys_to_diffusers_format on a state dict where at least one key converted to diffusers format and at least one key matched no conversion rule (not_converted_count > 0 and converted_count > 0).
Common situations: LoRA files that bundle text-encoder keys plus keys from a different model family; merged LoRAs of mixed provenance; files where a subset of modules uses a legacy naming convention the converter does not handle.
Related errors
- Unrecognized SDXL LoRA key prefix: '{full_key}'.
- Expected ModelPatchRaw for LoRA '{lora.lora.key}', got {type
- Unknown lora: {lora_key}!
- LoRA "{lora_key}" already applied to transformer.
- LoRA "{lora_key}" already applied to Qwen3 encoder.
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/843d95ceb0f121f6.
Report an issue: GitHub.