Skip to content

fix: correct AttributeError in TangentialCFG and NameError in FrequencyDecoupledGuidance#13434

Open
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix/guiders-attribute-and-variable-errors
Open

fix: correct AttributeError in TangentialCFG and NameError in FrequencyDecoupledGuidance#13434
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix/guiders-attribute-and-variable-errors

Conversation

@Ricardo-M-L
Copy link
Copy Markdown

Summary

Fixes two functional bugs in the experimental guiders module, both introduced in #11311 (Modular Diffusers Guiders):

Bug 1: TangentialClassifierFreeGuidance.is_conditional — AttributeError

The is_conditional property references self._num_outputs_prepared, which does not exist on the class or its base class BaseGuidance. Every other guider uses self._count_prepared (defined and managed by BaseGuidance). Accessing is_conditional on a TangentialClassifierFreeGuidance instance raises:

AttributeError: 'TangentialClassifierFreeGuidance' object has no attribute '_num_outputs_prepared'

Fix: Replace self._num_outputs_prepared with self._count_prepared.

Bug 2: FrequencyDecoupledGuidance.forward — NameError / wrong pyramid level

In the forward method's loop over pyramid levels, the else branch (when FDG is disabled for a level) appends pred_cond_freq to the guided pyramid. However, pred_cond_freq is only assigned inside the if branch. This causes:

  • NameError if the very first pyramid level has FDG disabled (variable never assigned)
  • Silent wrong results if a prior level assigned it — the wrong level's frequency data gets used

Fix: Replace pred_cond_freq with pred_cond_pyramid[level] to correctly reference the current level's conditional prediction.

Test plan

  • Verified _num_outputs_prepared is not defined anywhere in the codebase; _count_prepared is the correct attribute used by all other guiders
  • Verified pred_cond_freq is only assigned inside the if branch, confirming the else branch will fail or use stale data
  • Checked no existing open PRs address these issues

🤖 Generated with Claude Code

…in FrequencyDecoupledGuidance

Fix two bugs in the guiders module:

1. TangentialClassifierFreeGuidance.is_conditional references
   `self._num_outputs_prepared` which does not exist. All other guiders
   use `self._count_prepared` (defined in BaseGuidance). This causes an
   AttributeError whenever is_conditional is accessed.

2. FrequencyDecoupledGuidance.forward uses `pred_cond_freq` in the else
   branch (line 278) where FDG is disabled for a level, but that variable
   is only defined inside the if branch. If the first pyramid level has
   FDG disabled, this raises a NameError. Even when a prior level defined
   it, the wrong level's data would be used. Fixed to use
   `pred_cond_pyramid[level]` which correctly indexes the pyramid.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added guiders size/S PR with diff < 50 LOC labels Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

guiders size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant