huggingface / huggingface/diffusers

[SD3 ControlNet] bug in pipeline 'controlnet_pooled_projections'

Ouverte
#9,686 11 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug stale
Langage dominant
Python
Étoiles
34.5k
Forks
7.3k
Merge moyen
3 j 3 h
PR mergées (30 j)
91

Description

### Describe the bug

Hi,

I think I found an issue that causes a misalignment between training and inference in SD3 ControlNet.

https://github.com/huggingface/diffusers/blob/a3e8d3f7deed140f57a28d82dd0b5d965bd0fb09/src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet.py#L977

I think the if-else block starting there is not correct. It should be
```python
if controlnet_pooled_projections is None and pooled_prompt_embeds is None:
controlnet_pooled_projections = torch.zeros_like(pooled_prompt_embeds)
elif controlnet_pooled_projections is None:
controlnet_pooled_projections = pooled_prompt_embeds
```
Given that in training, the pooled_prompt_embeds are fed to the model:
https://github.com/huggingface/diffusers/blob/a3e8d3f7deed140f57a28d82dd0b5d965bd0fb09/examples/controlnet/train_controlnet_sd3.py#L1293

Additionally, I am wondering if this line:
https://github.com/huggingface/diffusers/blob/a3e8d3f7deed140f57a28d82dd0b5d965bd0fb09/examples/controlnet/train_controlnet_sd3.py#L1287
Should be aligned with this line:
https://github.com/huggingface/diffusers/blob/a3e8d3f7deed140f57a28d82dd0b5d965bd0fb09/examples/controlnet/train_controlnet_sd3.py#L1257
This seems to be the more sensible approach, but will probably not make much difference since the ControlNet can also learn the shift. It might speed up convergence *slightly*.

Best,
Tobias

### Reproduction

Train an SD3 ControlNet and during log_validation it will be executed.

### Logs

_No response_

### System Info

diffusers==0.30.3

### Who can help?

@yiyixuxu @sayakpaul

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par le bloc if-else autour de la ligne 977 dans src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet.py, puis comparez-le avec la gestion du pooled prompt autour des lignes 1287 et 1293 dans examples/controlnet/train_controlnet_sd3.py. Exécutez le chemin log_validation indiqué après l’entraînement et vérifiez que l’entraînement et l’inférence utilisent des pooled projections alignées, avec notamment une décision tranchée concernant le shift à la ligne 1257.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python, pytorch
Domaine
machine-learning
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.