mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-07-21 21:01:24 +08:00
llm
This commit is contained in:
parent
96cc89babb
commit
c2fbe299e0
@ -119,7 +119,7 @@ class GemmaTextProcessingEngine:
|
||||
|
||||
zs.extend(line_z_values)
|
||||
|
||||
return torch.stack(zs)
|
||||
return zs
|
||||
|
||||
def process_embeds(self, batch_tokens):
|
||||
device = memory_management.text_encoder_device()
|
||||
|
||||
@ -86,7 +86,7 @@ class Qwen3TextProcessingEngine:
|
||||
|
||||
zs.extend(line_z_values)
|
||||
|
||||
return torch.stack(zs)
|
||||
return zs
|
||||
|
||||
def process_embeds(self, batch_tokens):
|
||||
device = memory_management.text_encoder_device()
|
||||
|
||||
@ -99,7 +99,7 @@ class QwenTextProcessingEngine:
|
||||
|
||||
zs.extend(line_z_values)
|
||||
|
||||
return torch.stack(zs)
|
||||
return zs
|
||||
|
||||
def strip_template(self, out, tokens):
|
||||
template_end = 0
|
||||
|
||||
@ -113,18 +113,18 @@ class UMT5TextProcessingEngine:
|
||||
line_z_values = []
|
||||
|
||||
# pad all chunks to length of longest chunk
|
||||
# max_tokens = 0
|
||||
# for chunk in chunks:
|
||||
# max_tokens = max(len(chunk.tokens), max_tokens)
|
||||
max_tokens = 0
|
||||
for chunk in chunks:
|
||||
max_tokens = max(len(chunk.tokens), max_tokens)
|
||||
|
||||
for chunk in chunks:
|
||||
tokens = chunk.tokens
|
||||
multipliers = chunk.multipliers
|
||||
|
||||
# remaining_count = max_tokens - len(tokens)
|
||||
# if remaining_count > 0:
|
||||
# tokens += [self.pad_token] * remaining_count
|
||||
# multipliers += [1.0] * remaining_count
|
||||
remaining_count = max_tokens - len(tokens)
|
||||
if remaining_count > 0:
|
||||
tokens += [self.id_pad] * remaining_count
|
||||
multipliers += [1.0] * remaining_count
|
||||
|
||||
z = self.process_tokens([tokens], [multipliers])[0]
|
||||
line_z_values.append(z)
|
||||
|
||||
@ -199,12 +199,7 @@ def get_learned_conditioning(model, prompts: SdConditioning | list[str], steps,
|
||||
continue
|
||||
|
||||
texts = SdConditioning([x[1] for x in prompt_schedule], copy_from=prompts)
|
||||
try:
|
||||
conds = model.get_learned_conditioning(texts)
|
||||
except RuntimeError as e:
|
||||
if "stack expects each tensor to be equal size" in repr(e):
|
||||
raise NotImplementedError("Prompt Editing/Alternating is not supported in LLM Text Encoders")
|
||||
raise e
|
||||
conds = model.get_learned_conditioning(texts)
|
||||
|
||||
cond_schedule = []
|
||||
for i, (end_at_step, _) in enumerate(prompt_schedule):
|
||||
|
||||
@ -383,6 +383,8 @@ def forge_model_reload():
|
||||
_cond = sd_model.get_learned_conditioning(SdConditioning([opts.empty_prompt_template]))
|
||||
if isinstance(_cond, dict):
|
||||
_cond = DictWithShape(_cond)
|
||||
elif isinstance(_cond, list):
|
||||
_cond = torch.stack(_cond)
|
||||
|
||||
sd_model.empty_cond = _cond.to(devices.cpu)
|
||||
timer.record("calculate empty prompt")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user