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

fix for #7365, prevent pipelines from overriding provided prompt embeds #7926

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/community/lpw_stable_diffusion_xl.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,8 @@ def encode_prompt(
)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

prompt_embeds = prompt_embeds.hidden_states[-2]

prompt_embeds_list.append(prompt_embeds)
Expand Down
3 changes: 2 additions & 1 deletion examples/community/pipeline_demofusion_sdxl.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def encode_prompt(
)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

prompt_embeds = prompt_embeds.hidden_states[-2]

prompt_embeds_list.append(prompt_embeds)
Expand Down
3 changes: 2 additions & 1 deletion examples/community/pipeline_sdxl_style_aligned.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
3 changes: 2 additions & 1 deletion examples/community/pipeline_stable_diffusion_xl_ipex.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ def encode_prompt(
)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

prompt_embeds = prompt_embeds.hidden_states[-2]

prompt_embeds_list.append(prompt_embeds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ def encode_prompt(
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)

# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
pooled_prompt_embeds = prompt_embeds[0] if pooled_prompt_embeds is None else pooled_prompt_embeds

if clip_skip is None:
prompt_embeds = prompt_embeds.hidden_states[-2]
else:
Expand Down
Loading