diff --git a/wrappers/qwenimage.py b/wrappers/qwenimage.py index 7a94d66..3a58022 100644 --- a/wrappers/qwenimage.py +++ b/wrappers/qwenimage.py @@ -96,7 +96,10 @@ class ComfyQwenImageWrapper(nn.Module): # which could cause issues when passing to _execute_model # Note: ref_latents is NOT a parameter of forward(), so we keep it in kwargs for _execute_model to use if "guidance" in kwargs: - # Remove guidance from kwargs to avoid duplication (explicit parameter takes precedence) + # Preserve legacy guidance if it only arrives via kwargs (environment-dependent), + # then remove it to avoid duplication downstream. + if guidance is None: + guidance = kwargs.get("guidance") kwargs.pop("guidance") if "transformer_options" in kwargs: # Merge transformer_options from kwargs into the parameter if needed @@ -104,6 +107,10 @@ class ComfyQwenImageWrapper(nn.Module): transformer_options = {**transformer_options, **kwargs.pop("transformer_options")} else: kwargs.pop("transformer_options") + # Preserve legacy guidance if it only arrives via transformer_options (environment-dependent). + # We will later remove it from transformer_options when actually calling the model. + if guidance is None and isinstance(transformer_options, dict) and "guidance" in transformer_options: + guidance = transformer_options.get("guidance") if "attention_mask" in kwargs: kwargs.pop("attention_mask") if isinstance(timestep, torch.Tensor):