From 49eb2accf0610d220f451f2f3c1dfe93fe395c79 Mon Sep 17 00:00:00 2001 From: AlexHuang Date: Mon, 7 Sep 2026 16:19:07 +0800 Subject: [PATCH] [KVConnector] Guard lmcache_mp_connector state transition with num_external_tokens (#47505) Signed-off-by: Alex Signed-off-by: Alex-ai-future --- .../kv_transfer/kv_connector/v1/lmcache_mp_connector.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vllm/distributed/kv_transfer/kv_connector/v1/lmcache_mp_connector.py b/vllm/distributed/kv_transfer/kv_connector/v1/lmcache_mp_connector.py index 8786e91a5a..f465fcad92 100644 --- a/vllm/distributed/kv_transfer/kv_connector/v1/lmcache_mp_connector.py +++ b/vllm/distributed/kv_transfer/kv_connector/v1/lmcache_mp_connector.py @@ -835,8 +835,12 @@ class LMCacheMPConnectorUpstream(KVConnectorBase_V1): if new_block_ids: tracker.append_block_ids(new_block_ids) - # Update the state of the tracker - condition = tracker.needs_retrieve() + # num_external_tokens > 0 means this connector is chosen for loading. + # When non-chosen (num_external_tokens == 0, e.g. in MultiConnector), + # force condition=False so the state goes to READY and all lookup locks + # are released — end_session does NOT release lookup locks, so without + # this they would leak until TTL expiry (10 minutes). + condition = tracker.needs_retrieve() and num_external_tokens > 0 if tracker.state == LMCacheMPRequestState.PREFETCHING: # If need to retrieve, change to WAITING_FOR_LOAD # Otherwise, change to READY