Run a throughput test on a TRT-LLM engine.
(
bench_env: BenchmarkEnvironment,
**params,
)
| 290 | ) |
| 291 | @click.pass_obj |
| 292 | def throughput_command( |
| 293 | bench_env: BenchmarkEnvironment, |
| 294 | **params, |
| 295 | ) -> None: |
| 296 | """Run a throughput test on a TRT-LLM engine.""" |
| 297 | logger.info("Preparing to run throughput benchmark...") |
| 298 | |
| 299 | # Parameters from CLI |
| 300 | image_data_format: str = params.get("image_data_format", "pt") |
| 301 | data_device: str = params.get("data_device", "cpu") |
| 302 | no_skip_tokenizer_init: bool = params.get("no_skip_tokenizer_init", False) |
| 303 | |
| 304 | # Get general CLI options using the centralized function |
| 305 | options: GeneralExecSettings = get_general_cli_options(params, bench_env) |
| 306 | tokenizer = initialize_tokenizer(options.checkpoint_path) |
| 307 | |
| 308 | # Extract throughput-specific options not handled by GeneralExecSettings |
| 309 | max_batch_size = params.get("max_batch_size") |
| 310 | max_num_tokens = params.get("max_num_tokens") |
| 311 | enable_chunked_context: bool = params.get("enable_chunked_context") |
| 312 | scheduler_policy: str = params.get("scheduler_policy") |
| 313 | |
| 314 | custom_module_dirs: list[Path] = params.pop("custom_module_dirs", []) |
| 315 | for custom_module_dir in custom_module_dirs: |
| 316 | try: |
| 317 | import_custom_module_from_dir(custom_module_dir) |
| 318 | except Exception as e: |
| 319 | logger.error( |
| 320 | f"Failed to import custom module from {custom_module_dir}: {e}") |
| 321 | raise e |
| 322 | |
| 323 | # Runtime kwargs and option tracking. |
| 324 | kwargs = {} |
| 325 | |
| 326 | # Dataset Loading and Preparation |
| 327 | with open(options.dataset_path, "r") as dataset: |
| 328 | metadata, requests = create_dataset_from_stream( |
| 329 | tokenizer, |
| 330 | dataset, |
| 331 | num_requests=options.num_requests, |
| 332 | model_dir=options.checkpoint_path, |
| 333 | model_type=options.model_type, |
| 334 | modality=options.modality, |
| 335 | image_data_format=image_data_format, |
| 336 | data_device=data_device, |
| 337 | max_input_seq_len_for_multimodal=options.max_input_len) |
| 338 | metadata.dataset_path = options.dataset_path |
| 339 | params["target_input_len"] = params.get( |
| 340 | "target_input_len") or metadata.avg_isl |
| 341 | params["target_output_len"] = params.get( |
| 342 | "target_output_len") or metadata.avg_osl |
| 343 | |
| 344 | if options.modality is None: |
| 345 | # Log dataset info |
| 346 | # NOTE: This table is only accurate for non-multimodal models. |
| 347 | # The accurate table for multimodal models will be logged after the benchmark is done. |
| 348 | logger.info(metadata.get_summary_for_print()) |
| 349 |
nothing calls this directly
no test coverage detected