Fix Issue #43: Prevent ComfyUI-nunchaku bug by forcing guidance=None after conversion to additional_t_cond
- Force guidance to None in forward() and _execute_model() to prevent ComfyUI-nunchaku's buggy code path (line 726) from executing - Preserve legacy guidance values from kwargs/transformer_options and convert to additional_t_cond when needed (backward compatibility) - This prevents TypeError: QwenTimestepProjEmbeddings.forward() takes 3 positional arguments but 4 were given - Similar defensive approach to v2.0.2-v2.0.8 guidance duplication fixes
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user