Skip to content

Commit 8c3230d

Browse files
authored
[V1] Simpify vision block hash for prefix caching by removing offset from hash (#11646)
1 parent 2c57188 commit 8c3230d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tests/v1/core/test_prefix_caching.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,9 @@ def test_mm_prefix_caching():
469469
# Completed block should have hashes with extra keys.
470470
assert not computed_blocks
471471
assert len(req0.kv_block_hashes) == 3
472-
assert req0.kv_block_hashes[0].extra_keys == (("aaa", 0), )
473-
assert req0.kv_block_hashes[1].extra_keys == (("aaa", 5), ("bbb", 0))
474-
assert req0.kv_block_hashes[2].extra_keys == (("bbb", 2), )
472+
assert req0.kv_block_hashes[0].extra_keys == ("aaa", )
473+
assert req0.kv_block_hashes[1].extra_keys == ("aaa", "bbb")
474+
assert req0.kv_block_hashes[2].extra_keys == ("bbb", )
475475

476476
blocks = manager.allocate_slots(req0, 59, computed_blocks)
477477
assert [b.block_id for b in blocks] == [0, 1, 2, 3, 4]
@@ -485,7 +485,7 @@ def test_mm_prefix_caching():
485485

486486
# The just completed block should have hashes with extra keys.
487487
assert len(req0.kv_block_hashes) == 4
488-
assert req0.kv_block_hashes[3].extra_keys == (("ccc", 0), )
488+
assert req0.kv_block_hashes[3].extra_keys == ("ccc", )
489489

490490
# Cache hit.
491491
unique_token_ids = [-1] * 7 + [200] * 5

vllm/v1/core/kv_cache_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ def generate_block_hash_extra_keys(
218218
continue
219219

220220
# The block contains the current mm input.
221-
mm_start = max(0, start_token_idx - offset)
222-
extra_keys.append((mm_hashes[curr_mm_idx], mm_start))
221+
extra_keys.append(mm_hashes[curr_mm_idx])
222+
223223
if end_token_idx >= offset + length:
224224
# If this block contains the end of the current mm input,
225225
# move to the next mm input as this block may also contain

0 commit comments

Comments
 (0)