A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 14, 22:35 UTC
[Core] Avoid repeated len(block_token_ids) check in hash_request_tokens (#21781)
Signed-off-by: linzebing <linzebing1995@gmail.com>
Zebing Lin committed
Aug 1, 2025 at 03:23 UTC
e0f63e4a3509a9323339eee67c96ac3c93d15923
1 file changed
+2
-4
vllm/v1/core/kv_cache_utils.py
+2
-4
@@ -567,12 +567,10 @@ def hash_request_tokens(hash_function: Any, block_size: int,
567
568
ret = []
569
parent_block_hash_value = None
570
- for start in range(0, len(token_ids), block_size):
570
+ # Only full blocks will be hashed
571
+ for start in range(0, len(token_ids) - block_size + 1, block_size):
572
end = start + block_size
573
block_token_ids = token_ids[start:end]
573
- # Do not hash the block if it is not full.
574
- if len(block_token_ids) < block_size:
575
- break
574
575
if req_need_extra_keys:
576
# MM and LoRA requests need extra keys for block-hash computation.