Skip to content

Commit

Permalink
Report usage for beam search (#6404)
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-mo authored Jul 15, 2024
1 parent ccb20db commit 32c9d7f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions vllm/sampling_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,18 @@ def __init__(

self._verify_args()
if self.use_beam_search:
# Lazy import to avoid circular imports.
from vllm.usage.usage_lib import set_runtime_usage_data
set_runtime_usage_data("use_beam_search", True)

if not envs.VLLM_NO_DEPRECATION_WARNING:
logger.warning(
"[IMPORTANT] We plan to discontinue the support for beam "
"search in the next major release. Please refer to "
"https://github.com/vllm-project/vllm/issues/6226 for "
"more information. Set VLLM_NO_DEPRECATION_WARNING=1 to "
"suppress this warning.")

self._verify_beam_search()
else:
self._verify_non_beam_search()
Expand Down
15 changes: 13 additions & 2 deletions vllm/usage/usage_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from enum import Enum
from pathlib import Path
from threading import Thread
from typing import Any, Dict, Optional
from typing import Any, Dict, Optional, Union
from uuid import uuid4

import cpuinfo
Expand All @@ -25,6 +25,13 @@
_USAGE_STATS_ENABLED = None
_USAGE_STATS_SERVER = envs.VLLM_USAGE_STATS_SERVER

_GLOBAL_RUNTIME_DATA: Dict[str, Union[str, int, bool]] = {}


def set_runtime_usage_data(key: str, value: Union[str, int, bool]) -> None:
"""Set global usage data that will be sent with every usage heartbeat."""
_GLOBAL_RUNTIME_DATA[key] = value


def is_usage_stats_enabled():
"""Determine whether or not we can send usage stats to the server.
Expand Down Expand Up @@ -187,7 +194,11 @@ def _report_continous_usage(self):
"""
while True:
time.sleep(600)
data = {"uuid": self.uuid, "log_time": _get_current_timestamp_ns()}
data = {
"uuid": self.uuid,
"log_time": _get_current_timestamp_ns(),
}
data.update(_GLOBAL_RUNTIME_DATA)

self._write_to_file(data)
self._send_to_server(data)
Expand Down

0 comments on commit 32c9d7f

Please sign in to comment.