diff --git a/vllm/core/block/block_table.py b/vllm/core/block/block_table.py index 21f98a63ec52c..06b816eb367f5 100644 --- a/vllm/core/block/block_table.py +++ b/vllm/core/block/block_table.py @@ -346,8 +346,8 @@ def get_num_blocks_touched_by_append_slots( num_token_ids = len(token_ids) + num_lookahead_slots first_chunk_size = self._block_size - (self._num_full_slots % self._block_size) - num_token_blocks = ( - 1 + math.ceil(num_token_ids - first_chunk_size / self._block_size)) + num_token_blocks = (1 + math.ceil( + (num_token_ids - first_chunk_size) / self._block_size)) return num_token_blocks def _chunk_token_blocks_for_append( @@ -359,6 +359,7 @@ def _chunk_token_blocks_for_append( """ first_chunk_size = self._block_size - (self._num_full_slots % self._block_size) - token_blocks = [token_ids[:first_chunk_size]] + list( + token_blocks = [token_ids[:first_chunk_size]] + token_blocks.extend( chunk_list(token_ids[first_chunk_size:], self._block_size)) return token_blocks