fix(controlnet_hunyuan): wire num_layers, pooled_projection_dim, use_style_cond into from_transformer (#13641)#13658
Open
Anai-Guo wants to merge 1 commit intohuggingface:mainfrom
Open
Conversation
…le cond fields in from_transformer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Issue 1 in #13641.
HunyuanDiT2DControlNetModel.from_transformer()was readingconfig.transformer_num_layers, butHunyuanDiT2DModelstores the layer count underconfig.num_layers. The default call path therefore raisedAttributeError. Even whentransformer_num_layerswas passed manually, the method also droppedpooled_projection_dimanduse_style_cond_and_image_meta_size, so a ControlNet built from a non-default transformer silently fell back to defaults (pooled_projection_dim=1024,use_style_cond_and_image_meta_size=True) and could fail weight loading with size mismatches.Fix
config.num_layers(the actualHunyuanDiT2DModelconfig attribute) rather than the non-existenttransformer_num_layers.pooled_projection_dimanduse_style_cond_and_image_meta_sizefrom the source transformer config, so the ControlNet is constructed with the same conditioning embedding shapes and style-cond setting as the transformer it derives from.Verification
The reproduction snippet from #13641 now works:
Existing default-config call sites (e.g. with the public
Tencent-Hunyuan/HunyuanDiT-Diffuserscheckpoint) are unchanged: the defaultpooled_projection_dim=1024anduse_style_cond_and_image_meta_size=Truematch the public config exactly, so they round-trip to the same values that were previously hardcoded by omission.🤖 Generated with Claude Code