Skip to content

Conversation

@Pfannkuchensack
Copy link
Collaborator

Summary

Z-Image LoRAs containing keys like diffusion_model.context_refiner.* were being incorrectly classified as main checkpoint models instead of LoRAs. This happened because the _has_z_image_keys() function checked for Z-Image specific keys (like context_refiner) without verifying if the file was actually a LoRA.

Since main models have higher priority than LoRAs in the classification sort order, the incorrect main model classification would win.

The fix adds detection of LoRA-specific weight suffixes (.lora_down.weight, .lora_up.weight, .lora_A.weight, .lora_B.weight, .dora_scale) and returns False if any are found, ensuring LoRAs are correctly classified.

Related Issues / Discussions

#8707

QA Instructions

  1. Import a Z-Image LoRA file (e.g., one with diffusion_model.context_refiner.* or diffusion_model.layers.* keys)
  2. Verify it is classified as LoRA type with z-image base and lycoris format
  3. Import a Z-Image main model checkpoint
  4. Verify it is still correctly classified as Main type with z-image base

Merge Plan

Standard merge, no special considerations.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

… main models

Z-Image LoRAs containing keys like `diffusion_model.context_refiner.*` were being
incorrectly classified as main checkpoint models instead of LoRAs. This happened
because the `_has_z_image_keys()` function checked for Z-Image specific keys
(like `context_refiner`) without verifying if the file was actually a LoRA.

Since main models have higher priority than LoRAs in the classification sort order,
the incorrect main model classification would win.

The fix adds detection of LoRA-specific weight suffixes (`.lora_down.weight`,
`.lora_up.weight`, `.lora_A.weight`, `.lora_B.weight`, `.dora_scale`) and returns
False if any are found, ensuring LoRAs are correctly classified.
@github-actions github-actions bot added python PRs that change python files backend PRs that change backend files labels Jan 10, 2026
@JPPhoto
Copy link
Collaborator

JPPhoto commented Jan 10, 2026

Does this reclassify existing models if somebody reidentifies?

@Pfannkuchensack
Copy link
Collaborator Author

This will fix any Lora that got identifies as Model right if reidentifies again.

".dora_scale",
)

has_z_image_keys = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add has_z_image_keys instead of the code that was there before?

Copy link
Collaborator

@lstein lstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend PRs that change backend files python PRs that change python files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants