mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-15 04:52:31 +08:00
feat: add BasicCache.clear_all() public API for cache invalidation
This commit is contained in:
parent
a134423890
commit
cfcd334026
@ -190,6 +190,17 @@ class BasicCache:
|
|||||||
for key in to_remove:
|
for key in to_remove:
|
||||||
del self.subcaches[key]
|
del self.subcaches[key]
|
||||||
|
|
||||||
|
def clear_all(self):
|
||||||
|
"""Drop all cached outputs unconditionally.
|
||||||
|
|
||||||
|
This is the public API for external subsystems (e.g. aggressive model
|
||||||
|
offloading) that need to invalidate every cached result — for instance
|
||||||
|
after model parameters have been moved to the ``meta`` device and the
|
||||||
|
cached tensors are no longer usable.
|
||||||
|
"""
|
||||||
|
self.cache.clear()
|
||||||
|
self.subcaches.clear()
|
||||||
|
|
||||||
def clean_unused(self):
|
def clean_unused(self):
|
||||||
assert self.initialized
|
assert self.initialized
|
||||||
self._clean_cache()
|
self._clean_cache()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user