@@ -51,7 +51,7 @@ def test_prefill():
5151 all_token_ids = common_token_ids + unique_token_ids
5252 req0 = make_request ("0" , all_token_ids )
5353 computed_blocks , num_computed_tokens = manager .get_computed_blocks (req0 )
54- assert len (req0 .kv_block_hashes ) == 3
54+ assert len (manager . req_to_block_hashes [ req0 .request_id ] ) == 3
5555 assert not computed_blocks
5656 assert num_computed_tokens == 0
5757 blocks = manager .allocate_slots (req0 , 55 , computed_blocks )
@@ -76,7 +76,7 @@ def test_prefill():
7676 unique_token_ids = [3 ] * 5
7777 req1 = make_request ("1" , common_token_ids + unique_token_ids )
7878 computed_blocks , num_computed_tokens = manager .get_computed_blocks (req1 )
79- assert len (req1 .kv_block_hashes ) == 3
79+ assert len (manager . req_to_block_hashes [ req1 .request_id ] ) == 3
8080 assert [b .block_id for b in computed_blocks ] == [0 , 1 , 2 ]
8181 assert num_computed_tokens == 3 * 16
8282 num_new_tokens = 53 - 3 * 16
@@ -107,7 +107,7 @@ def test_prefill():
107107 unique_token_ids = [3 ] * 6
108108 req2 = make_request ("2" , common_token_ids + unique_token_ids )
109109 computed_blocks , num_computed_tokens = manager .get_computed_blocks (req2 )
110- assert len (req2 .kv_block_hashes ) == 3
110+ assert len (manager . req_to_block_hashes [ req2 .request_id ] ) == 3
111111 assert [b .block_id for b in computed_blocks ] == [0 , 1 , 2 ]
112112 assert num_computed_tokens == 3 * 16
113113 num_new_tokens = 53 - 3 * 16
@@ -494,10 +494,11 @@ def test_mm_prefix_caching():
494494 # Completed block should have hashes with extra keys.
495495 assert not computed_blocks
496496 assert num_computed_tokens == 0
497- assert len (req0 .kv_block_hashes ) == 3
498- assert req0 .kv_block_hashes [0 ].extra_keys == ("aaa" , )
499- assert req0 .kv_block_hashes [1 ].extra_keys == ("aaa" , "bbb" )
500- assert req0 .kv_block_hashes [2 ].extra_keys == ("bbb" , )
497+ block_hashes = manager .req_to_block_hashes [req0 .request_id ]
498+ assert len (block_hashes ) == 3
499+ assert block_hashes [0 ].extra_keys == ("aaa" , )
500+ assert block_hashes [1 ].extra_keys == ("aaa" , "bbb" )
501+ assert block_hashes [2 ].extra_keys == ("bbb" , )
501502
502503 blocks = manager .allocate_slots (req0 , 59 , computed_blocks )
503504 assert [b .block_id for b in blocks ] == [0 , 1 , 2 , 3 , 4 ]
@@ -510,8 +511,8 @@ def test_mm_prefix_caching():
510511 assert new_blocks is not None and len (new_blocks ) == 0
511512
512513 # The just completed block should have hashes with extra keys.
513- assert len (req0 . kv_block_hashes ) == 4
514- assert req0 . kv_block_hashes [3 ].extra_keys == ("ccc" , )
514+ assert len (block_hashes ) == 4
515+ assert block_hashes [3 ].extra_keys == ("ccc" , )
515516
516517 # Cache hit.
517518 unique_token_ids = [- 1 ] * 7 + [200 ] * 5
@@ -613,7 +614,7 @@ def test_reset_prefix_cache():
613614 all_token_ids = full_block_token_ids + unique_token_ids
614615 req1 = make_request ("1" , all_token_ids )
615616 computed_blocks , _ = manager .get_computed_blocks (req1 )
616- assert len (req1 .kv_block_hashes ) == 3
617+ assert len (manager . req_to_block_hashes [ req1 .request_id ] ) == 3
617618 assert len (computed_blocks ) == 3
618619 blocks = manager .allocate_slots (req1 , 7 , computed_blocks )
619620 assert [b .block_id for b in blocks ] == [4 ]
0 commit comments