From cfcd334026389bee862ab390c6ab8125d28d24b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Mulet?= Date: Sun, 12 Apr 2026 00:23:16 +0200 Subject: [PATCH] feat: add BasicCache.clear_all() public API for cache invalidation --- comfy_execution/caching.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/comfy_execution/caching.py b/comfy_execution/caching.py index f9c913bdb..2c2a6f616 100644 --- a/comfy_execution/caching.py +++ b/comfy_execution/caching.py @@ -190,6 +190,17 @@ class BasicCache: for key in to_remove: 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): assert self.initialized self._clean_cache()