[Bugfix][KV Cache] Fix incremental multimodal block hashing (#51694)
Signed-off-by: Jellow <49915976+CZT0@users.noreply.github.com> Signed-off-by: Jellow <dvdx@foxmail.com>
This commit is contained in:
@@ -1018,6 +1018,37 @@ def test_request_block_hasher(hash_fn):
|
||||
assert block_hashes[1] == hash_fn((block_hashes[0], (3, 4, 5), (("hash2", 0),)))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("hash_fn", [sha256, sha256_cbor])
|
||||
def test_request_block_hasher_incremental_append_with_multiple_mm_features(hash_fn):
|
||||
mm_positions = [
|
||||
PlaceholderRange(offset=4, length=2),
|
||||
PlaceholderRange(offset=6, length=1),
|
||||
]
|
||||
incremental = make_request(
|
||||
request_id="incremental",
|
||||
prompt_token_ids=list(range(7)),
|
||||
block_size=4,
|
||||
hash_fn=hash_fn,
|
||||
mm_positions=mm_positions,
|
||||
mm_hashes=["A", "B"],
|
||||
)
|
||||
incremental.append_output_token_ids(7)
|
||||
fresh = make_request(
|
||||
request_id="fresh",
|
||||
prompt_token_ids=list(range(8)),
|
||||
block_size=4,
|
||||
hash_fn=hash_fn,
|
||||
mm_positions=mm_positions,
|
||||
mm_hashes=["A", "B"],
|
||||
)
|
||||
|
||||
expected_second_hash = hash_fn(
|
||||
(incremental.block_hashes[0], (4, 5, 6, 7), (("A", 0), ("B", 2)))
|
||||
)
|
||||
assert incremental.block_hashes[1] == expected_second_hash
|
||||
assert incremental.block_hashes == fresh.block_hashes
|
||||
|
||||
|
||||
@pytest.mark.parametrize("hash_fn", [sha256, sha256_cbor])
|
||||
def test_hash_tokens_different_mm_input(hash_fn):
|
||||
request1 = make_request(
|
||||
|
||||
Reference in New Issue
Block a user