fix prompt parser with batch size

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-06-26 07:47:03 -04:00
parent 7380c08f8e
commit 4de160608e
3 changed files with 17 additions and 6 deletions
+7 -6
View File
@@ -53,7 +53,8 @@ class PromptEmbedder:
self.negative_prompts = negative_prompts
self.batchsize = len(self.prompts)
self.attention = last_attention
self.allsame = self.compare_prompts() # collapses batched prompts to single prompt if possible
self.allsame = False # dont collapse prompts
# self.allsame = self.compare_prompts() # collapses batched prompts to single prompt if possible
self.steps = steps
self.clip_skip = clip_skip
# All embeds are nested lists, outer list batch length, inner schedule length
@@ -83,7 +84,7 @@ class PromptEmbedder:
self.checkcache(p)
debug(f"Prompt encode: time={(time.time() - t0):.3f}")
def checkcache(self, p):
def checkcache(self, p) -> bool:
if shared.opts.sd_textencoder_cache_size == 0:
return False
if self.scheduled_prompt:
@@ -176,13 +177,13 @@ class PromptEmbedder:
else:
prompt_embed, positive_pooled, negative_embed, negative_pooled = get_weighted_text_embeddings(pipe, positive_prompt, negative_prompt, self.clip_skip)
if prompt_embed is not None:
self.prompt_embeds[batchidx].append(prompt_embed)
self.prompt_embeds[batchidx] = [prompt_embed]
if negative_embed is not None:
self.negative_prompt_embeds[batchidx].append(negative_embed)
self.negative_prompt_embeds[batchidx] = [negative_embed]
if positive_pooled is not None:
self.positive_pooleds[batchidx].append(positive_pooled)
self.positive_pooleds[batchidx] = [positive_pooled]
if negative_pooled is not None:
self.negative_pooleds[batchidx].append(negative_pooled)
self.negative_pooleds[batchidx] = [negative_pooled]
if debug_enabled:
get_tokens(pipe, 'positive', positive_prompt)