Signed-off-by: Matthew Bonanni <mbonanni@redhat.com> Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com> Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> Signed-off-by: Matthew Bonanni <matthew@neuralmagic.com> Signed-off-by: Nicolò Lucchesi <nicolo.lucchesi@mistral.ai> Co-authored-by: OpenAI Codex <codex@openai.com> Co-authored-by: Lucas Wilkinson <lwilkins@redhat.com> Co-authored-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> Co-authored-by: Nicolò Lucchesi <nicolo.lucchesi@mistral.ai> Co-authored-by: OpenAI Codex <noreply@openai.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Lucas Wilkinson <LucasWilkinson@users.noreply.github.com>
28 lines
991 B
Python
28 lines
991 B
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
|
|
from vllm.distributed.kv_events import KVCacheEvent
|
|
from vllm.v1.core.block_pool import BlockPool
|
|
|
|
|
|
class SharedEventQueueBlockPool(BlockPool):
|
|
"""A pool that publishes into another pool's live KV event queue.
|
|
|
|
The owner rebinds its queue on every drain, so this reads it through the
|
|
owner rather than holding a reference.
|
|
"""
|
|
|
|
def __init__(self, *args, event_owner: BlockPool, **kwargs) -> None:
|
|
self._event_owner = event_owner
|
|
super().__init__(*args, **kwargs)
|
|
|
|
@property
|
|
def kv_event_queue(self) -> list[KVCacheEvent]:
|
|
return self._event_owner.kv_event_queue
|
|
|
|
@kv_event_queue.setter
|
|
def kv_event_queue(self, events: list[KVCacheEvent]) -> None:
|
|
# ``BlockPool.__init__`` seeds an empty queue and ``take_events``
|
|
# swaps in a fresh one; both belong to the owner, which drains it.
|
|
assert not events
|