mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-09-09 09:47:02 +08:00
[v1] Add __repr__ to KVCacheBlock to avoid recursive print (#14081)
This commit is contained in:
parent
b9f1d4294e
commit
d54990da47
@ -128,6 +128,19 @@ class KVCacheBlock:
|
|||||||
"""Reset the block hash when the block is evicted."""
|
"""Reset the block hash when the block is evicted."""
|
||||||
self._block_hash = None
|
self._block_hash = None
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
# Use block_id instead of KVCacheBlock object to avoid calling __repr__
|
||||||
|
# on KVCacheBlock object recursively.
|
||||||
|
prev_block_id = self.prev_free_block.block_id \
|
||||||
|
if self.prev_free_block else None
|
||||||
|
next_block_id = self.next_free_block.block_id \
|
||||||
|
if self.next_free_block else None
|
||||||
|
return (f"KVCacheBlock(block_id={self.block_id}, "
|
||||||
|
f"ref_cnt={self.ref_cnt}, "
|
||||||
|
f"_block_hash={self._block_hash}, "
|
||||||
|
f"prev_free_block={prev_block_id}, "
|
||||||
|
f"next_free_block={next_block_id})")
|
||||||
|
|
||||||
|
|
||||||
class FreeKVCacheBlockQueue:
|
class FreeKVCacheBlockQueue:
|
||||||
"""This class organizes a list of KVCacheBlock objects to a doubly linked
|
"""This class organizes a list of KVCacheBlock objects to a doubly linked
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user