mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-26 02:12:31 +08:00
caching: Remove model awareness from RAM caching
Model RAM pressure is now implemented via the DynamicVRAM system.
This commit is contained in:
parent
2a1f402601
commit
56fe08648c
@ -300,9 +300,6 @@ class ModelPatcher:
|
|||||||
def model_mmap_residency(self, free=False):
|
def model_mmap_residency(self, free=False):
|
||||||
return comfy.model_management.module_mmap_residency(self.model, free=free)
|
return comfy.model_management.module_mmap_residency(self.model, free=free)
|
||||||
|
|
||||||
def get_ram_usage(self):
|
|
||||||
return self.model_size()
|
|
||||||
|
|
||||||
def loaded_size(self):
|
def loaded_size(self):
|
||||||
return self.model.model_loaded_weight_memory
|
return self.model.model_loaded_weight_memory
|
||||||
|
|
||||||
|
|||||||
@ -280,9 +280,6 @@ class CLIP:
|
|||||||
n.apply_hooks_to_conds = self.apply_hooks_to_conds
|
n.apply_hooks_to_conds = self.apply_hooks_to_conds
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def get_ram_usage(self):
|
|
||||||
return self.patcher.get_ram_usage()
|
|
||||||
|
|
||||||
def add_patches(self, patches, strength_patch=1.0, strength_model=1.0):
|
def add_patches(self, patches, strength_patch=1.0, strength_model=1.0):
|
||||||
return self.patcher.add_patches(patches, strength_patch, strength_model)
|
return self.patcher.add_patches(patches, strength_patch, strength_model)
|
||||||
|
|
||||||
@ -840,9 +837,6 @@ class VAE:
|
|||||||
self.size = comfy.model_management.module_size(self.first_stage_model)
|
self.size = comfy.model_management.module_size(self.first_stage_model)
|
||||||
return self.size
|
return self.size
|
||||||
|
|
||||||
def get_ram_usage(self):
|
|
||||||
return self.model_size()
|
|
||||||
|
|
||||||
def throw_exception_if_invalid(self):
|
def throw_exception_if_invalid(self):
|
||||||
if self.first_stage_model is None:
|
if self.first_stage_model is None:
|
||||||
raise RuntimeError("ERROR: VAE is invalid: None\n\nIf the VAE is from a checkpoint loader node your checkpoint does not contain a valid VAE.")
|
raise RuntimeError("ERROR: VAE is invalid: None\n\nIf the VAE is from a checkpoint loader node your checkpoint does not contain a valid VAE.")
|
||||||
|
|||||||
@ -494,10 +494,10 @@ class LRUCache(BasicCache):
|
|||||||
|
|
||||||
RAM_CACHE_HYSTERESIS = 1.1
|
RAM_CACHE_HYSTERESIS = 1.1
|
||||||
|
|
||||||
#This is kinda in GB but not really. It needs to be non-zero for the below heuristic
|
#Small baseline weight used when a cache entry has no measurable CPU tensors.
|
||||||
#and as long as Multi GB models dwarf this it will approximate OOM scoring OK
|
#Keeps unknown-sized entries in eviction scoring without dominating tensor-backed entries.
|
||||||
|
|
||||||
RAM_CACHE_DEFAULT_RAM_USAGE = 0.1
|
RAM_CACHE_DEFAULT_RAM_USAGE = 0.05
|
||||||
|
|
||||||
#Exponential bias towards evicting older workflows so garbage will be taken out
|
#Exponential bias towards evicting older workflows so garbage will be taken out
|
||||||
#in constantly changing setups.
|
#in constantly changing setups.
|
||||||
@ -545,11 +545,7 @@ class RAMPressureCache(LRUCache):
|
|||||||
if isinstance(output, list):
|
if isinstance(output, list):
|
||||||
scan_list_for_ram_usage(output)
|
scan_list_for_ram_usage(output)
|
||||||
elif isinstance(output, torch.Tensor) and output.device.type == 'cpu':
|
elif isinstance(output, torch.Tensor) and output.device.type == 'cpu':
|
||||||
#score Tensors at a 50% discount for RAM usage as they are likely to
|
ram_usage += output.numel() * output.element_size()
|
||||||
#be high value intermediates
|
|
||||||
ram_usage += (output.numel() * output.element_size()) * 0.5
|
|
||||||
elif hasattr(output, "get_ram_usage"):
|
|
||||||
ram_usage += output.get_ram_usage()
|
|
||||||
scan_list_for_ram_usage(outputs)
|
scan_list_for_ram_usage(outputs)
|
||||||
|
|
||||||
oom_score *= ram_usage
|
oom_score *= ram_usage
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user