From 747484cb64c8fe2f5477f6a432ab079b1795f88f Mon Sep 17 00:00:00 2001 From: xleoken Date: Tue, 24 Feb 2026 15:29:30 +0800 Subject: [PATCH] [Bugfix] Fix wrong computed_tokens when meet exception. (#6522) ### What this PR does / why we need it? Fix wrong computed_tokens when meet exception. This pull request addresses a bug in the KV transfer mechanism where an exception during token lookup operations could lead to an incorrect count of computed_tokens. By modifying the exception handling in both the lookup and lookup_scheduler functions to return 0 instead of the start index, the system now correctly indicates that no tokens were successfully processed when a remote connection failure occurs. This enhancement improves the robustness and accuracy of token management within the vllm_ascend distributed KV pool. ### Does this PR introduce _any_ user-facing change? NO. ### How was this patch tested? Signed-off-by: xleoken --- .../kv_transfer/kv_pool/ascend_store/pool_worker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vllm_ascend/distributed/kv_transfer/kv_pool/ascend_store/pool_worker.py b/vllm_ascend/distributed/kv_transfer/kv_pool/ascend_store/pool_worker.py index f82c8fcb..c3f016b7 100644 --- a/vllm_ascend/distributed/kv_transfer/kv_pool/ascend_store/pool_worker.py +++ b/vllm_ascend/distributed/kv_transfer/kv_pool/ascend_store/pool_worker.py @@ -572,7 +572,7 @@ class KVPoolWorker: # all tokens where found, return the maximal end except Exception as e: logger.error(f"Remote connection failed in contains: {e}") - return start + return 0 return end def lookup_scheduler( @@ -629,7 +629,7 @@ class KVPoolWorker: # all tokens where found, return the maximal end except Exception as e: logger.error(f"Remote connection failed in contains: {e}") - return start + return 0 return end def check_all_layers_exists(self, res: list[int], num_layers: int) -> list[int]: