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
3f331398
Unverified
Commit
3f331398
authored
Sep 15, 2025
by
Ning Xie
Committed by
GitHub
Sep 15, 2025
Browse files
[kv cache] update num_free_blocks in the end (#24228)
Signed-off-by:
Andy Xie
<
andy.xning@gmail.com
>
parent
78818dd1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
tests/v1/core/test_kv_cache_utils.py
tests/v1/core/test_kv_cache_utils.py
+12
-0
vllm/v1/core/kv_cache_utils.py
vllm/v1/core/kv_cache_utils.py
+2
-1
No files found.
tests/v1/core/test_kv_cache_utils.py
View file @
3f331398
...
...
@@ -243,6 +243,18 @@ def test_free_kv_cache_block_queue_append_n():
assert
blocks
[
3
].
next_free_block
is
queue
.
fake_free_list_tail
assert
queue
.
fake_free_list_tail
.
prev_free_block
is
blocks
[
3
]
# Create an empty FreeKVCacheBlockQueue
invalid_queue
=
FreeKVCacheBlockQueue
([])
# set prev_free_block to None and this will cause assertation in append_n
invalid_queue
.
fake_free_list_tail
.
prev_free_block
=
None
with
pytest
.
raises
(
AssertionError
):
# Append 1 block
# fake_head->fake_tail
invalid_queue
.
append_n
(
blocks
[
0
:
1
])
assert
invalid_queue
.
num_free_blocks
==
0
assert
(
invalid_queue
.
fake_free_list_head
.
next_free_block
==
invalid_queue
.
fake_free_list_tail
)
def
test_free_kv_cache_block_queue_popleft_n
():
blocks
=
[
KVCacheBlock
(
block_id
=
i
)
for
i
in
range
(
6
)]
...
...
vllm/v1/core/kv_cache_utils.py
View file @
3f331398
...
...
@@ -370,7 +370,6 @@ class FreeKVCacheBlockQueue:
"""
if
len
(
blocks
)
==
0
:
return
self
.
num_free_blocks
+=
len
(
blocks
)
last_block
=
self
.
fake_free_list_tail
.
prev_free_block
assert
last_block
is
not
None
,
(
...
...
@@ -385,6 +384,8 @@ class FreeKVCacheBlockQueue:
last_block
.
next_free_block
=
self
.
fake_free_list_tail
self
.
fake_free_list_tail
.
prev_free_block
=
last_block
self
.
num_free_blocks
+=
len
(
blocks
)
def
get_all_free_blocks
(
self
)
->
list
[
KVCacheBlock
]:
"""Get all free blocks in the free list. Mainly used for testing.
...
...
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