fix(qwen-image): drop the shadowed dead _get_qwen_prompt_embeds duplicate (#7461)

Signed-off-by: Anai-Guo <antai12232931@outlook.com>
This commit is contained in:
Tai An authored and GitHub committed 2026-09-14 13:48:51 +00:00
1 parent 3d793481a0
commit 1b6cd282f0
1 file changed
-45
@@ -374,51 +374,6 @@ class QwenImageEditPipeline(
return split_result
def _get_qwen_prompt_embeds(
self,
prompt: str | list[str] = None,
image: torch.Tensor | None = None,
dtype: torch.dtype | None = None,
):
dtype = dtype or self.text_encoder.dtype
prompt = [prompt] if isinstance(prompt, str) else prompt
template = self.prompt_template_encode
drop_idx = self.prompt_template_encode_start_idx
txt = [template.format(e) for e in prompt]
model_inputs = self.processor(
text=txt,
images=image,
padding=True,
return_tensors="pt",
).to(self.device)
outputs = self.text_encoder(
input_ids=model_inputs.input_ids,
attention_mask=model_inputs.attention_mask,
pixel_values=model_inputs.pixel_values,
image_grid_thw=model_inputs.image_grid_thw,
output_hidden_states=True,
)
hidden_states = outputs.hidden_states[-1]
split_hidden_states = self._extract_masked_hidden(hidden_states, model_inputs.attention_mask)
split_hidden_states = [e[drop_idx:] for e in split_hidden_states]
attn_mask_list = [torch.ones(e.size(0), dtype=torch.long, device=e.device) for e in split_hidden_states]
max_seq_len = max([e.size(0) for e in split_hidden_states])
prompt_embeds = torch.stack(
[torch.cat([u, u.new_zeros(max_seq_len - u.size(0), u.size(1))]) for u in split_hidden_states]
)
encoder_attention_mask = torch.stack(
[torch.cat([u, u.new_zeros(max_seq_len - u.size(0))]) for u in attn_mask_list]
)
prompt_embeds = prompt_embeds.to(dtype=dtype, device=self.device)
return prompt_embeds, encoder_attention_mask
def _get_qwen_prompt_embeds(
self,
prompt: str | list[str] = None,