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
45bfa49c
Unverified
Commit
45bfa49c
authored
Sep 15, 2025
by
Mickaël Seznec
Committed by
GitHub
Sep 15, 2025
Browse files
[Tests] fix initialization of kv hash in tests (#24273)
Signed-off-by:
Mickael Seznec
<
mickael@mistral.ai
>
parent
fd2f1054
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
tests/v1/core/test_kv_cache_utils.py
tests/v1/core/test_kv_cache_utils.py
+10
-7
tests/v1/core/test_prefix_caching.py
tests/v1/core/test_prefix_caching.py
+10
-5
No files found.
tests/v1/core/test_kv_cache_utils.py
View file @
45bfa49c
...
...
@@ -30,6 +30,16 @@ from vllm.v1.request import Request
# yapf: enable
@
pytest
.
fixture
(
autouse
=
True
)
def
_auto_init_hash_fn
(
request
):
hash_fn
:
Callable
if
"hash_fn"
in
request
.
fixturenames
:
hash_fn
=
init_none_hash
(
request
.
getfixturevalue
(
"hash_fn"
))
else
:
hash_fn
=
sha256
init_none_hash
(
hash_fn
)
def
make_request
(
request_id
:
str
,
prompt_token_ids
:
list
[
int
],
...
...
@@ -424,7 +434,6 @@ def test_generate_block_hash_extra_keys_cache_salt():
@
pytest
.
mark
.
parametrize
(
"hash_fn"
,
[
sha256
,
sha256_cbor
])
def
test_hash_block_tokens
(
hash_fn
):
init_none_hash
(
hash_fn
)
parent_block_hash
=
BlockHash
(
b
"123"
)
curr_block_token_ids
=
(
1
,
2
,
3
)
extra_keys
=
(
"key1"
,
"key2"
)
...
...
@@ -437,8 +446,6 @@ def test_hash_block_tokens(hash_fn):
@
pytest
.
mark
.
parametrize
(
"hash_fn"
,
[
sha256
,
sha256_cbor
])
def
test_request_block_hasher
(
hash_fn
):
kv_cache_utils
.
init_none_hash
(
hash_fn
)
request
=
make_request
(
request_id
=
"0"
,
prompt_token_ids
=
[
_
for
_
in
range
(
6
)],
...
...
@@ -461,8 +468,6 @@ def test_request_block_hasher(hash_fn):
@
pytest
.
mark
.
parametrize
(
"hash_fn"
,
[
sha256
,
sha256_cbor
])
def
test_hash_tokens_different_mm_input
(
hash_fn
):
init_none_hash
(
hash_fn
)
request1
=
make_request
(
request_id
=
"0"
,
prompt_token_ids
=
[
_
for
_
in
range
(
6
)],
...
...
@@ -491,8 +496,6 @@ def test_hash_tokens_different_mm_input(hash_fn):
@
pytest
.
mark
.
parametrize
(
"hash_fn"
,
[
sha256
,
sha256_cbor
])
def
test_hash_request_tokens_no_mm_inputs
(
hash_fn
):
kv_cache_utils
.
init_none_hash
(
hash_fn
)
request
=
make_request
(
request_id
=
"0"
,
prompt_token_ids
=
[
_
for
_
in
range
(
6
)],
...
...
tests/v1/core/test_prefix_caching.py
View file @
45bfa49c
...
...
@@ -25,6 +25,16 @@ from vllm.v1.kv_cache_interface import (FullAttentionSpec, KVCacheConfig,
KVCacheGroupSpec
,
SlidingWindowSpec
)
@
pytest
.
fixture
(
autouse
=
True
)
def
_auto_init_hash_fn
(
request
):
hash_fn
:
Callable
if
"hash_fn"
in
request
.
fixturenames
:
hash_fn
=
init_none_hash
(
request
.
getfixturevalue
(
"hash_fn"
))
else
:
hash_fn
=
sha256
init_none_hash
(
hash_fn
)
def
make_request
(
request_id
:
str
,
prompt_token_ids
:
list
[
int
],
...
...
@@ -105,7 +115,6 @@ def make_kv_cache_config_hybrid_model(block_size: int,
@
pytest
.
mark
.
parametrize
(
"hash_fn"
,
[
sha256
,
sha256_cbor
])
def
test_prefill
(
hash_fn
):
init_none_hash
(
hash_fn
)
block_size
=
16
manager
=
KVCacheManager
(
...
...
@@ -736,7 +745,6 @@ def test_cache_blocks(hash_fn):
This is a unit test that tests the correctness of the _cache_full_blocks
function of KVCacheManager.
"""
init_none_hash
(
hash_fn
)
block_size
=
4
block_pool
=
BlockPool
(
...
...
@@ -849,7 +857,6 @@ def test_mm_prefix_caching():
"""
This tests that the multi-modal prefix caching is correct.
"""
kv_cache_utils
.
init_none_hash
(
sha256
)
block_size
=
16
manager
=
KVCacheManager
(
...
...
@@ -942,8 +949,6 @@ def test_cache_key_salting():
This tests that cache salts are applied during hashing and the cache
is separated cache as expected.
"""
kv_cache_utils
.
init_none_hash
(
sha256
)
block_size
=
16
manager
=
KVCacheManager
(
make_kv_cache_config
(
block_size
,
11
),
...
...
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