mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-08-16 01:36:41 +08:00
Make log statement when not skipping useful, preparing for per-cond caching
This commit is contained in:
parent
14a3f02d8d
commit
54f2ef67bb
@ -22,6 +22,9 @@ def easycache_forward_wrapper(executor, *args, **kwargs):
|
|||||||
output_prev_norm = None
|
output_prev_norm = None
|
||||||
input_change = None
|
input_change = None
|
||||||
if do_easycache:
|
if do_easycache:
|
||||||
|
if easycache.initial_step:
|
||||||
|
easycache.first_cond_uuid = transformer_options["uuids"][0]
|
||||||
|
easycache.initial_step = False
|
||||||
if easycache.has_x_prev():
|
if easycache.has_x_prev():
|
||||||
input_change = (x - easycache.x_prev).flatten().abs().mean()
|
input_change = (x - easycache.x_prev).flatten().abs().mean()
|
||||||
if easycache.has_output_prev() and easycache.has_relative_transformation_rate():
|
if easycache.has_output_prev() and easycache.has_relative_transformation_rate():
|
||||||
@ -32,9 +35,9 @@ def easycache_forward_wrapper(executor, *args, **kwargs):
|
|||||||
logging.info(f"easycache_wrapper: skipping step; cumulative_change_rate: {easycache.cumulative_change_rate}, reuse_threshold: {easycache.reuse_threshold}")
|
logging.info(f"easycache_wrapper: skipping step; cumulative_change_rate: {easycache.cumulative_change_rate}, reuse_threshold: {easycache.reuse_threshold}")
|
||||||
return x + easycache.cache_diff
|
return x + easycache.cache_diff
|
||||||
else:
|
else:
|
||||||
easycache.cumulative_change_rate = 0.0
|
|
||||||
logging.info(f"easycache_wrapper: NOT skipping step; cumulative_change_rate: {easycache.cumulative_change_rate}, reuse_threshold: {easycache.reuse_threshold}")
|
logging.info(f"easycache_wrapper: NOT skipping step; cumulative_change_rate: {easycache.cumulative_change_rate}, reuse_threshold: {easycache.reuse_threshold}")
|
||||||
logging.info(f"easycache_wrapper: approx_output_change_rate: {approx_output_change_rate}")
|
logging.info(f"easycache_wrapper: approx_output_change_rate: {approx_output_change_rate}")
|
||||||
|
easycache.cumulative_change_rate = 0.0
|
||||||
|
|
||||||
output: torch.Tensor = executor(*args, **kwargs)
|
output: torch.Tensor = executor(*args, **kwargs)
|
||||||
if easycache.has_output_prev():
|
if easycache.has_output_prev():
|
||||||
@ -55,6 +58,12 @@ def easycache_forward_wrapper(executor, *args, **kwargs):
|
|||||||
easycache.output_prev = output.clone()
|
easycache.output_prev = output.clone()
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
def easycache_calc_cond_batch_wrapper(executor, *args, **kwargs):
|
||||||
|
model_options = args[-1]
|
||||||
|
easycache: EasyCacheHolder = model_options["transformer_options"]["easycache"]
|
||||||
|
easycache.skip_current_step = False
|
||||||
|
return executor(*args, **kwargs)
|
||||||
|
|
||||||
def easycache_sample_wrapper(executor, *args, **kwargs):
|
def easycache_sample_wrapper(executor, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
guider = executor.class_obj
|
guider = executor.class_obj
|
||||||
@ -83,7 +92,10 @@ class EasyCacheHolder:
|
|||||||
# control values
|
# control values
|
||||||
self.relative_transformation_rate: float = None
|
self.relative_transformation_rate: float = None
|
||||||
self.cumulative_change_rate = 0.0
|
self.cumulative_change_rate = 0.0
|
||||||
|
self.initial_step = True
|
||||||
|
self.skip_current_step = False
|
||||||
# cache values
|
# cache values
|
||||||
|
self.first_cond_uuid = None
|
||||||
self.x_prev = None
|
self.x_prev = None
|
||||||
self.output_prev = None
|
self.output_prev = None
|
||||||
self.cache_diff = None
|
self.cache_diff = None
|
||||||
@ -122,7 +134,10 @@ class EasyCacheHolder:
|
|||||||
def reset(self):
|
def reset(self):
|
||||||
self.relative_transformation_rate = 0.0
|
self.relative_transformation_rate = 0.0
|
||||||
self.cumulative_change_rate = 0.0
|
self.cumulative_change_rate = 0.0
|
||||||
|
self.initial_step = True
|
||||||
|
self.skip_current_step = False
|
||||||
self.output_change_rates = []
|
self.output_change_rates = []
|
||||||
|
self.first_cond_uuid = None
|
||||||
del self.x_prev
|
del self.x_prev
|
||||||
self.x_prev = None
|
self.x_prev = None
|
||||||
del self.output_prev
|
del self.output_prev
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user