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
94176712
Unverified
Commit
94176712
authored
Jan 03, 2024
by
Woosuk Kwon
Committed by
GitHub
Jan 03, 2024
Browse files
Revert the changes in test_cache (#2335)
parent
74d8d776
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
tests/kernels/test_cache.py
tests/kernels/test_cache.py
+12
-12
No files found.
tests/kernels/test_cache.py
View file @
94176712
...
@@ -49,13 +49,12 @@ def test_copy_blocks(
...
@@ -49,13 +49,12 @@ def test_copy_blocks(
src_blocks
=
random
.
sample
(
range
(
num_blocks
),
num_mappings
)
src_blocks
=
random
.
sample
(
range
(
num_blocks
),
num_mappings
)
remainig_blocks
=
list
(
set
(
range
(
num_blocks
))
-
set
(
src_blocks
))
remainig_blocks
=
list
(
set
(
range
(
num_blocks
))
-
set
(
src_blocks
))
dst_blocks
=
random
.
sample
(
remainig_blocks
,
2
*
num_mappings
)
dst_blocks
=
random
.
sample
(
remainig_blocks
,
2
*
num_mappings
)
copy_src
=
[]
block_mapping
=
{}
copy_dst
=
[]
for
i
in
range
(
num_mappings
):
for
i
in
range
(
num_mappings
):
copy_src
.
append
(
src_blocks
[
i
]
)
src
=
src_blocks
[
i
]
copy_dst
.
append
(
dst_blocks
[
2
*
i
]
)
dst1
=
dst_blocks
[
2
*
i
]
copy_src
.
append
(
src_blocks
[
i
])
dst2
=
dst_blocks
[
2
*
i
+
1
]
copy_dst
.
append
(
dst_blocks
[
2
*
i
+
1
])
block_mapping
[
src
]
=
[
dst1
,
dst2
]
# Create the KV caches.
# Create the KV caches.
key_caches
,
value_caches
=
kv_cache_factory
(
num_blocks
,
block_size
,
key_caches
,
value_caches
=
kv_cache_factory
(
num_blocks
,
block_size
,
...
@@ -67,14 +66,15 @@ def test_copy_blocks(
...
@@ -67,14 +66,15 @@ def test_copy_blocks(
cloned_value_caches
=
[
value_cache
.
clone
()
for
value_cache
in
value_caches
]
cloned_value_caches
=
[
value_cache
.
clone
()
for
value_cache
in
value_caches
]
# Call the copy blocks kernel.
# Call the copy blocks kernel.
cache_ops
.
copy_blocks
(
key_caches
,
value_caches
,
copy_src
,
copy_dst
)
cache_ops
.
copy_blocks
(
key_caches
,
value_caches
,
block_mapping
)
# Run the reference implementation.
# Run the reference implementation.
for
src
,
dst
in
zip
(
copy_src
,
copy_dst
):
for
src
,
dsts
in
block_mapping
.
items
():
for
cloned_key_cache
in
cloned_key_caches
:
for
dst
in
dsts
:
cloned_key_cache
[
dst
].
copy_
(
cloned_key_cache
[
src
])
for
cloned_key_cache
in
cloned_key_caches
:
for
cloned_value_cache
in
cloned_value_caches
:
cloned_key_cache
[
dst
].
copy_
(
cloned_key_cache
[
src
])
cloned_value_cache
[
dst
].
copy_
(
cloned_value_cache
[
src
])
for
cloned_value_cache
in
cloned_value_caches
:
cloned_value_cache
[
dst
].
copy_
(
cloned_value_cache
[
src
])
# Compare the results.
# Compare the results.
for
key_cache
,
cloned_key_cache
in
zip
(
key_caches
,
cloned_key_caches
):
for
key_cache
,
cloned_key_cache
in
zip
(
key_caches
,
cloned_key_caches
):
...
...
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