Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage Stats Collection #2852

Merged
merged 62 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e0e1386
Write info to local json
yhu422 Feb 8, 2024
739f4a1
Merge branch 'main' of github.com:vllm-project/vllm into usage
yhu422 Feb 8, 2024
c33b4cc
add usage context
yhu422 Feb 9, 2024
b74e3a6
removed usage_context from Engine_args
yhu422 Feb 9, 2024
c988e07
Move IO to another process
yhu422 Feb 9, 2024
88c5187
added http request
yhu422 Feb 13, 2024
85adbab
Merge branch 'main' of github.com:vllm-project/vllm into usage
yhu422 Feb 13, 2024
33c9dff
Added additional arg for from_engine_args
yhu422 Feb 13, 2024
ad609f0
comments
yhu422 Feb 13, 2024
8a2f18a
Write info to local json
yhu422 Feb 8, 2024
8e9e5be
Merge branch 'usage' of https://github.com/yhu422/vllm into usage
yhu422 Feb 13, 2024
f537692
Added Comments
yhu422 Feb 13, 2024
0f1ba7f
.
yhu422 Feb 13, 2024
abc3948
Collect usage info on engine initialization
yhu422 Feb 8, 2024
ec54145
Merge branch 'usage' of https://github.com/yhu422/vllm into usage
yhu422 Feb 13, 2024
f84ccaa
Write usage to local file for testing
yhu422 Feb 13, 2024
b08ba86
Fixed Formatting
yhu422 Feb 13, 2024
83ff459
Merge branch 'vllm-project:main' into usage
yhu422 Feb 13, 2024
73b689a
formatting changes
yhu422 Feb 13, 2024
86da72f
Merge branch 'usage' of https://github.com/yhu422/vllm into usage
yhu422 Feb 13, 2024
9c9a188
Minor bug fixed
yhu422 Feb 13, 2024
d2f84cf
tmp
yhu422 Feb 13, 2024
4e888e0
Merge branch 'main' of github.com:vllm-project/vllm into usage
yhu422 Feb 13, 2024
eb48061
Fixed Bug
yhu422 Feb 14, 2024
0684c06
Add Google Cloud Run service URL
yhu422 Feb 14, 2024
8e9890e
More GPU CPU Mem info
yhu422 Feb 16, 2024
5cf652a
Merge branch 'main' of github.com:vllm-project/vllm into usage
yhu422 Feb 27, 2024
d910b05
Added context constant
yhu422 Feb 27, 2024
8cf264b
Formatting & CPU Info
yhu422 Feb 27, 2024
93b8773
Update vllm/usage/usage_lib.py
yhu422 Feb 27, 2024
fe39b84
Added CPU info, new stat file path
yhu422 Feb 27, 2024
fc6e374
added gpu memory
yhu422 Feb 27, 2024
ab23171
added memory
yhu422 Feb 28, 2024
686c84a
Distinguish production/testing usage, added custom domain
yhu422 Mar 1, 2024
877eb78
formatting
yhu422 Mar 1, 2024
bc89a66
Merge branch 'main' of github.com:vllm-project/vllm into usage
yhu422 Mar 1, 2024
36fd304
Merge branch 'main' of github.com:vllm-project/vllm into usage
yhu422 Mar 5, 2024
e54f15b
test/prod distinction
yhu422 Mar 5, 2024
4e35b3b
Remove cpuinfo import
yhu422 Mar 5, 2024
a1597fb
ruff
yhu422 Mar 5, 2024
c580797
Merge branch 'main' of github.com:vllm-project/vllm into usage
yhu422 Mar 14, 2024
84353d4
fixed merge
yhu422 Mar 14, 2024
f2e69fc
Pass up model architecture info for GPUExecutor
yhu422 Mar 14, 2024
4e19967
formatting
yhu422 Mar 14, 2024
f327f3c
formatting
yhu422 Mar 14, 2024
d9c8a44
Get architecture directly from configs
yhu422 Mar 14, 2024
59f0f10
Merge branch 'main' of github.com:vllm-project/vllm into usage
simon-mo Mar 16, 2024
f34259a
edits round
simon-mo Mar 17, 2024
30df77c
ruff
simon-mo Mar 17, 2024
60b652b
Merge branch 'main' of github.com:vllm-project/vllm into usage
simon-mo Mar 28, 2024
be91bab
fix format
simon-mo Mar 28, 2024
4f04743
finish all code level functionality
simon-mo Mar 28, 2024
f4bf862
add wip doc
simon-mo Mar 28, 2024
6b968db
Merge branch 'main' of github.com:vllm-project/vllm into usage
simon-mo Mar 28, 2024
2006788
revert some fixes
simon-mo Mar 28, 2024
db715c8
more fixes
simon-mo Mar 28, 2024
2c1e557
finish doc, readability pass
simon-mo Mar 28, 2024
42e66b8
edit pass
simon-mo Mar 28, 2024
a4e5742
fix doc and isort
simon-mo Mar 28, 2024
9652830
Merge branch 'main' of github.com:vllm-project/vllm into usage
simon-mo Mar 29, 2024
ba63b44
bad merge
simon-mo Mar 29, 2024
58fb78d
add to amd req txt
simon-mo Mar 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .buildkite/test-template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ steps:
nvidia.com/gpu: "{{ step.num_gpus or default_num_gpu }}"
{% endif %}
env:
- name: VLLM_USAGE_SOURCE
value: ci-test
- name: HF_TOKEN
valueFrom:
secretKeyRef:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,7 @@ RUN --mount=type=cache,target=/root/.cache/pip \
COPY --from=build /workspace/vllm/*.so /workspace/vllm/
COPY vllm vllm

ENV VLLM_USAGE_SOURCE production-docker-image

ENTRYPOINT ["python3", "-m", "vllm.entrypoints.openai.api_server"]
#################### OPENAI API SERVER ####################
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Documentation
serving/deploying_with_docker
serving/distributed_serving
serving/metrics
serving/usage_stats
serving/integrations

.. toctree::
Expand Down
57 changes: 57 additions & 0 deletions docs/source/serving/usage_stats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Usage Stats Collection

vLLM collects anonymous usage data by default to help the engineering team better understand which hardware and model configurations are widely used. This data allows them to prioritize their efforts on the most common workloads. The collected data is transparent, does not contain any sensitive information, and will be publicly released for the community's benefit.

## What data is collected?

You can see the up to date list of data collected by vLLM in the [usage_lib.py](https://github.com/vllm-project/vllm/blob/main/vllm/usage/usage_lib.py).

Here is an example as of v0.4.0:

```json
{
"uuid": "fbe880e9-084d-4cab-a395-8984c50f1109",
"provider": "GCP",
"num_cpu": 24,
"cpu_type": "Intel(R) Xeon(R) CPU @ 2.20GHz",
"cpu_family_model_stepping": "6,85,7",
"total_memory": 101261135872,
"architecture": "x86_64",
"platform": "Linux-5.10.0-28-cloud-amd64-x86_64-with-glibc2.31",
"gpu_count": 2,
"gpu_type": "NVIDIA L4",
"gpu_memory_per_device": 23580639232,
"model_architecture": "OPTForCausalLM",
"vllm_version": "0.3.2+cu123",
"context": "LLM_CLASS",
"log_time": 1711663373492490000,
"source": "production",
"dtype": "torch.float16",
"tensor_parallel_size": 1,
"block_size": 16,
"gpu_memory_utilization": 0.9,
"quantization": null,
"kv_cache_dtype": "auto",
"enable_lora": false,
"enable_prefix_caching": false,
"enforce_eager": false,
"disable_custom_all_reduce": true
}
```

You can preview the collected data by running the following command:

```bash
tail ~/.config/vllm/usage_stats.json
```

## Opt-out of Usage Stats Collection

You can opt-out of usage stats collection by setting the VLLM_NO_USAGE_STATS or DO_NOT_TRACK environment variable, or by creating a ~/.config/vllm/do_not_track file:

```bash
# Any of the following methods can disable usage stats collection
export VLLM_NO_USAGE_STATS=1
export DO_NOT_TRACK=1
mkdir -p ~/.config/vllm && touch ~/.config/vllm/do_not_track
```
3 changes: 3 additions & 0 deletions requirements-neuron.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ fastapi
uvicorn[standard]
pydantic >= 2.0 # Required for OpenAI server.
prometheus_client >= 0.18.0
requests
psutil
py-cpuinfo
2 changes: 2 additions & 0 deletions requirements-rocm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake>=3.21
ninja # For faster builds.
typing-extensions>=4.8.0
starlette
requests
py-cpuinfo
psutil
ray >= 2.9
sentencepiece # Required for LLaMA tokenizer.
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ ray >= 2.9
sentencepiece # Required for LLaMA tokenizer.
numpy
torch == 2.1.2
requests
psutil
py-cpuinfo
transformers >= 4.39.1 # Required for StarCoder2 & Llava.
xformers == 0.0.23.post1 # Required for CUDA 12.1.
fastapi
Expand Down
29 changes: 18 additions & 11 deletions vllm/engine/async_llm_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from vllm.outputs import RequestOutput
from vllm.sampling_params import SamplingParams
from vllm.sequence import MultiModalData
from vllm.usage.usage_lib import UsageContext

logger = init_logger(__name__)
ENGINE_ITERATION_TIMEOUT_S = int(
Expand Down Expand Up @@ -319,9 +320,12 @@ def __init__(self,
self._errored_with: Optional[BaseException] = None

@classmethod
def from_engine_args(cls,
engine_args: AsyncEngineArgs,
start_engine_loop: bool = True) -> "AsyncLLMEngine":
def from_engine_args(
cls,
engine_args: AsyncEngineArgs,
start_engine_loop: bool = True,
usage_context: UsageContext = UsageContext.ENGINE_CONTEXT,
) -> "AsyncLLMEngine":
"""Creates an async LLM engine from the engine arguments."""
# Create the engine configs.
engine_configs = engine_args.create_engine_configs()
Expand All @@ -341,14 +345,17 @@ def from_engine_args(cls,
from vllm.executor.gpu_executor import GPUExecutorAsync
executor_class = GPUExecutorAsync
# Create the async LLM engine.
engine = cls(parallel_config.worker_use_ray,
engine_args.engine_use_ray,
*engine_configs,
executor_class,
log_requests=not engine_args.disable_log_requests,
log_stats=not engine_args.disable_log_stats,
max_log_len=engine_args.max_log_len,
start_engine_loop=start_engine_loop)
engine = cls(
parallel_config.worker_use_ray,
engine_args.engine_use_ray,
*engine_configs,
executor_class,
log_requests=not engine_args.disable_log_requests,
log_stats=not engine_args.disable_log_stats,
max_log_len=engine_args.max_log_len,
start_engine_loop=start_engine_loop,
usage_context=usage_context,
)
return engine

@property
Expand Down
53 changes: 49 additions & 4 deletions vllm/engine/llm_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from vllm.executor.executor_base import ExecutorBase
from vllm.logger import init_logger
from vllm.lora.request import LoRARequest
from vllm.model_executor.model_loader import get_architecture_class_name
from vllm.outputs import RequestOutput
from vllm.sampling_params import SamplingParams
from vllm.sequence import (MultiModalData, SamplerOutput, Sequence,
Expand All @@ -21,6 +22,8 @@
from vllm.transformers_utils.detokenizer import Detokenizer
from vllm.transformers_utils.tokenizer_group import (BaseTokenizerGroup,
get_tokenizer_group)
from vllm.usage.usage_lib import (UsageContext, is_usage_stats_enabled,
usage_message)
from vllm.utils import Counter

logger = init_logger(__name__)
Expand Down Expand Up @@ -53,6 +56,7 @@ class LLMEngine:
executor_class: The model executor class for managing distributed
execution.
log_stats: Whether to log statistics.
usage_context: Specified entry point, used for usage info collection
"""

def __init__(
Expand All @@ -66,6 +70,7 @@ def __init__(
vision_language_config: Optional["VisionLanguageConfig"],
executor_class: Type[ExecutorBase],
log_stats: bool,
usage_context: UsageContext = UsageContext.ENGINE_CONTEXT,
) -> None:
logger.info(
f"Initializing an LLM engine (v{vllm.__version__}) with config: "
Expand Down Expand Up @@ -108,6 +113,39 @@ def __init__(
device_config, lora_config,
vision_language_config)

# If usage stat is enabled, collect relevant info.
if is_usage_stats_enabled():
usage_message.report_usage(
get_architecture_class_name(model_config),
usage_context,
extra_kvs={
# Common configuration
"dtype":
str(model_config.dtype),
"tensor_parallel_size":
parallel_config.tensor_parallel_size,
"block_size":
cache_config.block_size,
"gpu_memory_utilization":
cache_config.gpu_memory_utilization,

# Quantization
"quantization":
model_config.quantization,
"kv_cache_dtype":
cache_config.cache_dtype,

# Feature flags
"enable_lora":
bool(lora_config),
"enable_prefix_caching":
cache_config.enable_prefix_caching,
"enforce_eager":
model_config.enforce_eager,
"disable_custom_all_reduce":
parallel_config.disable_custom_all_reduce,
})

# Ping the tokenizer to ensure liveness if it runs in a
# different process.
self.tokenizer.ping()
Expand All @@ -125,7 +163,11 @@ def __init__(
self.stat_logger.info("cache_config", self.cache_config)

@classmethod
def from_engine_args(cls, engine_args: EngineArgs) -> "LLMEngine":
def from_engine_args(
cls,
engine_args: EngineArgs,
usage_context: UsageContext = UsageContext.ENGINE_CONTEXT,
) -> "LLMEngine":
"""Creates an LLM engine from the engine arguments."""
# Create the engine configs.
engine_configs = engine_args.create_engine_configs()
Expand All @@ -147,9 +189,12 @@ def from_engine_args(cls, engine_args: EngineArgs) -> "LLMEngine":
executor_class = GPUExecutor

# Create the LLM engine.
engine = cls(*engine_configs,
executor_class=executor_class,
log_stats=not engine_args.disable_log_stats)
engine = cls(
*engine_configs,
executor_class=executor_class,
log_stats=not engine_args.disable_log_stats,
usage_context=usage_context,
)
return engine

def __reduce__(self):
Expand Down
5 changes: 3 additions & 2 deletions vllm/entrypoints/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from vllm.engine.arg_utils import AsyncEngineArgs
from vllm.engine.async_llm_engine import AsyncLLMEngine
from vllm.sampling_params import SamplingParams
from vllm.usage.usage_lib import UsageContext
from vllm.utils import random_uuid

TIMEOUT_KEEP_ALIVE = 5 # seconds.
Expand Down Expand Up @@ -100,9 +101,9 @@ async def stream_results() -> AsyncGenerator[bytes, None]:
help="FastAPI root_path when app is behind a path based routing proxy")
parser = AsyncEngineArgs.add_cli_args(parser)
args = parser.parse_args()

engine_args = AsyncEngineArgs.from_cli_args(args)
engine = AsyncLLMEngine.from_engine_args(engine_args)
engine = AsyncLLMEngine.from_engine_args(
engine_args, usage_context=UsageContext.API_SERVER)

app.root_path = args.root_path
uvicorn.run(app,
Expand Down
4 changes: 3 additions & 1 deletion vllm/entrypoints/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from vllm.outputs import RequestOutput
from vllm.sampling_params import SamplingParams
from vllm.sequence import MultiModalData
from vllm.usage.usage_lib import UsageContext
from vllm.utils import Counter


Expand Down Expand Up @@ -108,7 +109,8 @@ def __init__(
disable_custom_all_reduce=disable_custom_all_reduce,
**kwargs,
)
self.llm_engine = LLMEngine.from_engine_args(engine_args)
self.llm_engine = LLMEngine.from_engine_args(
engine_args, usage_context=UsageContext.LLM_CLASS)
self.request_counter = Counter()

def get_tokenizer(
Expand Down
5 changes: 3 additions & 2 deletions vllm/entrypoints/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from vllm.entrypoints.openai.serving_chat import OpenAIServingChat
from vllm.entrypoints.openai.serving_completion import OpenAIServingCompletion
from vllm.logger import init_logger
from vllm.usage.usage_lib import UsageContext

TIMEOUT_KEEP_ALIVE = 5 # seconds

Expand Down Expand Up @@ -151,9 +152,9 @@ async def authentication(request: Request, call_next):
served_model = args.served_model_name
else:
served_model = args.model

engine_args = AsyncEngineArgs.from_cli_args(args)
engine = AsyncLLMEngine.from_engine_args(engine_args)
engine = AsyncLLMEngine.from_engine_args(
engine_args, usage_context=UsageContext.OPENAI_API_SERVER)
openai_serving_chat = OpenAIServingChat(engine, served_model,
args.response_role,
args.lora_modules,
Expand Down
13 changes: 9 additions & 4 deletions vllm/model_executor/model_loader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Utilities for selecting and loading models."""
import contextlib
from typing import Type
from typing import Tuple, Type

import torch
import torch.nn as nn
Expand All @@ -25,7 +25,8 @@ def _set_default_torch_dtype(dtype: torch.dtype):
torch.set_default_dtype(old_dtype)


def _get_model_architecture(model_config: ModelConfig) -> Type[nn.Module]:
def _get_model_architecture(
model_config: ModelConfig) -> Tuple[Type[nn.Module], str]:
architectures = getattr(model_config.hf_config, "architectures", [])
# Special handling for quantized Mixtral.
# FIXME(woosuk): This is a temporary hack.
Expand All @@ -36,17 +37,21 @@ def _get_model_architecture(model_config: ModelConfig) -> Type[nn.Module]:
for arch in architectures:
model_cls = ModelRegistry.load_model_cls(arch)
if model_cls is not None:
return model_cls
return (model_cls, arch)
raise ValueError(
f"Model architectures {architectures} are not supported for now. "
f"Supported architectures: {ModelRegistry.get_supported_archs()}")


def get_architecture_class_name(model_config: ModelConfig) -> str:
return _get_model_architecture(model_config)[1]


def get_model(model_config: ModelConfig, device_config: DeviceConfig,
**kwargs) -> nn.Module:
lora_config = kwargs.get("lora_config", None)
vision_language_config = kwargs.get("vision_language_config", None)
model_class = _get_model_architecture(model_config)
model_class = _get_model_architecture(model_config)[0]

# Get the (maybe quantized) linear method.
linear_method = None
Expand Down
Empty file added vllm/usage/__init__.py
Empty file.
Loading
Loading