Skip to content

Commit 57e8a11

Browse files
committed
enable cond cache by default
1 parent f9950da commit 57e8a11

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

‎modules/processing.py‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def close(self):
295295
self.sampler = None
296296
self.c = None
297297
self.uc = None
298-
if not opts.experimental_persistent_cond_cache:
298+
if not opts.persistent_cond_cache:
299299
StableDiffusionProcessing.cached_c = [None, None]
300300
StableDiffusionProcessing.cached_uc = [None, None]
301301

@@ -319,6 +319,21 @@ def setup_prompts(self):
319319
self.all_prompts = [shared.prompt_styles.apply_styles_to_prompt(x, self.styles) for x in self.all_prompts]
320320
self.all_negative_prompts = [shared.prompt_styles.apply_negative_styles_to_prompt(x, self.styles) for x in self.all_negative_prompts]
321321

322+
def cached_params(self, required_prompts, steps, extra_network_data):
323+
"""Returns parameters that invalidate the cond cache if changed"""
324+
325+
return (
326+
required_prompts,
327+
steps,
328+
opts.CLIP_stop_at_last_layers,
329+
shared.sd_model.sd_checkpoint_info,
330+
extra_network_data,
331+
opts.sdxl_crop_left,
332+
opts.sdxl_crop_top,
333+
self.width,
334+
self.height,
335+
)
336+
322337
def get_conds_with_caching(self, function, required_prompts, steps, caches, extra_network_data):
323338
"""
324339
Returns the result of calling function(shared.sd_model, required_prompts, steps)
@@ -332,17 +347,7 @@ def get_conds_with_caching(self, function, required_prompts, steps, caches, extr
332347
caches is a list with items described above.
333348
"""
334349

335-
cached_params = (
336-
required_prompts,
337-
steps,
338-
opts.CLIP_stop_at_last_layers,
339-
shared.sd_model.sd_checkpoint_info,
340-
extra_network_data,
341-
opts.sdxl_crop_left,
342-
opts.sdxl_crop_top,
343-
self.width,
344-
self.height,
345-
)
350+
cached_params = self.cached_params(required_prompts, steps, extra_network_data)
346351

347352
for cache in caches:
348353
if cache[0] is not None and cached_params == cache[0]:
@@ -1184,7 +1189,7 @@ def close(self):
11841189
super().close()
11851190
self.hr_c = None
11861191
self.hr_uc = None
1187-
if not opts.experimental_persistent_cond_cache:
1192+
if not opts.persistent_cond_cache:
11881193
StableDiffusionProcessingTxt2Img.cached_hr_uc = [None, None]
11891194
StableDiffusionProcessingTxt2Img.cached_hr_c = [None, None]
11901195

‎modules/shared.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def list_samplers():
506506
"token_merging_ratio_img2img": OptionInfo(0.0, "Token merging ratio for img2img", gr.Slider, {"minimum": 0.0, "maximum": 0.9, "step": 0.1}).info("only applies if non-zero and overrides above"),
507507
"token_merging_ratio_hr": OptionInfo(0.0, "Token merging ratio for high-res pass", gr.Slider, {"minimum": 0.0, "maximum": 0.9, "step": 0.1}).info("only applies if non-zero and overrides above"),
508508
"pad_cond_uncond": OptionInfo(False, "Pad prompt/negative prompt to be same length").info("improves performance when prompt and negative prompt have different lengths; changes seeds"),
509-
"experimental_persistent_cond_cache": OptionInfo(False, "persistent cond cache").info("Experimental, keep cond caches across jobs, reduce overhead."),
509+
"persistent_cond_cache": OptionInfo(True, "Persistent cond cache").info("Do not recalculate conds from prompts if prompts have not changed since previous calculation"),
510510
}))
511511

512512
options_templates.update(options_section(('compatibility', "Compatibility"), {

0 commit comments

Comments
 (0)