huggingface / huggingface/diffusers

TangentialClassifierFreeGuidance.is_conditional reads an attribute that does not exist

Aperta Adatta ai principianti
#14,794 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug needs-env-info pipelines
Lingua principale
Python
Stelle
34.5k
Fork
7.3k
Merge medio
3g 3h
PR unite (30g)
91

Descrizione

### Describe the bug

`TangentialClassifierFreeGuidance.is_conditional` reads `self._num_outputs_prepared`, which is not defined on the class, on `BaseGuidance`, or anywhere else in the package. Accessing it raises `AttributeError`, and so does `is_unconditional`, since `BaseGuidance` defines that as `not self.is_conditional`.

`BaseGuidance.__init__` sets `self._count_prepared`, and `prepare_inputs` increments it. Every other guider reads that attribute. This one appears to be the only exception:

```
adaptive_projected_guidance.py return self._count_prepared == 1
adaptive_projected_guidance_mix.py return self._count_prepared == 1
auto_guidance.py return self._count_prepared == 1
classifier_free_guidance.py return self._count_prepared == 1
classifier_free_zero_star_guidance.py return self._count_prepared == 1
frequency_decoupled_guidance.py return self._count_prepared == 1
magnitude_aware_guidance.py return self._count_prepared == 1
perturbed_attention_guidance.py return self._count_prepared == 1 or self._count_prepared == 3
skip_layer_guidance.py return self._count_prepared == 1 or self._count_prepared == 3
smoothed_energy_guidance.py return self._count_prepared == 1 or self._count_prepared == 3
tangential_classifier_free_guidance.py return self._num_outputs_prepared == 1 <-- undefined
```

`grep -rn "_num_outputs_prepared" src/` returns that single line and no assignment.

The reported error is misleading, which is what makes this awkward to diagnose. Python surfaces a failure inside a property as the property itself being missing, so the message names `is_conditional` rather than the attribute that is actually absent.

The property is reachable rather than dead code. `BaseGuidance.is_unconditional` routes through it, and `modular_pipelines/stable_diffusion_xl/denoise.py` reads `components.guider.is_conditional` in the guess-mode branch.

### Reproduction

No GPU, model download or authentication required.

```python
from diffusers.guiders import ClassifierFreeGuidance, TangentialClassifierFreeGuidance

print(ClassifierFreeGuidance(guidance_scale=7.5).is_conditional) # False

t = TangentialClassifierFreeGuidance(guidance_scale=7.5)
print(hasattr(t, "_count_prepared")) # True
print(hasattr(t, "_num_outputs_prepared")) # False
t.is_conditional # AttributeError
t.is_unconditional # AttributeError
```

### Logs

```
AttributeError: 'TangentialClassifierFreeGuidance' object has no attribute 'is_conditional'
```

### Prior attempts

Two pull requests fixed this correctly and are now closed, in both cases by their own authors rather than by a maintainer or a review decision:

- #13434 (2026-04-08, closed 2026-04-27 by the author) also covered a `NameError` in `FrequencyDecoupledGuidance`. That second bug no longer reproduces on `main`, so only this one remains.
- #13764 (2026-05-19, closed 2026-07-21 by the author) received no comments at all.

I mention this because it seems more useful than filing a third identical patch unprompted. Given that guiders are marked experimental, is this worth fixing, or is the module parked for now? If you would like it fixed I am happy to open a PR changing the attribute to `_count_prepared`, with a test that covers `is_conditional` and `is_unconditional` for every guider so the next one cannot drift the same way.

### System Info

- diffusers 0.41.0.dev0, `main` at ae2e4c7
- torch 2.14.0, Python 3.11, macOS (Apple Silicon)
- Reproduced on CPU, no accelerator involved

### Who can help?

@DN6 @asomoza

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da src/diffusers/guiders/tangential_classifier_free_guidance.py e confronta la sua proprietà is_conditional con le altre implementazioni di guider e BaseGuidance. Controlla il percorso is_unconditional e la lettura di guess-mode in modular_pipelines/stable_diffusion_xl/denoise.py. Il lavoro è completato quando entrambe le proprietà funzionano senza AttributeError e il comportamento pertinente del guider è coperto dai test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
machine-learning
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
72/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.