GenAI Bench
repository·main·Indexed 43 days ago
https://github.com/sgl-project/genai-benchA benchmark tool for comprehensive token-level performance evaluation of Large Language Model (LLM) serving systems. Version 0.0.5 supports text and image generation, providing CLI tools for benchmarking, real-time UI monitoring, automated Excel reporting, and performance visualization of metrics like throughput and latency.
What's inside GenAI Bench
- GenAI Bench is a performance evaluation tool designed for comprehensive token-level benchmarking of Large Language Model (LLM) serving systems. It is capable of interacting with multiple cloud providers for both model endpoints and result storage.
Overview of GenAI Bench features
mainGenAI Bench provides a comprehensive suite of tools for LLM benchmarking:
- CLI Tool: Validates inputs and manages benchmark execution.
- Live UI Dashboard: Provides real-time monitoring of progress, logs, and metrics.
- Rich Logs: Automatically saves logs to both the terminal and a file upon completion.
- Experiment Analyzer: Generates Excel reports containing pricing and raw metrics (throughput, latency like TTFT, E2E, TPOT, error rates, and RPS). It also supports generating visualizations with flexible plot configurations (defaulting to a 2x4 grid).
Coding guidelines for genai-bench
mainWhen contributing to
genai-bench, adhere to the following standards:- Python Version: 3.10-3.13.
- Style Guide: Follow the Google Python style guide and PEP 8.
- Type Safety: Use type hints throughout the codebase.
- Documentation: Write docstrings for all public APIs.
- Design: Keep functions focused and small.
- Testing: Add tests for every new feature.
- Formatting/Linting: Refer to the
Makefilefor available linting and formatting commands.
Supported multi-modal task types
mainGenAI Bench supports several task types for different generative AI workloads:
text-to-text: Chat and completion tasks.text-to-embeddings: Embedding generation tasks.image-text-to-text: Vision-language tasks.text-to-rerank: Document reranking tasks.
How tasks and modalities work in genai-bench
mainTasks are driven by two core concepts:
- Input Modality: The type of input data the task operates on (e.g., text or images).
- Output Modality: The type of output the task generates (e.g., text, embeddings, or audio).
When you select a task via the
--taskflag,genai-benchautomatically selects the appropriate internal components, including the correct sampler (TextSamplerorImageSampler) and the corresponding request type (e.g.,UserChatRequest,UserEmbeddingRequest).Understand Single Request Level Metrics
mainSingle-request level metrics capture token-level performance for an individual request, providing insights into server efficiency. Each metric includes standard statistics: percentile, min, max, stddev, and mean.
Key Latency and Speed Metrics
- TTFT (Time to First Token): The initial response time when the first output token is generated (input stage latency). Measured in
seconds. - End-to-End Latency: Total time from query submission to receiving the full response, including network latencies. Measured in
seconds. - TPOT (Time Per Output Token): The average time between two subsequent generated tokens. Measured in
seconds. - Output Latency: Time taken to receive the full response after the first token is generated. Measured in
seconds. - Output Inference Speed: The rate of token generation per second for a single request. Measured in
tokens/second. - Input Throughput: The overall throughput of the input process. Measured in
tokens/second. - Output Throughput: The throughput of output generation for a single request. Measured in
tokens/second.
Token Counting Metrics
- Num of Input Tokens: Number of prompt tokens.
- Num of Output Tokens: Number of completion tokens.
- Num of Request Tokens: Total tokens processed (
input + output). - Num of Reasoning Tokens: Number of reasoning tokens outputted (always $\le$ output tokens).
Task-Specific Metrics
- Embedding Tasks: Since there is no output stage, output metrics are set to
0. - Text-to-Speech (TTS) Tasks:
- TTFB (Time to First Byte): Replaces TTFT; the time until the first audio chunk arrives.
- Audio Throughput: Replaces token-based output metrics; measures the rate of audio data generated per second. Measured in
bytes/second.
- TTFT (Time to First Token): The initial response time when the first output token is generated (input stage latency). Measured in
Understand Aggregated Metrics
mainAggregated level metrics summarize single-request metrics from an entire run, which is defined by a specific traffic scenario and number of concurrency. These metrics provide insights into server capacity and performance under pressure.
Throughput Metrics
- Mean Input Throughput: Average input tokens processed by the model in one run with multiple concurrent requests. Measured in
tokens/second. - Mean Output Throughput: Average output tokens processed by the model in one run with multiple concurrent requests. Measured in
tokens/second. - Total Tokens Throughput: Average throughput of all tokens (input + output) processed during the run. Measured in
tokens/second. - Requests Per Minute: The number of requests processed by the model per minute.
- Mean Input Throughput: Average input tokens processed by the model in one run with multiple concurrent requests. Measured in
Define traffic scenarios for request shaping
mainTraffic scenarios shape the requests during a benchmark run by defining token distributions, budgets, or modality properties. You can pass one or more scenarios using the
--traffic-scenarioflag. If you provide a--dataset-pathwithout any scenarios, the tool defaults todatasetmode, which uses raw entries from your dataset without token shaping.Supported Scenario Formats
Type Format Description Text D(in,out)Deterministic: Exact ininput andoutoutput tokens.N(m_in,s_in)/(m_out,s_out)Normal: Input/output tokens follow a normal distribution with mean and stddev. U(min_in,max_in)/(min_out,max_out)Uniform: Input/output tokens follow a uniform distribution. U(max_in,max_out)Uniform: Only input tokens are shaped. Embeddings E(tokens_per_doc)Fixed tokens per document. Re-Rank R(tokens_per_doc,tokens_per_query)Fixed tokens for documents and queries. Audio A(num_input_chars)Fixed number of input characters. Image I(width,height)Fixed image dimensions. I(width,height,num_images)Fixed dimensions and number of images. Special datasetUse raw dataset entries without shaping. Note: Scenario strings are validated; mistyping a format will trigger an error showing supported types.
# Example: Running with multiple text scenarios (Normal and Deterministic) genai-bench \ --task text-to-text \ --dataset-path prompts.txt \ --traffic-scenario "N(480,240)/(300,150)" \ --traffic-scenario "D(100,1000)" \ --api-backend openai \ --api-base http://localhost:8000 \ --api-model-name gpt-test \ --model-tokenizer gpt2Supported benchmark tasks in GenAI Bench
mainGenAI Bench supports several task types depending on your evaluation needs:
text-to-text: Benchmarks generating text output from text input (e.g., Chat, QA).text-to-embeddings: Benchmarks generating embeddings from text input (e.g., Semantic search).image-text-to-text: Benchmarks generating text from images and text prompts (e.g., Visual question answering).image-to-embeddings: Benchmarks generating embeddings from images (e.g., Image similarity).
Use dataset mode for raw sampling
mainDataset mode is used when you want to sample raw entries from a dataset without applying token shaping or length constraints. This mode is automatically enabled if you provide a
--dataset-pathbut omit the--traffic-scenarioflag. You can also explicitly set it using--traffic-scenario dataset.Behavior by Task
- text-to-text: Picks a single line from the dataset;
max_tokens=Noneandignore_eos=Falseare used to avoid shaping. - text-to-embeddings: Samples
batch_sizelines per request. - text-to-rerank: Samples one query and
batch_sizedocuments. - text-to-image: Picks a single line as the prompt; size/quality use server defaults.
- text-to-speech: Picks a single line as input text; no character-length shaping is applied.
- image-text-to-text / image-to-embeddings: Samples images (defaults to 1 image per request).
# Run using dataset-only mode (no token shaping) genai-bench \ --task text-to-text \ --dataset-path data.csv \ --api-backend openai \ --api-base http://localhost:8000 \ --api-model-name gpt-test \ --model-tokenizer gpt2- text-to-text: Picks a single line from the dataset;
Understand GenAI-bench authentication separation
mainGenAI-bench separates authentication into two distinct categories to allow cross-cloud workflows (e.g., benchmarking a model on one cloud while storing results on another):
- Model Authentication: Used for accessing LLM endpoints (e.g., OpenAI, AWS Bedrock, GCP Vertex AI).
- Storage Authentication: Used for uploading benchmark results to storage services (e.g., AWS S3, OCI Object Storage).
This separation enables flexible benchmarking pipelines where the compute provider and the data storage provider do not need to be the same.
Simulate bursty vs uniform traffic patterns
mainGenAI Bench uses the
--traffic-scenarioflag to control the variability of token lengths, which can be used to simulate different traffic patterns:- Bursty Traffic: Use distributions with high variance, such as a Normal distribution with a large standard deviation.
- Example:
--traffic-scenario "N(512,256)/(512,256)"
- Example:
- Uniform/Consistent Traffic: Use deterministic distributions or distributions with very low variance.
- Example:
--traffic-scenario "D(512,512)"
- Example:
# Bursty pattern example genai-bench benchmark \ --api-backend vllm \ --api-base http://127.0.0.1:8000 \ --api-model-name vllm-model \ --model-tokenizer NousResearch/Hermes-3-Llama-3.1-8B \ --task text-to-text \ --max-requests-per-run 500 \ --max-time-per-run 30 \ --traffic-scenario "N(512,256)/(512,256)" \ --num-concurrency 8 \ --server-engine "vLLM"- Bursty Traffic: Use distributions with high variance, such as a Normal distribution with a large standard deviation.