Skip to content

Commit 96927ea

Browse files
authored
[block manager] fix a bug of calc physical block id of hpu (#1987)
reserved block needs to be considered in the calculation
1 parent 75237d1 commit 96927ea

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

vllm/core/block/cpu_gpu_block_allocator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,12 @@ def get_physical_block_id(self, device: Device, absolute_id: int) -> int:
253253
Returns:
254254
int: The zero-offset block id on certain device.
255255
"""
256-
return self._allocators[device].get_physical_block_id(absolute_id)
256+
base = self._allocators[device].get_physical_block_id(absolute_id)
257+
if device == Device.GPU and current_platform.is_hpu():
258+
reserved_block = 1 # align with reserved blocks in create()
259+
else:
260+
reserved_block = 0
261+
return base + reserved_block
257262

258263
def swap(self, blocks: List[Block], src_device: Device,
259264
dst_device: Device) -> Dict[int, int]:

0 commit comments

Comments
 (0)