trtllm-bench#
trtllm-bench is a comprehensive benchmarking tool for TensorRT LLM engines. It provides three main subcommands for different benchmarking scenarios:
Note
Non-breaking: --config <file.yaml> is the preferred flag for passing a YAML configuration file.
Existing workflows using --extra_llm_api_options <file.yaml> continue to work; it is an equivalent alias.
Syntax#
Dataset preparation#
prepare_dataset.py#
trtllm-bench is designed to work with the prepare_dataset.py script, which generates benchmark datasets in the required format. The prepare_dataset script supports:
Dataset Types:
Real datasets from various sources
Synthetic datasets with normal or uniform token distributions
LoRA task-specific datasets
Key Features:
Tokenizer integration for proper text preprocessing
Configurable random seeds for reproducible results
Support for LoRA adapters and task IDs
Output in JSON format compatible with trtllm-bench
Important
The --stdout flag is required when using prepare_dataset.py with trtllm-bench to ensure proper data streaming format.
Usage:
prepare_dataset#
python prepare_dataset.py [OPTIONS]
Options
Option |
Description |
|---|---|
|
Tokenizer directory or HuggingFace model name (required) |
|
Output JSON filename (default: preprocessed_dataset.json) |
|
Print output to stdout with JSON dataset entry on each line (required for trtllm-bench) |
|
Random seed for token generation (default: 420) |
|
LoRA task ID (default: -1) |
|
Random LoRA task range (two integers) |
|
Directory containing LoRA adapters |
|
Logging level: info or debug (default: info) |
dataset#
Process real datasets from various sources.
python prepare_dataset.py dataset [OPTIONS]
Options
Option |
Description |
|---|---|
|
Input dataset file or directory (required) |
|
Maximum input sequence length (default: 2048) |
|
Maximum output sequence length (default: 512) |
|
Number of samples to process (default: all) |
|
Input format: json, jsonl, csv, or txt (default: auto-detect) |
token_norm_dist#
Generate synthetic datasets with normal token distribution.
python prepare_dataset.py token_norm_dist [OPTIONS]
Options
Option |
Description |
|---|---|
|
Number of requests to be generated (required) |
|
Normal distribution mean for input tokens (required) |
|
Normal distribution standard deviation for input tokens (required) |
|
Normal distribution mean for output tokens (required) |
|
Normal distribution standard deviation for output tokens (required) |
token_unif_dist#
Generate synthetic datasets with uniform token distribution
python prepare_dataset.py token_unif_dist [OPTIONS]
Options
Option |
Description |
|---|---|
|
Number of requests to be generated (required) |
|
Uniform distribution minimum for input tokens (required) |
|
Uniform distribution maximum for input tokens (required) |
|
Uniform distribution minimum for output tokens (required) |
|
Uniform distribution maximum for output tokens (required) |