Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDXL] Compel can't batch prompt (mat1 and mat2 shapes cannot be multiplied) #89

Open
Fqlox opened this issue Jun 4, 2024 · 1 comment

Comments

@Fqlox
Copy link

Fqlox commented Jun 4, 2024

I wanted to make an inference with multiple prompt at one time and got:

mat1 and mat2 shapes cannot be multiplied (2x4096 and 2816x1280)

Here is a basic example:

pipe = StableDiffusion ....
compel = Compel(
  tokenizer=[pipe.tokenizer, pipe.tokenizer_2] ,
  text_encoder=[pipe.text_encoder, pipe.text_encoder_2],
  returned_embeddings_type=ReturnedEmbeddingsType.PENULTIMATE_HIDDEN_STATES_NON_NORMALIZED,
  requires_pooled=[False, True]
)

prompts_str = [
    "a Man wearing (sunglasses)1.2, close up, realistic, 4k",
    "a dog in a forest, long distance shot, photo, photography, highly detailed",
]

prompts = [compel(x) for x in prompts_str]

conditioning = torch.cat([e[0] for e in prompts], dim=1) 
pooled = torch.cat([e[1] for e in prompts], dim =1 ) 

image = pipe(
prompt_embeds=conditioning, 
pooled_prompt_embeds=pooled,
image_batch_size=2,
prompt_batch_size=2,
...
)

I tried to use list instead of torch.cat, I tried to pass on pooled prompt

Thanks in advance

@madriss
Copy link

madriss commented Jul 23, 2024

Have you found a solution ?

I tried to concat with dim=0 and seemed to get it to work although with strange resutls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants