[mypy] Enable mypy type checking for vllm/core (#7229)

This commit is contained in:
Jonathan Berkhahn
2024-08-28 07:11:14 +08:00
committed by GitHub
parent 5340a2dccf
commit 9c71c97ae2
9 changed files with 31 additions and 18 deletions
+4 -3
View File
@@ -278,7 +278,7 @@ class BlockSpaceManagerV1(BlockSpaceManager):
# request ID
self.cross_block_tables: Dict[str, BlockTable] = {}
def _get_seq_num_required_blocks(self, seq: Sequence) -> int:
def _get_seq_num_required_blocks(self, seq: Optional[Sequence]) -> int:
return 0 if seq is None else seq.n_blocks
def can_allocate(self, seq_group: SequenceGroup) -> AllocStatus:
@@ -310,13 +310,14 @@ class BlockSpaceManagerV1(BlockSpaceManager):
return AllocStatus.LATER
def _allocate_sequence(self, \
seq: Sequence, \
seq: Optional[Sequence], \
ref_count: int, \
is_encoder_decoder: bool = True) -> BlockTable:
# Allocate new physical token blocks that will store the prompt tokens.
num_prompt_blocks = seq.n_blocks
num_prompt_blocks = self._get_seq_num_required_blocks(seq)
block_table: BlockTable = BlockTable()
assert seq is not None
for logical_idx in range(num_prompt_blocks):
if (self.block_sliding_window is not None
and logical_idx >= self.block_sliding_window):