[Core][v1] Unify allocating slots in prefill and decode in KV cache manager (#12608)

As mentioned in RFC https://github.com/vllm-project/vllm/issues/12254,
this PR achieves the task: combine allocate_slots and append_slots.

There should be no functionality change, except that in decode, also
raise exception when num_tokens is zero (like prefill), and change the
unit test case accordingly.

@comaniac @rickyyx @WoosukKwon @youkaichao @heheda12345 @simon-mo

---------

Signed-off-by: Shawn Du <shawnd200@outlook.com>
This commit is contained in:
Shawn Du
2025-02-02 16:40:58 +08:00
committed by GitHub
parent abfcdcdf27
commit f8ece6e17f
3 changed files with 78 additions and 116 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ class Scheduler:
assert num_new_tokens > 0
while True:
new_blocks = self.kv_cache_manager.append_slots(
new_blocks = self.kv_cache_manager.allocate_slots(
request, num_new_tokens)
if new_blocks is None:
# The request cannot be scheduled.