{"record":{"id":"7c53a227e631789b","repo":"Comfy-Org/ComfyUI","slug":"qwen-fun-controlnet-requires-a-qwenimage-base-mode","errorCode":null,"errorMessage":"Qwen Fun ControlNet requires a QwenImage base model at runtime.","messagePattern":"Qwen Fun ControlNet requires a QwenImage base model at runtime\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/qwen_image/controlnet.py","lineNumber":123,"sourceCode":"        elif cur_in > expected_in:\n            hidden_states = hidden_states[:, :, :expected_in]\n\n        return hidden_states\n\n    def forward(\n        self,\n        x,\n        timesteps,\n        context,\n        attention_mask=None,\n        guidance: torch.Tensor = None,\n        hint=None,\n        transformer_options={},\n        base_model=None,\n        **kwargs,\n    ):\n        if base_model is None:\n            raise RuntimeError(\"Qwen Fun ControlNet requires a QwenImage base model at runtime.\")\n\n        encoder_hidden_states_mask = attention_mask\n        # Keep attention mask disabled inside Fun control blocks to mirror\n        # VideoX behavior (they rely on seq lengths for RoPE, not masked attention).\n        encoder_hidden_states_mask = None\n\n        hidden_states, img_ids, _ = base_model.process_img(x)\n        hint_tokens = self._process_hint_tokens(hint)\n        if hint_tokens is None:\n            raise RuntimeError(\"Qwen Fun ControlNet requires a control hint image.\")\n\n        if hint_tokens.shape[1] != hidden_states.shape[1]:\n            max_tokens = min(hint_tokens.shape[1], hidden_states.shape[1])\n            hint_tokens = hint_tokens[:, :max_tokens]\n            hidden_states = hidden_states[:, :max_tokens]\n            img_ids = img_ids[:, :max_tokens]\n\n        txt_start = round(","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/qwen_image/controlnet.py#L105-L141","documentation":"Qwen Fun ControlNet is a 'Fun' style controlnet that is applied at model-forward time and needs the live QwenImage base transformer (it calls base_model.process_img to build hidden states and image RoPE ids). ComfyUI passes base_model in when the controlnet is applied through the standard QwenImage controlnet application path; a None base_model means the Fun controlnet was invoked outside that path.","triggerScenarios":"Calling QwenFunControlNet.apply_control/forward directly (custom node code) without the base_model kwarg; loading the Fun ControlNet through a generic ControlNet-apply node that does not know how to hand the base model to it; a controlnet Apply node chain where the model input is missing.","commonSituations":"Using the wrong 'Apply ControlNet' node variant for Qwen Fun ControlNet (should be the QwenImage/Fun-specific apply path); a custom node calling the controlnet forward in its own sampler loop; workflow where the base MODEL output is not connected into the conditioning chain.","solutions":["Use the dedicated QwenImage ControlNet apply node/path so ComfyUI supplies base_model at runtime.","In workflows, make sure the base QwenImage MODEL output feeds the apply node and the resulting conditioning feeds the sampler.","Custom-node authors: pass base_model=<QwenImage transformer instance> when invoking the controlnet, mirroring comfy/ldm/qwen_image/controlnet.py call sites.","Confirm the base checkpoint is actually QwenImage — other DiT families never supply a compatible base_model."],"exampleFix":"# before (custom node)\nout = controlnet.apply_control(x, t, context, hint=hint)\n# after\nout = controlnet.apply_control(x, t, context, hint=hint, base_model=qwen_transformer)","handlingStrategy":"validation","validationCode":"def apply_qwen_fun_control(controlnet, x, t, context, hint, base_model):\n    if base_model is None:\n        raise ValueError(\"Qwen Fun ControlNet must be applied via the QwenImage apply path so base_model is provided\")\n    return controlnet(x, t, context, hint=hint, base_model=base_model, transformer_options={})","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the QwenImage-specific ControlNet apply node, not a generic one.","In custom nodes, always thread the sampled transformer as base_model into Fun controlnet calls.","Verify the base MODEL output is connected in the workflow before the apply node."],"tags":["qwen-image","controlnet","model-wiring","runtime"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}