mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-08-16 02:56:36 +08:00
Fix missing LazyCache check_metadata method
Ensure LazyCache reset method resets all the tensor state values
This commit is contained in:
parent
ba601f1bba
commit
d675140bdf
@ -287,7 +287,7 @@ class EasyCacheHolder:
|
|||||||
return self.first_cond_uuid in uuids
|
return self.first_cond_uuid in uuids
|
||||||
|
|
||||||
def check_metadata(self, x: torch.Tensor) -> bool:
|
def check_metadata(self, x: torch.Tensor) -> bool:
|
||||||
metadata = (x.device, x.dtype, x.shape)
|
metadata = (x.device, x.dtype, x.shape[1:])
|
||||||
if self.state_metadata is None:
|
if self.state_metadata is None:
|
||||||
self.state_metadata = metadata
|
self.state_metadata = metadata
|
||||||
return True
|
return True
|
||||||
@ -375,6 +375,7 @@ class LazyCacheHolder:
|
|||||||
self.output_change_rates = []
|
self.output_change_rates = []
|
||||||
self.approx_output_change_rates = []
|
self.approx_output_change_rates = []
|
||||||
self.total_steps_skipped = 0
|
self.total_steps_skipped = 0
|
||||||
|
self.state_metadata = None
|
||||||
|
|
||||||
def has_cache_diff(self) -> bool:
|
def has_cache_diff(self) -> bool:
|
||||||
return self.cache_diff is not None
|
return self.cache_diff is not None
|
||||||
@ -419,6 +420,17 @@ class LazyCacheHolder:
|
|||||||
def update_cache_diff(self, output: torch.Tensor, x: torch.Tensor):
|
def update_cache_diff(self, output: torch.Tensor, x: torch.Tensor):
|
||||||
self.cache_diff = output - x
|
self.cache_diff = output - x
|
||||||
|
|
||||||
|
def check_metadata(self, x: torch.Tensor) -> bool:
|
||||||
|
metadata = (x.device, x.dtype, x.shape)
|
||||||
|
if self.state_metadata is None:
|
||||||
|
self.state_metadata = metadata
|
||||||
|
return True
|
||||||
|
if metadata == self.state_metadata:
|
||||||
|
return True
|
||||||
|
logging.warn(f"{self.name} - Tensor shape, dtype or device changed, resetting state")
|
||||||
|
self.reset()
|
||||||
|
return False
|
||||||
|
|
||||||
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
|
||||||
@ -427,7 +439,14 @@ class LazyCacheHolder:
|
|||||||
self.approx_output_change_rates = []
|
self.approx_output_change_rates = []
|
||||||
del self.cache_diff
|
del self.cache_diff
|
||||||
self.cache_diff = None
|
self.cache_diff = None
|
||||||
|
del self.x_prev_subsampled
|
||||||
|
self.x_prev_subsampled = None
|
||||||
|
del self.output_prev_subsampled
|
||||||
|
self.output_prev_subsampled = None
|
||||||
|
del self.output_prev_norm
|
||||||
|
self.output_prev_norm = None
|
||||||
self.total_steps_skipped = 0
|
self.total_steps_skipped = 0
|
||||||
|
self.state_metadata = None
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def clone(self):
|
def clone(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user