Skip to content

Commit 8669c69

Browse files
[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>
1 parent 1651003 commit 8669c69

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

vllm/config/kv_events.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
33

44

5+
from typing import Literal
6+
7+
from pydantic import Field
58
from pydantic.dataclasses import dataclass
69

710
from vllm.config.utils import config
@@ -17,7 +20,7 @@ class KVEventsConfig:
1720
Events can be published externally by zmq using the event publisher config.
1821
"""
1922

20-
publisher: str = "null"
23+
publisher: Literal["null", "zmq"] = Field(default=None)
2124
"""The publisher to use for publishing kv events. Can be "null", "zmq".
2225
"""
2326

@@ -47,3 +50,7 @@ class KVEventsConfig:
4750
"""The topic to use for the event publisher. Consumers can subscribe to
4851
this topic to receive events.
4952
"""
53+
54+
def __post_init__(self):
55+
if self.publisher is None:
56+
self.publisher = "zmq" if self.enable_kv_cache_events else "null"

vllm/distributed/kv_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,12 @@ def create(
353353
cls, config: KVEventsConfig | None, data_parallel_rank: int = 0
354354
) -> EventPublisher:
355355
"""Create publisher from a config mapping."""
356-
if not config:
356+
if config is None or config.publisher == "null":
357357
return NullEventPublisher()
358358

359359
config_dict = asdict(config)
360360

361-
kind = config_dict.pop("publisher", "null")
361+
kind = config_dict.pop("publisher")
362362
config_dict.pop("enable_kv_cache_events")
363363
try:
364364
constructor = cls._registry[kind]

0 commit comments

Comments
 (0)