huggingface / huggingface/diffusers

SanaCombinedTimestepGuidanceEmbeddings do not work with SanaPipeline

Aperta
#12,540 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug stale
Lingua principale
Python
Stelle
34.5k
Fork
7.3k
Merge medio
3g 3h
PR unite (30g)
91

Descrizione

### Describe the bug

When building a `SanaTransformer2DModel`, it lets you which time_embed to use with `guidance_embeds`. The default choice is `AdaLayerNormSingle`, which works fine when calling the pipeline; the other choice, `SanaCombinedTimestepGuidanceEmbeddings`, does not work however.

### Reproduction

```
from diffusers import SanaTransformer2DModel, SanaPAGPipeline
import torch

config = SanaTransformer2DModel.load_config('Efficient-Large-Model/Sana_600M_512px_diffusers', subfolder='transformer')
config['num_layers'] = 14
config['patch_size'] = 2
config['interpolation_scale'] = 1.0
config['guidance_embeds'] = True

new_transformer = SanaTransformer2DModel.from_config(config)

total_params = sum(p.numel() for p in new_transformer.parameters())
print(f"Total number of parameters: {total_params:,}")

pipe = SanaPAGPipeline.from_pretrained(
"Efficient-Large-Model/Sana_1600M_512px_MultiLing_diffusers",
pag_applied_layers = ["transformer_blocks.8"],
transformer=new_transformer,
torch_dtype=torch.bfloat16,
vae=None
).to('cuda')
with torch.no_grad():
image = pipe(
prompt='cat',
output_type='latent',
height=768,
width=512,
pag_scale=1.0,
guidance_scale=4.0,
num_inference_steps=20,
)[0]

```

### Logs

```shell
File "/home/lucas/Documents/YAT/create_sana_transformer.py", line 23, in
image = pipe(
^^^^^
File "/home/lucas/Documents/YAT/.venv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/lucas/Documents/YAT/.venv/lib/python3.12/site-packages/diffusers/pipelines/pag/pipeline_pag_sana.py", line 877, in __call__
noise_pred = self.transformer(
^^^^^^^^^^^^^^^^^
File "/home/lucas/Documents/YAT/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lucas/Documents/YAT/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lucas/Documents/YAT/.venv/lib/python3.12/site-packages/diffusers/models/transformers/sana_transformer.py", line 539, in forward
timestep, embedded_timestep = self.time_embed(
^^^^^^^^^^^^^^^^
File "/home/lucas/Documents/YAT/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lucas/Documents/YAT/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: SanaCombinedTimestepGuidanceEmbeddings.forward() got an unexpected keyword argument 'batch_size'
```

### System Info

I am on Ubuntu 24.04 LTS.

```
pip show diffusers
Name: diffusers
Version: 0.35.2
Summary: State-of-the-art diffusion in PyTorch and JAX.
Home-page: https://github.com/huggingface/diffusers
Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/diffusers/graphs/contributors)
Author-email: diffusers@huggingface.co
License: Apache 2.0 License
Location: /home/lucas/Documents/YAT/.venv/lib/python3.12/site-packages
Requires: filelock, huggingface-hub, importlib_metadata, numpy, Pillow, regex, requests, safetensors
Required-by:
```

### Who can help?

_No response_

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start with the SanaTransformer2DModel call in models/transformers/sana_transformer.py and the SanaPAGPipeline entry point in pipelines/pag/pipeline_pag_sana.py. Reproduce the reported TypeError with the provided script, then verify that SanaCombinedTimestepGuidanceEmbeddings works through the pipeline without the unexpected batch_size argument error.

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à
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.