Skip to content

Commit

Permalink
fix block manager interface for can_allocate
Browse files Browse the repository at this point in the history
  • Loading branch information
Varun Sundar Rabindranath committed Sep 18, 2024
1 parent cf01bc2 commit dd2932e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion vllm/core/block_manager_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,15 @@ def __init__(
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:
def can_allocate(self,
seq_group: SequenceGroup,
num_lookahead_slots: int = 0) -> AllocStatus:
# FIXME(woosuk): Here we assume that all sequences in the group share
# the same prompt. This may not be true for preempted sequences.

assert (num_lookahead_slots == 0
), "lookahead allocation not supported in BlockSpaceManagerV1"

check_no_caching_or_swa_for_blockmgr_encdec(self, seq_group)

self_num_required_blocks = self._get_seq_num_required_blocks(
Expand Down
4 changes: 3 additions & 1 deletion vllm/core/embedding_model_block_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def __init__(
) -> None:
pass

def can_allocate(self, seq_group: SequenceGroup) -> AllocStatus:
def can_allocate(self,
seq_group: SequenceGroup,
num_lookahead_slots: int = 0) -> AllocStatus:
# Always return OK for dummy purposes
return AllocStatus.OK

Expand Down
4 changes: 3 additions & 1 deletion vllm/core/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def get_block_space_manager_class(version: str):
raise ValueError(f"Unknown version {version=}")

@abstractmethod
def can_allocate(self, seq_group: SequenceGroup) -> AllocStatus:
def can_allocate(self,
seq_group: SequenceGroup,
num_lookahead_slots: int = 0) -> AllocStatus:
pass

@abstractmethod
Expand Down

0 comments on commit dd2932e

Please sign in to comment.