[Feature] publisher default set zmq in kv_event config (#26915)

Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
This commit is contained in:
rongfu.leng 2025-10-23 03:19:33 +08:00 committed by GitHub
parent 1651003c35
commit 8669c69afa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View File

@ -2,6 +2,9 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from typing import Literal
from pydantic import Field
from pydantic.dataclasses import dataclass from pydantic.dataclasses import dataclass
from vllm.config.utils import config from vllm.config.utils import config
@ -17,7 +20,7 @@ class KVEventsConfig:
Events can be published externally by zmq using the event publisher config. Events can be published externally by zmq using the event publisher config.
""" """
publisher: str = "null" publisher: Literal["null", "zmq"] = Field(default=None)
"""The publisher to use for publishing kv events. Can be "null", "zmq". """The publisher to use for publishing kv events. Can be "null", "zmq".
""" """
@ -47,3 +50,7 @@ class KVEventsConfig:
"""The topic to use for the event publisher. Consumers can subscribe to """The topic to use for the event publisher. Consumers can subscribe to
this topic to receive events. this topic to receive events.
""" """
def __post_init__(self):
if self.publisher is None:
self.publisher = "zmq" if self.enable_kv_cache_events else "null"

View File

@ -353,12 +353,12 @@ class EventPublisherFactory:
cls, config: KVEventsConfig | None, data_parallel_rank: int = 0 cls, config: KVEventsConfig | None, data_parallel_rank: int = 0
) -> EventPublisher: ) -> EventPublisher:
"""Create publisher from a config mapping.""" """Create publisher from a config mapping."""
if not config: if config is None or config.publisher == "null":
return NullEventPublisher() return NullEventPublisher()
config_dict = asdict(config) config_dict = asdict(config)
kind = config_dict.pop("publisher", "null") kind = config_dict.pop("publisher")
config_dict.pop("enable_kv_cache_events") config_dict.pop("enable_kv_cache_events")
try: try:
constructor = cls._registry[kind] constructor = cls._registry[kind]