| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | |
| 5 | from typing import Literal |
| 6 | |
| 7 | from vllm.config.utils import config |
| 8 | |
| 9 | |
| 10 | @config |
| 11 | class KVEventsConfig: |
| 12 | """Configuration for KV event publishing.""" |
| 13 | |
| 14 | enable_kv_cache_events: bool = False |
| 15 | """If True, enable KV cache events for tracking block storage and removal. |
| 16 | Events can be published externally by zmq using the event publisher config. |
| 17 | """ |
| 18 | |
| 19 | publisher: Literal["null", "zmq"] = None # type: ignore[assignment] |
| 20 | """The publisher to use for publishing kv events. Can be "null", "zmq". |
| 21 | """ |
| 22 | |
| 23 | endpoint: str = "tcp://*:5557" |
| 24 | """The zmq endpoint to use for publishing kv events. |
| 25 | """ |
| 26 | |
| 27 | replay_endpoint: str | None = None |
| 28 | """The zmq endpoint to use for replaying kv events. |
| 29 | """ |
| 30 | |
| 31 | buffer_steps: int = 10_000 |
| 32 | """The number of steps to cache for replay endpoint. Will only save |
| 33 | events from the last N steps for the replay endpoint. |
| 34 | """ |
| 35 | |
| 36 | hwm: int = 100_000 |
| 37 | """The zmq high water mark for the event publisher. After queueing N events, |
| 38 | events will start dropping if the consumer is not keeping up. |
| 39 | """ |
| 40 | |
| 41 | max_queue_size: int = 100_000 |
| 42 | """The maximum number of events to queue while waiting for publishing. |
| 43 | """ |
| 44 | |
| 45 | topic: str = "" |
| 46 | """The topic to use for the event publisher. Consumers can subscribe to |
| 47 | this topic to receive events. |
| 48 | """ |
| 49 | |
| 50 | def __post_init__(self): |
| 51 | if self.publisher is None: |
| 52 | self.publisher = "zmq" if self.enable_kv_cache_events else "null" |