Unverified Commit e0f63e4a authored by Zebing Lin's avatar Zebing Lin Committed by GitHub
Browse files

[Core] Avoid repeated len(block_token_ids) check in hash_request_tokens (#21781)


Signed-off-by: default avatarlinzebing <linzebing1995@gmail.com>
parent b4e081cb
...@@ -567,12 +567,10 @@ def hash_request_tokens(hash_function: Any, block_size: int, ...@@ -567,12 +567,10 @@ def hash_request_tokens(hash_function: Any, block_size: int,
ret = [] ret = []
parent_block_hash_value = None parent_block_hash_value = None
for start in range(0, len(token_ids), block_size): # Only full blocks will be hashed
for start in range(0, len(token_ids) - block_size + 1, block_size):
end = start + block_size end = start + block_size
block_token_ids = token_ids[start:end] block_token_ids = token_ids[start:end]
# Do not hash the block if it is not full.
if len(block_token_ids) < block_size:
break
if req_need_extra_keys: if req_need_extra_keys:
# MM and LoRA requests need extra keys for block-hash computation. # MM and LoRA requests need extra keys for block-hash computation.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment