@@ -117,7 +117,7 @@ def test_prefill(hash_algo):
117117 blocks = manager .allocate_slots (req0 , 55 ,
118118 len (computed_blocks .blocks [0 ]) * 16 ,
119119 computed_blocks )
120- assert blocks .get_block_ids () == [[ 1 , 2 , 3 , 4 ]]
120+ assert blocks .get_block_ids () == ([ 1 , 2 , 3 , 4 ], )
121121
122122 # Check full block metadata
123123 parent_block_hash = None
@@ -141,14 +141,14 @@ def test_prefill(hash_algo):
141141 req1 = make_request ("1" , common_token_ids + unique_token_ids )
142142 computed_blocks , num_computed_tokens = manager .get_computed_blocks (req1 )
143143 assert len (manager .req_to_block_hashes [req1 .request_id ]) == 3
144- assert computed_blocks .get_block_ids () == [[ 1 , 2 , 3 ]]
144+ assert computed_blocks .get_block_ids () == ([ 1 , 2 , 3 ], )
145145 assert num_computed_tokens == 3 * 16
146146 num_new_tokens = 53 - 3 * 16
147147 blocks = manager .allocate_slots (req1 , num_new_tokens ,
148148 len (computed_blocks .blocks [0 ]) * 16 ,
149149 computed_blocks )
150- assert blocks .get_block_ids () == [[ 5 ]]
151- for block in computed_blocks .blocks [ 0 ] :
150+ assert blocks .get_block_ids () == ([ 5 ], )
151+ for ( block , ) in computed_blocks .blocks :
152152 assert block .ref_cnt == 2
153153
154154 # At this point, we should have 5 free blocks left.
@@ -175,13 +175,13 @@ def test_prefill(hash_algo):
175175 req2 = make_request ("2" , common_token_ids + unique_token_ids )
176176 computed_blocks , num_computed_tokens = manager .get_computed_blocks (req2 )
177177 assert len (manager .req_to_block_hashes [req2 .request_id ]) == 3
178- assert computed_blocks .get_block_ids () == [[ 1 , 2 , 3 ]]
178+ assert computed_blocks .get_block_ids () == ([ 1 , 2 , 3 ], )
179179 assert num_computed_tokens == 3 * 16
180180 num_new_tokens = 53 - 3 * 16
181181 blocks = manager .allocate_slots (req2 , num_new_tokens ,
182182 len (computed_blocks .blocks [0 ]) * 16 ,
183183 computed_blocks )
184- assert blocks .get_block_ids () == [[ 6 ]]
184+ assert blocks .get_block_ids () == ([ 6 ], )
185185
186186 # Although we only have 6 free blocks, we have 8 blocks in
187187 # the free block queue due to lazy removal.
@@ -205,7 +205,7 @@ def test_prefill(hash_algo):
205205 len (computed_blocks .blocks [0 ]) * 16 ,
206206 computed_blocks )
207207 # This block ID order also checks the eviction order.
208- assert blocks .get_block_ids () == [[ 7 , 8 , 9 , 10 , 4 , 5 , 6 , 3 , 2 , 1 ]]
208+ assert blocks .get_block_ids () == ([ 7 , 8 , 9 , 10 , 4 , 5 , 6 , 3 , 2 , 1 ], )
209209 assert manager .block_pool .free_block_queue .num_free_blocks == 0
210210 assert manager .block_pool .free_block_queue .free_list_head is None
211211 assert manager .block_pool .free_block_queue .free_list_tail is None
@@ -236,8 +236,8 @@ def test_prefill_hybrid_model():
236236 blocks = manager .allocate_slots (req0 , 55 ,
237237 len (computed_blocks .blocks [0 ]) * 16 ,
238238 computed_blocks )
239- assert blocks .get_block_ids () == [[ 1 , 2 , 3 , 4 ], [5 , 6 , 7 , 8 ] ,
240- [9 , 10 , 11 , 12 ]]
239+ assert blocks .get_block_ids () == ([ 1 , 2 , 3 , 4 ], [5 , 6 , 7 ,
240+ 8 ], [9 , 10 , 11 , 12 ])
241241
242242 # Check full block metadata
243243 parent_block_hash = None
@@ -263,14 +263,14 @@ def test_prefill_hybrid_model():
263263 req1 = make_request ("1" , common_token_ids + unique_token_ids )
264264 computed_blocks , num_computed_tokens = manager .get_computed_blocks (req1 )
265265 assert len (manager .req_to_block_hashes [req1 .request_id ]) == 3
266- assert computed_blocks .get_block_ids () == [[ 1 , 2 , 3 ], [0 , 6 , 7 ] ,
267- [0 , 10 , 11 ]]
266+ assert computed_blocks .get_block_ids () == ([ 1 , 2 , 3 ], [0 , 6 ,
267+ 7 ], [0 , 10 , 11 ])
268268 assert num_computed_tokens == 3 * 16
269269 num_new_tokens = 53 - 3 * 16
270270 blocks = manager .allocate_slots (req1 , num_new_tokens ,
271271 len (computed_blocks .blocks [0 ]) * 16 ,
272272 computed_blocks )
273- assert blocks .get_block_ids () == [[ 13 ], [14 ], [15 ]]
273+ assert blocks .get_block_ids () == ([ 13 ], [14 ], [15 ])
274274 for block_per_group in computed_blocks .blocks :
275275 for block in block_per_group :
276276 if block != manager .block_pool .null_block :
@@ -374,8 +374,8 @@ def test_prefill_plp():
374374 blocks = manager .allocate_slots (req0 , 55 ,
375375 len (computed_blocks .blocks [0 ]) * 16 ,
376376 computed_blocks )
377- assert blocks .get_block_ids () == [[ 1 , 2 , 3 , 4 ]]
378- req0_block_hashes = [b .block_hash for b in blocks .blocks [ 0 ] ]
377+ assert blocks .get_block_ids () == ([ 1 , 2 , 3 , 4 ], )
378+ req0_block_hashes = [b .block_hash for b in blocks .blocks ]
379379
380380 # Check full block metadata
381381 parent_block_hash = None
@@ -400,14 +400,14 @@ def test_prefill_plp():
400400 req1 = make_request ("1" , common_token_ids + unique_token_ids )
401401 computed_blocks , num_computed_tokens = manager .get_computed_blocks (req1 )
402402 assert len (manager .req_to_block_hashes [req1 .request_id ]) == 3
403- assert computed_blocks .get_block_ids () == [[ 1 , 2 , 3 ]]
403+ assert computed_blocks .get_block_ids () == ([ 1 , 2 , 3 ], )
404404 assert num_computed_tokens == 3 * 16
405405 num_new_tokens = 53 - 3 * 16
406406 blocks = manager .allocate_slots (req1 , num_new_tokens ,
407407 len (computed_blocks .blocks [0 ]) * 16 ,
408408 computed_blocks )
409- assert blocks .get_block_ids () == [[ 5 ]]
410- for block in computed_blocks .blocks [ 0 ] :
409+ assert blocks .get_block_ids () == ([ 5 ], )
410+ for block in computed_blocks .blocks :
411411 assert block .ref_cnt == 2
412412
413413 # At this point, we should have 5 free blocks left.
@@ -443,8 +443,8 @@ def test_prefill_plp():
443443 computed_blocks )
444444 block_ids = blocks .get_block_ids ()
445445 # Duplicate cached blocks have different ids but same hashes vs request #0
446- assert [b .block_hash for b in blocks .blocks [ 0 ] ] == req0_block_hashes
447- assert block_ids != [[ 1 , 2 , 3 , 4 ]]
446+ assert [b .block_hash for b in blocks .blocks ] == req0_block_hashes
447+ assert block_ids != ([ 1 , 2 , 3 , 4 ], )
448448
449449 # Request #2 block hashes are valid since request #0 hashes are.
450450 # Check block reference counts.
@@ -474,7 +474,7 @@ def test_decode():
474474 blocks = manager .allocate_slots (req0 , 55 ,
475475 len (computed_blocks .blocks [0 ]) * 16 ,
476476 computed_blocks )
477- assert blocks .get_block_ids () == [[ 1 , 2 , 3 , 4 ]]
477+ assert blocks .get_block_ids () == ([ 1 , 2 , 3 , 4 ], )
478478
479479 # Append slots without allocating a new block.
480480 req0 .num_computed_tokens = 55
@@ -546,12 +546,12 @@ def test_evict():
546546 # Touch the first 2 blocks.
547547 req2 = make_request ("2" , list (range (2 * 16 + 3 )))
548548 computed_blocks , num_computed_tokens = manager .get_computed_blocks (req2 )
549- assert computed_blocks .get_block_ids () == [[ 1 , 2 ]]
549+ assert computed_blocks .get_block_ids () == ([ 1 , 2 ], )
550550 assert num_computed_tokens == 2 * 16
551551 blocks = manager .allocate_slots (req2 , 3 ,
552552 len (computed_blocks .blocks [0 ]) * 16 ,
553553 computed_blocks )
554- assert blocks .get_block_ids () == [[ 10 ]]
554+ assert blocks .get_block_ids () == ([ 10 ], )
555555 assert manager .block_pool .free_block_queue .num_free_blocks == 7
556556
557557
@@ -865,7 +865,7 @@ def test_mm_prefix_caching():
865865 blocks = manager .allocate_slots (req0 , 59 ,
866866 len (computed_blocks .blocks [0 ]) * 16 ,
867867 computed_blocks )
868- assert blocks .get_block_ids () == [[ 1 , 2 , 3 , 4 ]]
868+ assert blocks .get_block_ids () == ([ 1 , 2 , 3 , 4 ], )
869869 req0 .num_computed_tokens = 59
870870
871871 # Append slots without allocating a new block.
@@ -926,7 +926,7 @@ def test_cache_key_salting():
926926 blocks = manager .allocate_slots (req0 , 59 ,
927927 len (computed_blocks .blocks [0 ]) * 16 ,
928928 computed_blocks )
929- assert blocks .get_block_ids () == [[ 1 , 2 , 3 , 4 ]]
929+ assert blocks .get_block_ids () == ([ 1 , 2 , 3 , 4 ], )
930930 req0 .num_computed_tokens = 59
931931
932932 # Append slots without allocating a new block.
@@ -1042,7 +1042,7 @@ def test_reset_prefix_cache():
10421042 all_token_ids = full_block_token_ids + unique_token_ids
10431043 req0 = make_request ("0" , all_token_ids )
10441044 blocks = manager .allocate_slots (req0 , 55 )
1045- assert blocks .get_block_ids () == [[ 1 , 2 , 3 , 4 ]]
1045+ assert blocks .get_block_ids () == ([ 1 , 2 , 3 , 4 ], )
10461046
10471047 unique_token_ids = [4 ] * 7
10481048 all_token_ids = full_block_token_ids + unique_token_ids
@@ -1053,7 +1053,7 @@ def test_reset_prefix_cache():
10531053 blocks = manager .allocate_slots (req1 , 7 ,
10541054 len (computed_blocks .blocks [0 ]) * 16 ,
10551055 computed_blocks )
1056- assert blocks .get_block_ids () == [[ 5 ]]
1056+ assert blocks .get_block_ids () == ([ 5 ], )
10571057
10581058 # Failed to reset prefix cache because some blocks are not freed yet.
10591059 assert not manager .reset_prefix_cache ()
0 commit comments