Skip to content

Conversation

@linoytsaban
Copy link
Collaborator

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@linoytsaban linoytsaban requested a review from sayakpaul November 3, 2025 15:51
@linoytsaban
Copy link
Collaborator Author

@bot /style

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

Style fix runs successfully without any file modified.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Thank you! I left some minor yet important nits. Once those are addressed, we can ship!


state_dict = {convert_key(k): v for k, v in state_dict.items()}

has_default = any("default." in k for k in state_dict)
Copy link
Member

Choose a reason for hiding this comment

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

If it's starting with "default.", then let's be explicit about that:

Suggested change
has_default = any("default." in k for k in state_dict)
has_default = any(k.startswith("default.") for k in state_dict)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"default" isn't the prefix though, e.g.transformer_blocks.0.attn.add_v_proj.lora_A.default.weight

Comment on lines +2217 to +2218
if has_default:
state_dict = {k.replace("default.", ""): v for k, v in state_dict.items()}
Copy link
Member

Choose a reason for hiding this comment

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

So, that it's done as intended:

Suggested change
if has_default:
state_dict = {k.replace("default.", ""): v for k, v in state_dict.items()}
if has_default:
state_dict = {k[len("default."):]: v for k, v in state_dict.items()}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same comment as here - 'default' is not in the key's prefix, so this won't be the intended behavior in this case

has_lora_unet = any(k.startswith("lora_unet_") for k in state_dict)
has_diffusion_model = any(k.startswith("diffusion_model.") for k in state_dict)
if has_alphas_in_sd or has_lora_unet or has_diffusion_model:
has_default = any("default." in k for k in state_dict)
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same comment as #12581 (comment) - 'default' is not in the key's prefix, so this won't be the intended behavior in this case

@linoytsaban linoytsaban merged commit dcfb18a into huggingface:main Nov 4, 2025
28 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants