mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
fix(prompt): cache list prompts again
0dbe27c37 keyed the prompt cache on the negative prompt and the cfg flag
and hashed both prompts to tuples for it. The positive prompt was hashed
before the list check that builds the key, so a list prompt, which is what
every pipeline passes, was never stored or found and the text encoder ran
on every generation. Only the negative prompt needs hashing.
This commit is contained in:
@@ -22,7 +22,6 @@ class PromptCache:
|
||||
self.cache.clear()
|
||||
self.id = id(shared.sd_model)
|
||||
log.debug(f'Encode: prompt cache activate id={self.id} depth={len(self.cache)}')
|
||||
prompt = self._hashable(prompt)
|
||||
negative_prompt = self._hashable(negative_prompt)
|
||||
if (isinstance(prompt, list) and len(prompt) == 1 and isinstance(prompt[0], str)):
|
||||
cached = self.cache.get((prompt[0], negative_prompt, cfg_enabled), None)
|
||||
@@ -41,7 +40,6 @@ class PromptCache:
|
||||
if len(self.cache) >= self.max:
|
||||
oldest_key = next(iter(self.cache))
|
||||
del self.cache[oldest_key]
|
||||
prompt = self._hashable(prompt)
|
||||
negative_prompt = self._hashable(negative_prompt)
|
||||
if (isinstance(prompt, list) and len(prompt) == 1 and isinstance(prompt[0], str)):
|
||||
self.cache[(prompt[0], negative_prompt, cfg_enabled)] = encoded
|
||||
|
||||
Reference in New Issue
Block a user