Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
e461c262
Unverified
Commit
e461c262
authored
Dec 20, 2024
by
yangzhibin
Committed by
GitHub
Dec 19, 2024
Browse files
[Misc] Remove unused vllm/block.py (#11336)
parent
276738ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
90 deletions
+2
-90
vllm/block.py
vllm/block.py
+0
-88
vllm/core/evictor.py
vllm/core/evictor.py
+2
-2
No files found.
vllm/block.py
deleted
100644 → 0
View file @
276738ce
"""Token blocks."""
from
typing
import
TYPE_CHECKING
,
Iterator
,
List
,
Optional
from
vllm.utils
import
Device
DEFAULT_LAST_ACCESSED_TIME
:
float
=
-
1
class
PhysicalTokenBlock
:
"""Represents the state of a block in the KV cache."""
def
__init__
(
self
,
device
:
Device
,
block_number
:
int
,
block_size
:
int
,
block_hash
:
int
,
num_hashed_tokens
:
int
,
)
->
None
:
self
.
device
=
device
self
.
block_number
=
block_number
self
.
block_size
=
block_size
self
.
block_hash
=
block_hash
self
.
num_hashed_tokens
=
num_hashed_tokens
self
.
ref_count
=
0
self
.
last_accessed
=
DEFAULT_LAST_ACCESSED_TIME
self
.
computed
=
False
def
__repr__
(
self
)
->
str
:
return
(
f
'PhysicalTokenBlock(device=
{
self
.
device
}
, '
f
'block_number=
{
self
.
block_number
}
, '
f
'num_hashed_tokens=
{
self
.
num_hashed_tokens
}
, '
f
'ref_count=
{
self
.
ref_count
}
, '
f
'last_accessed=
{
self
.
last_accessed
}
, '
f
'computed=
{
self
.
computed
}
)'
)
class
BlockTable
:
"""Holds a list of blocks with caching of their associated block_ids
"""
def
__init__
(
self
,
blocks
:
Optional
[
List
[
PhysicalTokenBlock
]]
=
None
):
self
.
_blocks
:
List
[
PhysicalTokenBlock
]
=
[]
self
.
_block_ids
:
List
[
int
]
=
[]
if
blocks
is
not
None
:
for
block
in
blocks
:
self
.
append
(
block
)
def
append
(
self
,
block
:
PhysicalTokenBlock
):
self
.
_blocks
.
append
(
block
)
self
.
_block_ids
.
append
(
block
.
block_number
)
def
__len__
(
self
)
->
int
:
return
len
(
self
.
_blocks
)
def
__getitem__
(
self
,
key
):
return
self
.
_blocks
[
key
]
if
TYPE_CHECKING
:
def
__iter__
(
self
)
->
Iterator
[
PhysicalTokenBlock
]:
raise
RuntimeError
(
"Method should be automatically generated"
)
def
__setitem__
(
self
,
key
,
value
):
if
isinstance
(
key
,
slice
):
blocks
=
value
self
.
_blocks
[
key
]
=
blocks
self
.
_block_ids
[
key
]
=
[
b
.
block_number
for
b
in
blocks
]
else
:
block
=
value
self
.
_blocks
[
key
]
=
block
self
.
_block_ids
[
key
]
=
block
.
block_number
def
reset
(
self
):
self
.
_blocks
=
[]
self
.
_block_ids
=
[]
def
copy
(
self
)
->
"BlockTable"
:
return
BlockTable
(
self
.
_blocks
)
def
list
(
self
)
->
List
[
PhysicalTokenBlock
]:
return
self
.
_blocks
def
ids
(
self
)
->
List
[
int
]:
return
self
.
_block_ids
vllm/core/evictor.py
View file @
e461c262
...
@@ -13,7 +13,7 @@ class EvictionPolicy(enum.Enum):
...
@@ -13,7 +13,7 @@ class EvictionPolicy(enum.Enum):
class
Evictor
(
ABC
):
class
Evictor
(
ABC
):
"""The Evictor subclasses should be used by the BlockAllocator class to
"""The Evictor subclasses should be used by the BlockAllocator class to
handle eviction of freed
PhysicalToken
Blocks.
handle eviction of freed Blocks.
"""
"""
@
abstractmethod
@
abstractmethod
...
@@ -70,7 +70,7 @@ class BlockMetaData:
...
@@ -70,7 +70,7 @@ class BlockMetaData:
class
LRUEvictor
(
Evictor
):
class
LRUEvictor
(
Evictor
):
"""Evicts in a least-recently-used order using the last_accessed timestamp
"""Evicts in a least-recently-used order using the last_accessed timestamp
that's recorded in the
PhysicalToken
Block. If there are multiple blocks with
that's recorded in the Block. If there are multiple blocks with
the same last_accessed time, then the one with the largest num_hashed_tokens
the same last_accessed time, then the one with the largest num_hashed_tokens
will be evicted. If two blocks each have the lowest last_accessed time and
will be evicted. If two blocks each have the lowest last_accessed time and
highest num_hashed_tokens value, then one will be chose arbitrarily
highest num_hashed_tokens value, then one will be chose arbitrarily
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment