huggingface / huggingface/diffusers

Wrong default layers for Flux 2 Klein

Aperta
#13,445 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug lora needs-code-example pipelines
Lingua principale
Python
Stelle
34.5k
Fork
7.3k
Merge medio
3g 3h
PR unite (30g)
91

Descrizione

### Describe the bug

Thanks a lot for taking the time to review this issue 🤗

There seems to be a mismatch between the default values exposed via CLI arguments and the layers that are actually used internally in the script:

Script:
[pipeline_flux2_klein.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/flux2/pipeline_flux2_klein.py)
[train_dreambooth_lora_flux2_klein.py](https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora_flux2_klein.py)

The argument definition specifies:

```
parser.add_argument(
"--text_encoder_out_layers",
type=int,
nargs="+",
default=[10, 20, 30],
help="Text encoder hidden layers to compute the final text embeddings.",
)
```
However, inside the implementation the following layers are actually used:
`hidden_states_layers: list[int] = (9, 18, 27)`
**Expected behavior**
The default CLI argument values should match the layers that are actually used internally, or the internal implementation should respect the provided CLI values.
**Actual behavior**
There is an off-by-one inconsistency between:
CLI defaults: [10, 20, 30]
Internal usage: (9, 18, 27)
This can lead to confusion and potentially incorrect assumptions when tuning or debugging training behavior.
**Possible cause**
This might be a copy-paste artifact from:
[train_dreambooth_lora_flux2.py](https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora_flux2.py)
which uses a different setup (e.g. Mistral-based text encoder in a dev version), where layer indexing may differ.
**Additional context**
This discrepancy cost me ~72 GPU hours before I realized what was going on, so I figured it’s worth documenting 😅
**Suggested fix**
Either align defaults with (9, 18, 27)
Or make sure --text_encoder_out_layers is actually used consistently throughout the script

### Reproduction

No special setup required — this is directly visible from reading the script.

### Logs

```shell

```

### System Info

N/A

### Who can help?

_No response_

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da src/diffusers/pipelines/flux2/pipeline_flux2_klein.py e examples/dreambooth/train_dreambooth_lora_flux2_klein.py, confrontando il valore predefinito della CLI per --text_encoder_out_layers con il valore interno hidden_states_layers. Traccia il percorso dell'argomento fino al calcolo dei text embedding e verifica l'indicizzazione prevista dei layer. Il lavoro è completato quando i valori predefiniti e i layer effettivamente utilizzati sono coerenti e i valori della CLI forniti esplicitamente vengono rispettati, se questo è il comportamento scelto.

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

Valutazione

Stack tecnologico
python, pytorch
Ambito
machine-learning
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
65/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.