mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-14 07:54:58 +08:00
Use the type BlockTable (#1791)
This commit is contained in:
parent
708e6c18b0
commit
6ed068a71a
@ -7,6 +7,10 @@ from vllm.sequence import Sequence, SequenceGroup, SequenceStatus
|
|||||||
from vllm.utils import Device
|
from vllm.utils import Device
|
||||||
|
|
||||||
|
|
||||||
|
# Mapping: logical block number -> physical block.
|
||||||
|
BlockTable = List[PhysicalTokenBlock]
|
||||||
|
|
||||||
|
|
||||||
class BlockAllocator:
|
class BlockAllocator:
|
||||||
"""Manages free physical token blocks for a device.
|
"""Manages free physical token blocks for a device.
|
||||||
|
|
||||||
@ -26,7 +30,7 @@ class BlockAllocator:
|
|||||||
self.num_blocks = num_blocks
|
self.num_blocks = num_blocks
|
||||||
|
|
||||||
# Initialize the free blocks.
|
# Initialize the free blocks.
|
||||||
self.free_blocks: List[PhysicalTokenBlock] = []
|
self.free_blocks: BlockTable = []
|
||||||
for i in range(num_blocks):
|
for i in range(num_blocks):
|
||||||
block = PhysicalTokenBlock(device=device,
|
block = PhysicalTokenBlock(device=device,
|
||||||
block_number=i,
|
block_number=i,
|
||||||
@ -51,10 +55,6 @@ class BlockAllocator:
|
|||||||
return len(self.free_blocks)
|
return len(self.free_blocks)
|
||||||
|
|
||||||
|
|
||||||
# Mapping: logical block number -> physical block.
|
|
||||||
BlockTable = List[PhysicalTokenBlock]
|
|
||||||
|
|
||||||
|
|
||||||
class AllocStatus(enum.Enum):
|
class AllocStatus(enum.Enum):
|
||||||
"""Result for BlockSpaceManager.can_allocate
|
"""Result for BlockSpaceManager.can_allocate
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user