Add DiffSynth blockwise ControlNet support to QwenImageControlNetModel#13268
Open
aryabyte21 wants to merge 1 commit intohuggingface:mainfrom
Open
Add DiffSynth blockwise ControlNet support to QwenImageControlNetModel#13268aryabyte21 wants to merge 1 commit intohuggingface:mainfrom
aryabyte21 wants to merge 1 commit intohuggingface:mainfrom
Conversation
Extends the existing QwenImageControlNetModel with a `controlnet_block_type` config parameter to support the DiffSynth blockwise ControlNet architecture alongside the existing InstantX linear projection approach. The blockwise variant uses BlockWiseControlBlock modules (RMSNorm + MLP) that fuse base hidden states with control features at each transformer block, instead of the simple zero-initialized linear projections used by InstantX. Closes huggingface#12221
2 tasks
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
Adds support for the DiffSynth-Studio blockwise ControlNet architecture to the existing
QwenImageControlNetModel, addressing the maintainer's feedback on PR #12317 by integrating it into the existing class rather than creating a separate one.What changed
controlnet_block_typeconfig parameter toQwenImageControlNetModel("linear"default for InstantX,"blockwise"for DiffSynth)BlockWiseControlBlockmodule: RMSNorm + MLP fusion block that normalizes both base hidden states and control features separately before fusing via Linear → GELU → Linear (zero-initialized output)controlnet_block_samplesoutput formatscripts/convert_diffsynth_blockwise_controlnet_to_diffusers.py)Key design decision
Per @yiyixuxu's review comment on #12317:
Yes — the only architectural difference is in the controlnet blocks themselves. The blockwise variant uses
BlockWiseControlBlock(x, y)(two inputs: base + control features) instead ofzero_module(nn.Linear)(x)(one input). Everything else — the pipeline, transformer integration, and output format — is identical.Available checkpoints
DiffSynth-Studio/Qwen-Image-Blockwise-ControlNet-CannyDiffSynth-Studio/Qwen-Image-Blockwise-ControlNet-DepthDiffSynth-Studio/Qwen-Image-Blockwise-ControlNet-InpaintUsage
Closes #12221
Test plan
test_qwen_controlnetpasses (no regression)test_qwen_controlnet_multiconditionpasses (no regression)test_qwen_blockwise_controlnetpassestest_qwen_blockwise_controlnet_from_transformerpasses