(allocator: BlockAllocator)
| 82 | |
| 83 | |
| 84 | def test_basic_free(allocator: BlockAllocator): |
| 85 | allocator.sanity_checks() |
| 86 | |
| 87 | input_ids1 = [1] * 31 |
| 88 | input_ids2 = [2] * 31 |
| 89 | input_ids3 = [3] * 31 |
| 90 | |
| 91 | completion_ids1 = input_ids1 + [1] |
| 92 | completion_ids2 = input_ids2 + [2] |
| 93 | |
| 94 | kvs1, num_cached1 = allocator.allocate_with_prefix_match("seq1", input_ids1) |
| 95 | allocator.sanity_checks() |
| 96 | |
| 97 | with pytest.raises(ValueError): |
| 98 | allocator.allocate_with_prefix_match("seq2", input_ids2) |
| 99 | |
| 100 | kvs1.extend(allocator.allocate_up_to_length("seq1", kvs1, len(completion_ids1))) |
| 101 | allocator.sanity_checks() |
| 102 | allocator.free_and_update("seq1", kvs1, completion_ids1) |
| 103 | allocator.sanity_checks() |
| 104 | |
| 105 | kvs2, num_cached2 = allocator.allocate_with_prefix_match("seq2", input_ids2) |
| 106 | allocator.sanity_checks() |
| 107 | |
| 108 | assert num_cached2 == 0 |
| 109 | |
| 110 | kvs2.extend(allocator.allocate_up_to_length("seq2", kvs2, len(completion_ids2))) |
| 111 | allocator.sanity_checks() |
| 112 | allocator.free_and_update("seq2", kvs2, completion_ids2) |
| 113 | allocator.sanity_checks() |
| 114 | |
| 115 | kvs3, num_cached3 = allocator.allocate_with_prefix_match("seq3", input_ids3) |
| 116 | allocator.sanity_checks() |
| 117 | |
| 118 | assert num_cached3 == 0 |
| 119 | |
| 120 | |
| 121 | def test_multi_branch_free(allocator: BlockAllocator): |
nothing calls this directly
no test coverage detected