Files
vllm-omni/vllm_omni/core/sched/utils.py
T

22 lines
910 B
Python
Raw Normal View History

+1
2026-06-01 11:08:12 +08:00
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""Shared utilities for omni schedulers."""
from vllm.v1.core.kv_cache_manager import KVCacheManager
from vllm.v1.request import Request
+1
2026-06-01 11:08:12 +08:00
def free_kv_blocks_in_physical_order(manager: KVCacheManager, request: Request) -> None:
"""Return non-cached request blocks in increasing physical order.
vLLM's block pool deliberately honors the eviction-priority order passed
to ``free_blocks``. For a non-caching P/D pool there is no LRU priority to
preserve, so physical order lets native connectors coalesce adjacent
source/destination pages on the next allocation.
"""
if manager.enable_caching:
manager.free(request)
return
blocks = manager.pop_blocks_for_free(request)
manager.block_pool.free_blocks(sorted(blocks, key=lambda block: block.block_id))