Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
norm
vllm
Commits
3363c27d
You need to sign in or sign up before continuing.
Commit
3363c27d
authored
Feb 14, 2023
by
Woosuk Kwon
Browse files
Add __repr__
parent
2729087e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
cacheflow/block.py
cacheflow/block.py
+5
-0
cacheflow/sequence.py
cacheflow/sequence.py
+9
-3
No files found.
cacheflow/block.py
View file @
3363c27d
...
...
@@ -49,3 +49,8 @@ class PhysicalTokenBlock:
self
.
block_size
=
block_size
self
.
ref_count
=
0
def
__repr__
(
self
)
->
str
:
return
(
f
'PhysicalTokenBlock(device=
{
self
.
device
}
, '
f
'block_number=
{
self
.
block_number
}
, '
f
'ref_count=
{
self
.
ref_count
}
)'
)
cacheflow/sequence.py
View file @
3363c27d
...
...
@@ -2,7 +2,6 @@ import enum
from
typing
import
List
,
Optional
from
cacheflow.block
import
LogicalTokenBlock
from
cacheflow.decoding
import
DecodingParams
class
SequenceStatus
(
enum
.
Enum
):
...
...
@@ -58,6 +57,11 @@ class Sequence:
token_ids
.
extend
(
block
.
get_token_ids
())
return
token_ids
def
__repr__
(
self
)
->
str
:
return
(
f
'Sequence(seq_id=
{
self
.
seq_id
}
, '
f
'status=
{
self
.
status
.
name
}
, '
f
'num_blocks=
{
len
(
self
.
logical_token_blocks
)
}
)'
)
class
SequenceGroup
:
...
...
@@ -65,11 +69,9 @@ class SequenceGroup:
self
,
group_id
:
int
,
seqs
:
List
[
Sequence
],
decoding_params
:
DecodingParams
,
)
->
None
:
self
.
group_id
=
group_id
self
.
seqs
=
seqs
self
.
decoding_params
=
decoding_params
def
num_seqs
(
self
,
status
:
Optional
[
SequenceStatus
]
=
None
)
->
int
:
if
status
is
None
:
...
...
@@ -82,3 +84,7 @@ class SequenceGroup:
if
seq
.
seq_id
==
seq_id
:
return
seq
raise
ValueError
(
f
'Sequence
{
seq_id
}
not found.'
)
def
__repr__
(
self
)
->
str
:
return
(
f
'SequenceGroup(group_id=
{
self
.
group_id
}
, '
f
'num_seqs=
{
len
(
self
.
seqs
)
}
)'
)
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