From 992368522f69aa2df15a3f9539d138498e52c5bf Mon Sep 17 00:00:00 2001 From: yjz <126063153+JianDan0212@users.noreply.github.com> Date: Wed, 1 Apr 2026 18:41:49 +0800 Subject: [PATCH] [KVTransfer] Fix TpKVTopology.is_kv_replicated equality case (#38179) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: JianDan0212 Co-authored-by: Nicolò Lucchesi --- vllm/distributed/kv_transfer/kv_connector/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vllm/distributed/kv_transfer/kv_connector/utils.py b/vllm/distributed/kv_transfer/kv_connector/utils.py index 1f889c6c83..72980a85ab 100644 --- a/vllm/distributed/kv_transfer/kv_connector/utils.py +++ b/vllm/distributed/kv_transfer/kv_connector/utils.py @@ -457,9 +457,11 @@ class TpKVTopology: """ Whether the KV cache is replicated across TP workers due to the number of TP workers being greater than the number of KV heads. + When they are equal, each TP rank still owns one distinct KV head, + so this is not considered replication. """ tp_size = self.remote_tp_size[engine_id] - return tp_size // self.total_num_kv_heads >= 1 + return tp_size > self.total_num_kv_heads def replicates_kv_cache(self, remote_engine_id: EngineId) -> bool: # MLA is always replicated as the hidden dim can't be split.