Repository navigation
Do not identify FLUX ControlNet checkpoints as FLUX main models - #9835
Conversation
|
Thanks! Verified with the real One change before merging: the Otherwise this looks good to me. |
…n validation InstantX ControlNets use diffusers keys and have no BFL double_blocks key, so the key check above already rejects them.
Pfannkuchensack
left a comment
There was a problem hiding this comment.
Need to clean up the conflict but nice work.
…/flux-xlabs-controlnet-not-main # Conflicts: # invokeai/backend/model_manager/configs/main.py
Summary
Installing an XLabs FLUX ControlNet checkpoint (e.g.
flux-canny-controlnet-v3.safetensorsfromXLabs-AI/flux-controlnet-collections) registered it as a FLUX main model (
type: main,base: flux,format: checkpoint) instead of a ControlNet, so it never appeared where ControlNetsare chosen and could not be used.
The XLabs ControlNet contains two FLUX double blocks, so its state dict carries
double_blocks.0.img_attn.norm.key_norm.scale— the keyMain_Checkpoint_FLUX_Config._validate_is_fluxkeys off.
ControlNet_Checkpoint_FLUX_Configmatches too, and becauseModelConfigFactory.matches_sort_keyranksModelType.Mainfirst, the main config won the tie-break._validate_is_fluxnow rejects state dicts thatis_state_dict_xlabs_controlnetoris_state_dict_instantx_controlnetrecognise, so only the ControlNet config matches these files.Related Issues / Discussions
Closes #9832
QA Instructions
New regression test
tests/backend/model_manager/configs/test_flux_controlnet_not_main_config.pybuilds a state dict mirroring the XLabs ControlNet (the controlnet-specific keys plus two FLUX double
blocks, no
single_blocks/final_layer) and asserts the main config rejects it while the ControlNetconfig accepts it.
test_xlabs_controlnet_does_not_match_flux_mainfails (DID NOT RAISE NotAMatchError—the file matched as a main model).
2 passed).Verified locally on a CPU-only Linux box (Python 3.12, torch 2.13.0+cpu). The FLUX/ControlNet/main
config tests pass (67 passed, 1 skipped); the remaining failures in the wider
tests/backend/model_manager/configs/directory are pre-existing on a cleanmainin thisenvironment (protobuf/onnx and WAN filename-heuristic env issues) — the same count fails with and
without this change.
Review
Smallest fix at the root cause: two
is_state_dict_*_controlnetdetectors already exist and are usedby the ControlNet config; reusing them in the main-model guard keeps behavior consistent and avoids
touching the fragile ControlNet key heuristics.
Need help on this PR? Tag
@codesmith-botwith what you need.