feat: add BasicCache.clear_all() public API for cache invalidation

This commit is contained in:
Julián Mulet 2026-04-12 00:23:16 +02:00
parent a134423890
commit cfcd334026
No known key found for this signature in database

View File

@ -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()