Test the RunningList Structure.
()
| 9 | |
| 10 | |
| 11 | def check_running_list(): |
| 12 | """ |
| 13 | Test the RunningList Structure. |
| 14 | """ |
| 15 | running_list = RunningList(prefill_ratio=1.2) |
| 16 | seq1 = Sequence( |
| 17 | request_id=1, |
| 18 | prompt="abc", |
| 19 | input_token_id=[1, 2, 3], |
| 20 | block_size=16, |
| 21 | eos_token_id=0, |
| 22 | pad_token_id=0, |
| 23 | sample_params=None, |
| 24 | ) |
| 25 | seq2 = Sequence( |
| 26 | request_id=2, |
| 27 | prompt="abc", |
| 28 | input_token_id=[1, 2, 3], |
| 29 | block_size=16, |
| 30 | eos_token_id=0, |
| 31 | pad_token_id=0, |
| 32 | sample_params=None, |
| 33 | ) |
| 34 | running_list.append(seq1) |
| 35 | running_list.append(seq2) |
| 36 | assert running_list.ready_for_prefill() |
| 37 | assert len(running_list.decoding) == 0 |
| 38 | assert len(running_list.prefill) > 0 and running_list.prefill[0] == seq1 |
| 39 | |
| 40 | seq = running_list.find_seq(seq1.request_id) |
| 41 | assert seq == seq1 |
| 42 | |
| 43 | running_list.mark_prefill_running() |
| 44 | for seq in running_list.prefill: |
| 45 | assert seq.status == RequestStatus.RUNNING |
| 46 | |
| 47 | running_list.move_prefill_to_decoding([seq1.request_id, seq2.request_id]) |
| 48 | assert len(running_list.prefill) == 0 |
| 49 | assert len(running_list.decoding) > 0 and running_list.decoding[0] == seq1 |
| 50 | |
| 51 | running_list.remove(seq1) |
| 52 | running_list.remove(seq2) |
| 53 | assert running_list.is_empty() |
| 54 | |
| 55 | |
| 56 | def check_request_handler(): |
no test coverage detected
searching dependent graphs…