[Bugfix][Multimodal] Fix reference counting of the SHM processor cache (#59695)

Signed-off-by: tenotek <50898317+hdq66666@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
tenotek
2026-10-02 22:14:13 +08:00
committed by GitHub
co-authored by Claude Fable 5.1
parent c91dccc080
commit 443dccd3c9
5 changed files with 124 additions and 29 deletions
+4
View File
@@ -377,6 +377,10 @@ class BaseMultiModalProcessorCache(
"""
raise NotImplementedError
def release_sender_touches(self) -> None:
"""Release the items that were touched but not updated afterwards."""
return None
@abstractmethod
def make_stats(self, *, delta: bool = False) -> CacheInfo:
"""Get (and reset) the multi-modal cache stats.
+6 -4
View File
@@ -170,10 +170,13 @@ class ShmObjectStoreSenderCache(BaseMultiModalProcessorCache):
@override
def touch_sender_cache_item(self, mm_hash: str) -> None:
"""Touch the item in shared memory cache to prevent eviction.
Increments writer_flag on sender side."""
"""Touch the item in shared memory cache to prevent eviction."""
self._shm_cache.touch(mm_hash)
@override
def release_sender_touches(self) -> None:
self._shm_cache.release_touches()
@override
def validate_input_item(
self,
@@ -305,8 +308,7 @@ class ShmObjectStoreReceiverCache(BaseMultiModalReceiverCache):
mm_hash: str,
mm_item: MultiModalKwargsItem | None = None,
) -> None:
"""Touch the item in shared memory cache to prevent eviction.
Increments reader_count on receiver side."""
"""Validate the item's handle in shared memory cache."""
assert mm_item is not None
if (handle := _get_shm_handle(mm_item)) is not None:
address, monotonic_id, signature = handle