Comfy-Org/ComfyUI · error · RuntimeError

Qwen Fun ControlNet requires a QwenImage base model at runti

Error message

Qwen Fun ControlNet requires a QwenImage base model at runtime.

What it means

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.

Source

Thrown at comfy/ldm/qwen_image/controlnet.py:123

        elif cur_in > expected_in:
            hidden_states = hidden_states[:, :, :expected_in]

        return hidden_states

    def forward(
        self,
        x,
        timesteps,
        context,
        attention_mask=None,
        guidance: torch.Tensor = None,
        hint=None,
        transformer_options={},
        base_model=None,
        **kwargs,
    ):
        if base_model is None:
            raise RuntimeError("Qwen Fun ControlNet requires a QwenImage base model at runtime.")

        encoder_hidden_states_mask = attention_mask
        # Keep attention mask disabled inside Fun control blocks to mirror
        # VideoX behavior (they rely on seq lengths for RoPE, not masked attention).
        encoder_hidden_states_mask = None

        hidden_states, img_ids, _ = base_model.process_img(x)
        hint_tokens = self._process_hint_tokens(hint)
        if hint_tokens is None:
            raise RuntimeError("Qwen Fun ControlNet requires a control hint image.")

        if hint_tokens.shape[1] != hidden_states.shape[1]:
            max_tokens = min(hint_tokens.shape[1], hidden_states.shape[1])
            hint_tokens = hint_tokens[:, :max_tokens]
            hidden_states = hidden_states[:, :max_tokens]
            img_ids = img_ids[:, :max_tokens]

        txt_start = round(

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Use the dedicated QwenImage ControlNet apply node/path so ComfyUI supplies base_model at runtime.
  2. In workflows, make sure the base QwenImage MODEL output feeds the apply node and the resulting conditioning feeds the sampler.
  3. Custom-node authors: pass base_model=<QwenImage transformer instance> when invoking the controlnet, mirroring comfy/ldm/qwen_image/controlnet.py call sites.
  4. Confirm the base checkpoint is actually QwenImage — other DiT families never supply a compatible base_model.

Example fix

# before (custom node)
out = controlnet.apply_control(x, t, context, hint=hint)
# after
out = controlnet.apply_control(x, t, context, hint=hint, base_model=qwen_transformer)
Defensive patterns

Strategy: validation

Validate before calling

def apply_qwen_fun_control(controlnet, x, t, context, hint, base_model):
    if base_model is None:
        raise ValueError("Qwen Fun ControlNet must be applied via the QwenImage apply path so base_model is provided")
    return controlnet(x, t, context, hint=hint, base_model=base_model, transformer_options={})

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/7c53a227e631789b. Report an issue: GitHub.