[Bugfix] Honor skip_reading_prefix_cache for KV connector hits (#57269)
Signed-off-by: aoshen02 <aoshen02@users.noreply.github.com> Co-authored-by: aoshen02 <aoshen02@users.noreply.github.com>
aoshen02 committed
Sep 17, 2026 at 18:46 UTC
9ff08f9493aa745b0559c02cf6148f71d9817169
2 files changed
+21
tests/v1/core/test_scheduler.py
+19
@@ -2302,6 +2302,25 @@ def test_has_sync_kv_loads(
2302
assert output.has_sync_kv_loads is expected_has_sync_loads
2303
2304
2305
+def test_kv_connector_honors_skip_reading_prefix_cache():
2306
+ """A request that must score every prompt row takes no external hit."""
2307
+ BLOCK_SIZE = 16
2308
+ scheduler = create_scheduler(
2309
+ enable_prefix_caching=True,
2310
+ use_kv_connector=mock_kv(matched_tokens=BLOCK_SIZE * 2, is_async=False),
2311
+ block_size=BLOCK_SIZE,
2312
+ )
2313
+ plain, scoring = create_requests(num_requests=2, num_tokens=BLOCK_SIZE * 4)
2314
+ scoring.sampling_params.prompt_logprobs = 1
2315
+ scoring.skip_reading_prefix_cache = True
2316
+ scheduler.add_request(plain)
2317
+ scheduler.add_request(scoring)
2318
+
2319
+ output = scheduler.schedule()
2320
+ assert output.num_scheduled_tokens[plain.request_id] == BLOCK_SIZE * 2
2321
+ assert output.num_scheduled_tokens[scoring.request_id] == BLOCK_SIZE * 4
2322
+
2323
+
2324
@pytest.mark.parametrize("is_async", [False, True])
2325
def test_kv_connector_basic(is_async: bool):
2326
"""Test whether Scheduler with KVConnector schedules tokens, allocates
vllm/v1/core/sched/scheduler.py
+2
@@ -935,6 +935,8 @@ class Scheduler(SchedulerInterface):
935
request, block_aligned_local
936
)
937
)
938
+ if request.skip_reading_prefix_cache:
939
+ ext_tokens, load_kv_async = 0, False
940
941
if ext_tokens is None:
942
# The request cannot be scheduled because