vllm_mlx.benchmark¶
Performance Benchmark for vllm-mlx.
View the complete module source at #L1-L1684.
API details¶
Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.
vllm_mlx.benchmark
¶
Performance Benchmark for vllm-mlx.
Measures key performance metrics for LLM and MLLM (Multimodal Language Model) inference: - Time to First Token (TTFT) - Time Per Output Token (TPOT) - Tokens Per Second (TPS) - both input processing and output generation - End-to-End Latency - Throughput - Memory Usage (process and MLX cache) - MLLM: Image resolution performance - MLLM: Video frame count performance
Usage
LLM benchmark¶
python -m vllm_mlx.benchmark --model mlx-community/Llama-3.2-1B-Instruct-4bit python -m vllm_mlx.benchmark --model mlx-community/Llama-3.2-3B-Instruct-4bit --prompts 10 --max-tokens 256
MLLM image benchmark (auto-detected or use --mllm flag)¶
python -m vllm_mlx.benchmark --model mlx-community/Qwen3-VL-4B-Instruct-3bit python -m vllm_mlx.benchmark --model mlx-community/Qwen3-VL-4B-Instruct-3bit --mllm --quick
MLLM video benchmark¶
python -m vllm_mlx.benchmark --model mlx-community/Qwen3-VL-4B-Instruct-3bit --video python -m vllm_mlx.benchmark --model mlx-community/Qwen3-VL-4B-Instruct-3bit --video --video-url https://example.com/video.mp4
vllm_mlx.benchmark.VIDEO_SAMPLE_URLS
module-attribute
¶
VIDEO_SAMPLE_URLS = {'bunny_10s': 'https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4', 'bunny_240p': 'https://docs.evostream.com/sample_content/assets/bunny.mp4', 'sintel_720p': 'https://docs.evostream.com/sample_content/assets/sintel1m720p.mp4'}
vllm_mlx.benchmark.DEFAULT_VIDEO_URL
module-attribute
¶
DEFAULT_VIDEO_URL = VIDEO_SAMPLE_URLS['bunny_10s']
vllm_mlx.benchmark.VLM_TEST_VIDEO_URLS
module-attribute
¶
VLM_TEST_VIDEO_URLS = [VIDEO_SAMPLE_URLS['bunny_10s'], VIDEO_SAMPLE_URLS['bunny_240p']]
vllm_mlx.benchmark.MLLM_PATTERNS
module-attribute
¶
MLLM_PATTERNS = ['-VL-', '-VL/', 'VL-', 'llava', 'LLaVA', 'idefics', 'Idefics', 'paligemma', 'PaliGemma', 'pixtral', 'Pixtral', 'molmo', 'Molmo', 'phi3-vision', 'phi-3-vision', 'cogvlm', 'CogVLM', 'internvl', 'InternVL', 'deepseek-vl', 'DeepSeek-VL']
vllm_mlx.benchmark.MLLM_TEST_IMAGE_URL
module-attribute
¶
MLLM_TEST_IMAGE_URL = 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/26/YellowLabradorLooking_new.jpg/1200px-YellowLabradorLooking_new.jpg'
vllm_mlx.benchmark.MLLM_TEST_IMAGE_URLS
module-attribute
¶
MLLM_TEST_IMAGE_URLS = [MLLM_TEST_IMAGE_URL, 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/640px-PNG_transparency_demonstration_1.png']
vllm_mlx.benchmark.ResourceMetrics
dataclass
¶
ResourceMetrics(process_memory_gb: float = 0.0, mlx_cache_gb: float = 0.0, mlx_peak_memory_gb: float = 0.0, system_memory_used_gb: float = 0.0, system_memory_total_gb: float = 0.0)
Resource usage metrics during benchmark.
vllm_mlx.benchmark.ResourceMetrics.process_memory_gb
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.ResourceMetrics.mlx_cache_gb
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.ResourceMetrics.mlx_peak_memory_gb
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.ResourceMetrics.system_memory_used_gb
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.ResourceMetrics.system_memory_total_gb
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.ResourceMonitor
¶
Monitor system resources during benchmark runs.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.ResourceMonitor.start
¶
vllm_mlx.benchmark.ResourceMonitor.sample
¶
sample() -> ResourceMetrics
Take a resource sample.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.ResourceMonitor.get_summary
¶
get_summary() -> ResourceMetrics
Get summary of all samples.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.BenchmarkResult
dataclass
¶
BenchmarkResult(prompt: str, prompt_tokens: int, generated_tokens: int, ttft: float, total_time: float, tpot: float = 0.0, generation_tps: float = 0.0, processing_tps: float = 0.0)
Results from a single benchmark run.
vllm_mlx.benchmark.BenchmarkResult.generation_tps
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkResult.processing_tps
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkResult.__post_init__
¶
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.BenchmarkSummary
dataclass
¶
BenchmarkSummary(model_name: str, num_runs: int, total_prompt_tokens: int, total_generated_tokens: int, total_time: float, ttft_mean: float, ttft_min: float, ttft_max: float, ttft_p50: float, ttft_p95: float, tpot_mean: float, tpot_min: float, tpot_max: float, generation_tps_mean: float, generation_tps_max: float, processing_tps_mean: float, latency_mean: float, latency_min: float, latency_max: float, latency_p50: float, latency_p95: float, total_throughput_tps: float, requests_per_second: float, hardware_chip: str = '', hardware_memory_gb: float = 0.0, hardware_bandwidth_gbs: float = 0.0, resources: ResourceMetrics = ResourceMetrics())
Summary statistics across all benchmark runs.
vllm_mlx.benchmark.BenchmarkSummary.total_prompt_tokens
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkSummary.total_generated_tokens
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkSummary.generation_tps_mean
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkSummary.generation_tps_max
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkSummary.processing_tps_mean
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkSummary.total_throughput_tps
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkSummary.requests_per_second
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkSummary.hardware_chip
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkSummary.hardware_memory_gb
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkSummary.hardware_bandwidth_gbs
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.BenchmarkSummary.resources
class-attribute
instance-attribute
¶
resources: ResourceMetrics = field(default_factory=ResourceMetrics)
vllm_mlx.benchmark.MLLMBenchmarkResult
dataclass
¶
MLLMBenchmarkResult(resolution: str, width: int, height: int, pixels: int, time_seconds: float, tokens_generated: int, tokens_per_second: float, response_preview: str, memory_gb: float = 0.0, mlx_memory_gb: float = 0.0)
vllm_mlx.benchmark.VideoBenchmarkResult
dataclass
¶
VideoBenchmarkResult(config_name: str, fps: float, max_frames: int, frames_extracted: int, video_duration: float, time_seconds: float, prompt_tokens: int, completion_tokens: int, tokens_per_second: float, response_preview: str, memory_gb: float = 0.0, mlx_memory_gb: float = 0.0)
Result from a single video benchmark run.
vllm_mlx.benchmark.VideoBenchmarkResult.completion_tokens
instance-attribute
¶
vllm_mlx.benchmark.VideoBenchmarkResult.tokens_per_second
instance-attribute
¶
vllm_mlx.benchmark.VideoBenchmarkResult.memory_gb
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.VideoBenchmarkResult.mlx_memory_gb
class-attribute
instance-attribute
¶
vllm_mlx.benchmark.reset_mlx_peak_memory
¶
Reset MLX peak memory counter.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.get_mlx_memory_info
¶
Get MLX memory usage information.
Parameters:
-
reset_peak(bool, default:True) –If True, reset peak memory counter after reading.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.get_process_memory
¶
Get current process memory usage in GB.
vllm_mlx.benchmark.get_system_memory
¶
Get system memory (used, total) in GB.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.calculate_percentile
¶
Calculate percentile from a list.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.benchmark_single_prompt
¶
benchmark_single_prompt(model, tokenizer, prompt: str, max_tokens: int = 256, temperature: float = 0.7) -> Optional[BenchmarkResult]
Benchmark a single prompt with detailed timing.
Parameters:
-
model–The loaded MLX model
-
tokenizer–The tokenizer
-
prompt(str) –The prompt to benchmark
-
max_tokens(int, default:256) –Maximum tokens to generate
-
temperature(float, default:0.7) –Sampling temperature
Returns:
-
Optional[BenchmarkResult]–BenchmarkResult with timing metrics
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.run_benchmark
¶
run_benchmark(model_name: str, num_prompts: int = 5, max_tokens: int = 256, temperature: float = 0.7, warmup_runs: int = 1) -> Optional[BenchmarkSummary]
Run the full benchmark suite.
Parameters:
-
model_name(str) –HuggingFace model name or local path
-
num_prompts(int, default:5) –Number of prompts to test
-
max_tokens(int, default:256) –Maximum tokens per generation
-
temperature(float, default:0.7) –Sampling temperature
-
warmup_runs(int, default:1) –Number of warmup runs before measuring
Returns:
-
Optional[BenchmarkSummary]–BenchmarkSummary with aggregate statistics
Source code in vllm_mlx/benchmark.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
vllm_mlx.benchmark.is_mllm_model
¶
Check if model name indicates a multimodal language model.
vllm_mlx.benchmark.download_test_image
¶
Download image from URL and return PIL Image.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.resize_image
¶
vllm_mlx.benchmark.image_to_base64
¶
Convert PIL Image to base64 data URL.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.benchmark_mllm_resolution
¶
benchmark_mllm_resolution(model, processor, config, base_image: Image, width: int, height: int, max_tokens: int = 256, warmup: bool = False) -> MLLMBenchmarkResult
Run MLLM benchmark for a specific resolution.
Source code in vllm_mlx/benchmark.py
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 | |
vllm_mlx.benchmark.run_mllm_benchmark
¶
run_mllm_benchmark(model_name: str, quick: bool = False, max_tokens: int = 256, warmup_runs: int = 1) -> list[MLLMBenchmarkResult]
Run MLLM benchmark across multiple image resolutions.
Parameters:
-
model_name(str) –HuggingFace model name
-
quick(bool, default:False) –If True, test only 4 resolutions
-
max_tokens(int, default:256) –Max tokens to generate
-
warmup_runs(int, default:1) –Number of warmup runs
Returns:
-
list[MLLMBenchmarkResult]–List of MLLMBenchmarkResult
Source code in vllm_mlx/benchmark.py
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 | |
vllm_mlx.benchmark.print_mllm_summary
¶
print_mllm_summary(results: list[MLLMBenchmarkResult], model_name: str)
Print MLLM benchmark summary.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.create_test_video
¶
create_test_video(duration: float = 10.0, fps: float = 30.0, width: int = 640, height: int = 480) -> str
Create a synthetic test video with colored frames and text.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.download_video
¶
Download video from URL and return local path.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.get_video_info
¶
Get information about a video file.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.benchmark_video_config
¶
benchmark_video_config(model, video_path: str, fps: float, max_frames: int, config_name: str, video_info: dict, max_tokens: int = 150, warmup: bool = False) -> VideoBenchmarkResult
Run a single video benchmark configuration.
Source code in vllm_mlx/benchmark.py
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 | |
vllm_mlx.benchmark.run_video_benchmark
¶
run_video_benchmark(model_name: str, video_url: str = None, video_path: str = None, quick: bool = False, max_tokens: int = 150, warmup_runs: int = 1) -> list[VideoBenchmarkResult]
Run video benchmark across multiple frame configurations.
Parameters:
-
model_name(str) –HuggingFace MLLM model name
-
video_url(str, default:None) –URL to download video from
-
video_path(str, default:None) –Local video file path
-
quick(bool, default:False) –If True, test only 3 configurations
-
max_tokens(int, default:150) –Max tokens to generate
-
warmup_runs(int, default:1) –Number of warmup runs
Returns:
-
list[VideoBenchmarkResult]–List of VideoBenchmarkResult
Source code in vllm_mlx/benchmark.py
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 | |
vllm_mlx.benchmark.print_video_summary
¶
print_video_summary(results: list[VideoBenchmarkResult], model_name: str)
Print video benchmark summary.
Source code in vllm_mlx/benchmark.py
vllm_mlx.benchmark.print_summary
¶
print_summary(summary: BenchmarkSummary)
Print a formatted summary of benchmark results using tabulate.
Source code in vllm_mlx/benchmark.py
1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 | |
vllm_mlx.benchmark.main
¶
Run the benchmark.
Source code in vllm_mlx/benchmark.py
1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 | |
Complete contract reference¶
Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.
vllm_mlx.benchmark.ResourceMetrics · class
vllm_mlx.benchmark.ResourceMetrics(process_memory_gb: float = 0.0, mlx_cache_gb: float = 0.0, mlx_peak_memory_gb: float = 0.0, system_memory_used_gb: float = 0.0, system_memory_total_gb: float = 0.0)
Resource usage metrics during benchmark.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
process_memory_gb |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
mlx_cache_gb |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
mlx_peak_memory_gb |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
system_memory_used_gb |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
system_memory_total_gb |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
Returns
- Constructs:
vllm_mlx.benchmark.ResourceMetrics
Exceptions and behavior
Class ResourceMetrics declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.benchmark.reset_mlx_peak_memory · function
Reset MLX peak memory counter.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated - Direct return expressions:
None
Exceptions and behavior
Function reset_mlx_peak_memory calls hasattr, mx.reset_peak_memory, mx.metal.reset_peak_memory; returns None.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.get_mlx_memory_info · function
Get MLX memory usage information.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
reset_peak |
bool |
no |
True |
If True, reset peak memory counter after reading. |
Returns
- Type:
dict - Direct return expressions:
{};info
Exceptions and behavior
Function get_mlx_memory_info calls hasattr, mx.get_cache_memory, mx.get_peak_memory, mx.get_active_memory; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.get_process_memory · function
Get current process memory usage in GB.
Parameters
This callable has no explicit inputs.
Returns
- Type:
float - Direct return expressions:
0.0;process.memory_info().rss / 1024 ** 3
Exceptions and behavior
Function get_process_memory calls psutil.Process, process.memory_info; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.get_system_memory · function
Get system memory (used, total) in GB.
Parameters
This callable has no explicit inputs.
Returns
- Type:
tuple[float, float] - Direct return expressions:
(0.0, 0.0);(mem.used / 1024 ** 3, mem.total / 1024 ** 3)
Exceptions and behavior
Function get_system_memory calls psutil.virtual_memory; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.ResourceMonitor · class
Monitor system resources during benchmark runs.
Parameters
This callable has no explicit inputs.
Returns
- Constructs:
vllm_mlx.benchmark.ResourceMonitor
Exceptions and behavior
Class ResourceMonitor declares 4 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.benchmark.ResourceMonitor.__init__ · method
Method ResourceMonitor.__init__ updates self.samples, self._start_time, self._start_memory.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Method ResourceMonitor.__init__ updates self.samples, self._start_time, self._start_memory.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.ResourceMonitor.start · method
Start monitoring.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Method ResourceMonitor.start updates self._start_time, self._start_memory; calls time.perf_counter, get_process_memory, reset_mlx_peak_memory.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.ResourceMonitor.sample · method
Take a resource sample.
Parameters
This callable has no explicit inputs.
Returns
- Type:
ResourceMetrics - Direct return expressions:
metrics
Exceptions and behavior
Method ResourceMonitor.sample calls get_mlx_memory_info, get_system_memory, ResourceMetrics, get_process_memory; returns metrics.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.ResourceMonitor.get_summary · method
Get summary of all samples.
Parameters
This callable has no explicit inputs.
Returns
- Type:
ResourceMetrics - Direct return expressions:
ResourceMetrics();ResourceMetrics(process_memory_gb=peak_process, mlx_cache_gb=peak_mlx_cache, mlx_peak_memory_gb=peak_mlx, system_memory…
Exceptions and behavior
Method ResourceMonitor.get_summary calls ResourceMetrics, max; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.BenchmarkResult · class
vllm_mlx.benchmark.BenchmarkResult(prompt: str, prompt_tokens: int, generated_tokens: int, ttft: float, total_time: float, tpot: float = 0.0, generation_tps: float = 0.0, processing_tps: float = 0.0)
Results from a single benchmark run.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
prompt |
str |
yes |
none |
Required constructor field. |
prompt_tokens |
int |
yes |
none |
Required constructor field. |
generated_tokens |
int |
yes |
none |
Required constructor field. |
ttft |
float |
yes |
none |
Required constructor field. |
total_time |
float |
yes |
none |
Required constructor field. |
tpot |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
generation_tps |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
processing_tps |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
Returns
- Constructs:
vllm_mlx.benchmark.BenchmarkResult
Exceptions and behavior
Class BenchmarkResult declares 1 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.benchmark.BenchmarkResult.__post_init__ · method
Method BenchmarkResult.__post_init__ updates self.tpot, self.generation_tps, self.processing_tps.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Method BenchmarkResult.__post_init__ updates self.tpot, self.generation_tps, self.processing_tps.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.BenchmarkSummary · class
vllm_mlx.benchmark.BenchmarkSummary(model_name: str, num_runs: int, total_prompt_tokens: int, total_generated_tokens: int, total_time: float, ttft_mean: float, ttft_min: float, ttft_max: float, ttft_p50: float, ttft_p95: float, tpot_mean: float, tpot_min: float, tpot_max: float, generation_tps_mean: float, generation_tps_max: float, processing_tps_mean: float, latency_mean: float, latency_min: float, latency_max: float, latency_p50: float, latency_p95: float, total_throughput_tps: float, requests_per_second: float, hardware_chip: str = '', hardware_memory_gb: float = 0.0, hardware_bandwidth_gbs: float = 0.0, resources: ResourceMetrics = field(default_factory=ResourceMetrics))
Summary statistics across all benchmark runs.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required constructor field. |
num_runs |
int |
yes |
none |
Required constructor field. |
total_prompt_tokens |
int |
yes |
none |
Required constructor field. |
total_generated_tokens |
int |
yes |
none |
Required constructor field. |
total_time |
float |
yes |
none |
Required constructor field. |
ttft_mean |
float |
yes |
none |
Required constructor field. |
ttft_min |
float |
yes |
none |
Required constructor field. |
ttft_max |
float |
yes |
none |
Required constructor field. |
ttft_p50 |
float |
yes |
none |
Required constructor field. |
ttft_p95 |
float |
yes |
none |
Required constructor field. |
tpot_mean |
float |
yes |
none |
Required constructor field. |
tpot_min |
float |
yes |
none |
Required constructor field. |
tpot_max |
float |
yes |
none |
Required constructor field. |
generation_tps_mean |
float |
yes |
none |
Required constructor field. |
generation_tps_max |
float |
yes |
none |
Required constructor field. |
processing_tps_mean |
float |
yes |
none |
Required constructor field. |
latency_mean |
float |
yes |
none |
Required constructor field. |
latency_min |
float |
yes |
none |
Required constructor field. |
latency_max |
float |
yes |
none |
Required constructor field. |
latency_p50 |
float |
yes |
none |
Required constructor field. |
latency_p95 |
float |
yes |
none |
Required constructor field. |
total_throughput_tps |
float |
yes |
none |
Required constructor field. |
requests_per_second |
float |
yes |
none |
Required constructor field. |
hardware_chip |
str |
no |
'' |
Optional constructor field; defaults to ''. |
hardware_memory_gb |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
hardware_bandwidth_gbs |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
resources |
ResourceMetrics |
no |
field(default_factory=ResourceMetrics) |
Optional constructor field; defaults to field(default_factory=ResourceMetrics). |
Returns
- Constructs:
vllm_mlx.benchmark.BenchmarkSummary
Exceptions and behavior
Class BenchmarkSummary declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.benchmark.calculate_percentile · function
Calculate percentile from a list.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
data |
list |
yes |
none |
Required positional or keyword input. |
percentile |
float |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
float - Direct return expressions:
0.0;sorted_data[index]
Exceptions and behavior
Function calculate_percentile calls sorted, int, len, min; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.benchmark_single_prompt · function
vllm_mlx.benchmark.benchmark_single_prompt(model, tokenizer, prompt: str, max_tokens: int = 256, temperature: float = 0.7) -> Optional[BenchmarkResult]
Benchmark a single prompt with detailed timing.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model |
not annotated |
yes |
none |
The loaded MLX model |
tokenizer |
not annotated |
yes |
none |
The tokenizer |
prompt |
str |
yes |
none |
The prompt to benchmark |
max_tokens |
int |
no |
256 |
Maximum tokens to generate |
temperature |
float |
no |
0.7 |
Sampling temperature |
Returns
- Type:
Optional[BenchmarkResult] - Direct return expressions:
BenchmarkResult(prompt=prompt[:50] + '...' if len(prompt) > 50 else prompt, prompt_tokens=prompt_token_count, generated…;None
Exceptions and behavior
Function benchmark_single_prompt calls tokenizer.encode, len, make_sampler, time.perf_counter; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.run_benchmark · function
vllm_mlx.benchmark.run_benchmark(model_name: str, num_prompts: int = 5, max_tokens: int = 256, temperature: float = 0.7, warmup_runs: int = 1) -> Optional[BenchmarkSummary]
Run the full benchmark suite.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
HuggingFace model name or local path |
num_prompts |
int |
no |
5 |
Number of prompts to test |
max_tokens |
int |
no |
256 |
Maximum tokens per generation |
temperature |
float |
no |
0.7 |
Sampling temperature |
warmup_runs |
int |
no |
1 |
Number of warmup runs before measuring |
Returns
- Type:
Optional[BenchmarkSummary] - Direct return expressions:
None;summary
Exceptions and behavior
Function run_benchmark calls detect_hardware, len, print, tabulate; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.is_mllm_model · function
Check if model name indicates a multimodal language model.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
bool - Direct return expressions:
True;False
Exceptions and behavior
Function is_mllm_model calls model_name.lower, pattern.lower; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.MLLMBenchmarkResult · class
vllm_mlx.benchmark.MLLMBenchmarkResult(resolution: str, width: int, height: int, pixels: int, time_seconds: float, tokens_generated: int, tokens_per_second: float, response_preview: str, memory_gb: float = 0.0, mlx_memory_gb: float = 0.0)
Result from a single MLLM benchmark run.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
resolution |
str |
yes |
none |
Required constructor field. |
width |
int |
yes |
none |
Required constructor field. |
height |
int |
yes |
none |
Required constructor field. |
pixels |
int |
yes |
none |
Required constructor field. |
time_seconds |
float |
yes |
none |
Required constructor field. |
tokens_generated |
int |
yes |
none |
Required constructor field. |
tokens_per_second |
float |
yes |
none |
Required constructor field. |
response_preview |
str |
yes |
none |
Required constructor field. |
memory_gb |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
mlx_memory_gb |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
Returns
- Constructs:
vllm_mlx.benchmark.MLLMBenchmarkResult
Exceptions and behavior
Class MLLMBenchmarkResult declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.benchmark.download_test_image · function
Download image from URL and return PIL Image.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
url |
str |
yes |
none |
Required positional or keyword input. |
timeout |
int |
no |
30 |
Optional positional or keyword input; defaults to 30. |
Returns
- Type:
Image.Image - Direct return expressions:
Image.open(io.BytesIO(response.content))
Exceptions and behavior
Function download_test_image calls requests.get, response.raise_for_status, Image.open, io.BytesIO; returns Image.open(io.BytesIO(response.content)).
No direct raise statement appears in this definition.
vllm_mlx.benchmark.resize_image · function
Resize image to specified dimensions.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
img |
Image.Image |
yes |
none |
Required positional or keyword input. |
width |
int |
yes |
none |
Required positional or keyword input. |
height |
int |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
Image.Image - Direct return expressions:
img.resize((width, height), Image.Resampling.LANCZOS)
Exceptions and behavior
Function resize_image calls img.resize; returns img.resize((width, height), Image.Resampling.LANCZOS).
No direct raise statement appears in this definition.
vllm_mlx.benchmark.image_to_base64 · function
Convert PIL Image to base64 data URL.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
img |
Image.Image |
yes |
none |
Required positional or keyword input. |
format |
str |
no |
'JPEG' |
Optional positional or keyword input; defaults to 'JPEG'. |
Returns
- Type:
str - Direct return expressions:
f'data:{mime};base64,{b64}'
Exceptions and behavior
Function image_to_base64 calls Image.new, background.paste, img.split, img.convert; returns f'data:{mime};base64,{b64}'.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.benchmark_mllm_resolution · function
vllm_mlx.benchmark.benchmark_mllm_resolution(model, processor, config, base_image: Image.Image, width: int, height: int, max_tokens: int = 256, warmup: bool = False) -> MLLMBenchmarkResult
Run MLLM benchmark for a specific resolution.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model |
not annotated |
yes |
none |
Required positional or keyword input. |
processor |
not annotated |
yes |
none |
Required positional or keyword input. |
config |
not annotated |
yes |
none |
Required positional or keyword input. |
base_image |
Image.Image |
yes |
none |
Required positional or keyword input. |
width |
int |
yes |
none |
Required positional or keyword input. |
height |
int |
yes |
none |
Required positional or keyword input. |
max_tokens |
int |
no |
256 |
Optional positional or keyword input; defaults to 256. |
warmup |
bool |
no |
False |
Optional positional or keyword input; defaults to False. |
Returns
- Type:
MLLMBenchmarkResult - Direct return expressions:
MLLMBenchmarkResult(resolution=resolution_name, width=width, height=height, pixels=pixels, time_seconds=elapsed, tokens…
Exceptions and behavior
Function benchmark_mllm_resolution calls reset_mlx_peak_memory, resize_image, tempfile.NamedTemporaryFile, img.save; returns MLLMBenchmarkResult(resolution=resolution_name, width=width, height=height, pixels=pixels, time_seconds=elapsed, tokens….
No direct raise statement appears in this definition.
vllm_mlx.benchmark.run_mllm_benchmark · function
vllm_mlx.benchmark.run_mllm_benchmark(model_name: str, quick: bool = False, max_tokens: int = 256, warmup_runs: int = 1) -> list[MLLMBenchmarkResult]
Run MLLM benchmark across multiple image resolutions.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
HuggingFace model name |
quick |
bool |
no |
False |
If True, test only 4 resolutions |
max_tokens |
int |
no |
256 |
Max tokens to generate |
warmup_runs |
int |
no |
1 |
Number of warmup runs |
Returns
- Type:
list[MLLMBenchmarkResult] - Direct return expressions:
[];results
Exceptions and behavior
Function run_mllm_benchmark calls detect_hardware, print, len, tabulate; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.print_mllm_summary · function
vllm_mlx.benchmark.print_mllm_summary(results: list[MLLMBenchmarkResult], model_name: str) -> not annotated
Print MLLM benchmark summary.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
results |
list[MLLMBenchmarkResult] |
yes |
none |
Required positional or keyword input. |
model_name |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated - Direct return expressions:
None
Exceptions and behavior
Function print_mllm_summary calls print, table_data.append, tabulate, sum; returns None.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.VideoBenchmarkResult · class
vllm_mlx.benchmark.VideoBenchmarkResult(config_name: str, fps: float, max_frames: int, frames_extracted: int, video_duration: float, time_seconds: float, prompt_tokens: int, completion_tokens: int, tokens_per_second: float, response_preview: str, memory_gb: float = 0.0, mlx_memory_gb: float = 0.0)
Result from a single video benchmark run.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
config_name |
str |
yes |
none |
Required constructor field. |
fps |
float |
yes |
none |
Required constructor field. |
max_frames |
int |
yes |
none |
Required constructor field. |
frames_extracted |
int |
yes |
none |
Required constructor field. |
video_duration |
float |
yes |
none |
Required constructor field. |
time_seconds |
float |
yes |
none |
Required constructor field. |
prompt_tokens |
int |
yes |
none |
Required constructor field. |
completion_tokens |
int |
yes |
none |
Required constructor field. |
tokens_per_second |
float |
yes |
none |
Required constructor field. |
response_preview |
str |
yes |
none |
Required constructor field. |
memory_gb |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
mlx_memory_gb |
float |
no |
0.0 |
Optional constructor field; defaults to 0.0. |
Returns
- Constructs:
vllm_mlx.benchmark.VideoBenchmarkResult
Exceptions and behavior
Class VideoBenchmarkResult declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.benchmark.create_test_video · function
vllm_mlx.benchmark.create_test_video(duration: float = 10.0, fps: float = 30.0, width: int = 640, height: int = 480) -> str
Create a synthetic test video with colored frames and text.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
duration |
float |
no |
10.0 |
Optional positional or keyword input; defaults to 10.0. |
fps |
float |
no |
30.0 |
Optional positional or keyword input; defaults to 30.0. |
width |
int |
no |
640 |
Optional positional or keyword input; defaults to 640. |
height |
int |
no |
480 |
Optional positional or keyword input; defaults to 480. |
Returns
- Type:
str - Direct return expressions:
temp_file.name
Exceptions and behavior
Function create_test_video calls tempfile.NamedTemporaryFile, temp_file.close, cv2.VideoWriter_fourcc, cv2.VideoWriter; returns temp_file.name.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.download_video · function
Download video from URL and return local path.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
url |
str |
yes |
none |
Required positional or keyword input. |
timeout |
int |
no |
120 |
Optional positional or keyword input; defaults to 120. |
Returns
- Type:
str - Direct return expressions:
temp_file.name
Exceptions and behavior
Function download_video calls print, requests.get, response.raise_for_status, tempfile.NamedTemporaryFile; returns temp_file.name.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.get_video_info · function
Get information about a video file.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
video_path |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
dict - Direct return expressions:
{'error': 'Cannot open video'};info
Exceptions and behavior
Function get_video_info calls cv2.VideoCapture, cap.isOpened, int, cap.get; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.benchmark_video_config · function
vllm_mlx.benchmark.benchmark_video_config(model, video_path: str, fps: float, max_frames: int, config_name: str, video_info: dict, max_tokens: int = 150, warmup: bool = False) -> VideoBenchmarkResult
Run a single video benchmark configuration.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model |
not annotated |
yes |
none |
Required positional or keyword input. |
video_path |
str |
yes |
none |
Required positional or keyword input. |
fps |
float |
yes |
none |
Required positional or keyword input. |
max_frames |
int |
yes |
none |
Required positional or keyword input. |
config_name |
str |
yes |
none |
Required positional or keyword input. |
video_info |
dict |
yes |
none |
Required positional or keyword input. |
max_tokens |
int |
no |
150 |
Optional positional or keyword input; defaults to 150. |
warmup |
bool |
no |
False |
Optional positional or keyword input; defaults to False. |
Returns
- Type:
VideoBenchmarkResult - Direct return expressions:
VideoBenchmarkResult(config_name=config_name, fps=fps, max_frames=max_frames, frames_extracted=frames_extracted, video_…
Exceptions and behavior
Function benchmark_video_config calls reset_mlx_peak_memory, print, time.perf_counter, model.generate; returns VideoBenchmarkResult(config_name=config_name, fps=fps, max_frames=max_frames, frames_extracted=frames_extracted, video_….
No direct raise statement appears in this definition.
vllm_mlx.benchmark.run_video_benchmark · function
vllm_mlx.benchmark.run_video_benchmark(model_name: str, video_url: str = None, video_path: str = None, quick: bool = False, max_tokens: int = 150, warmup_runs: int = 1) -> list[VideoBenchmarkResult]
Run video benchmark across multiple frame configurations.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
HuggingFace MLLM model name |
video_url |
str |
no |
None |
URL to download video from |
video_path |
str |
no |
None |
Local video file path |
quick |
bool |
no |
False |
If True, test only 3 configurations |
max_tokens |
int |
no |
150 |
Max tokens to generate |
warmup_runs |
int |
no |
1 |
Number of warmup runs |
Returns
- Type:
list[VideoBenchmarkResult] - Direct return expressions:
results
Exceptions and behavior
Function run_video_benchmark calls detect_hardware, print, len, tabulate; returns results.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.print_video_summary · function
vllm_mlx.benchmark.print_video_summary(results: list[VideoBenchmarkResult], model_name: str) -> not annotated
Print video benchmark summary.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
results |
list[VideoBenchmarkResult] |
yes |
none |
Required positional or keyword input. |
model_name |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated - Direct return expressions:
None
Exceptions and behavior
Function print_video_summary calls print, sorted, table_data.append, tabulate; returns None.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.print_summary · function
Print a formatted summary of benchmark results using tabulate.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
summary |
BenchmarkSummary |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated
Exceptions and behavior
Function print_summary calls print, tabulate, resource_data.append.
No direct raise statement appears in this definition.
vllm_mlx.benchmark.main · function
Run the benchmark.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, is_mllm_model.
No direct raise statement appears in this definition.
Complete symbol map¶
This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.
| Symbol | Kind | Signature and inputs | What it does | Source |
|---|---|---|---|---|
ResourceMetrics |
class | ResourceMetrics(process_memory_gb: float = 0.0, mlx_cache_gb: float = 0.0, mlx_peak_memory_gb: float = 0.0, system_memory_used_gb: float = 0.0, system_memory_total_gb: float = 0.0) |
Resource usage metrics during benchmark. | #L72-L80 |
reset_mlx_peak_memory |
function | reset_mlx_peak_memory() -> not annotated |
Reset MLX peak memory counter. | #L83-L95 |
get_mlx_memory_info |
function | get_mlx_memory_info(reset_peak: bool = True) -> dict |
Get MLX memory usage information. | #L98-L135 |
get_process_memory |
function | get_process_memory() -> float |
Get current process memory usage in GB. | #L138-L147 |
get_system_memory |
function | get_system_memory() -> tuple[float, float] |
Get system memory (used, total) in GB. | #L150-L159 |
ResourceMonitor |
class | ResourceMonitor() |
Monitor system resources during benchmark runs. | #L162-L213 |
ResourceMonitor.__init__ |
method | ResourceMonitor.__init__() -> not annotated |
Method ResourceMonitor.__init__ updates self.samples, self._start_time, self._start_memory. |
#L165-L168 |
ResourceMonitor.start |
method | ResourceMonitor.start() -> not annotated |
Start monitoring. | #L170-L176 |
ResourceMonitor.sample |
method | ResourceMonitor.sample() -> ResourceMetrics |
Take a resource sample. | #L178-L192 |
ResourceMonitor.get_summary |
method | ResourceMonitor.get_summary() -> ResourceMetrics |
Get summary of all samples. | #L194-L213 |
BenchmarkResult |
class | BenchmarkResult(prompt: str, prompt_tokens: int, generated_tokens: int, ttft: float, total_time: float, tpot: float = 0.0, generation_tps: float = 0.0, processing_tps: float = 0.0) |
Results from a single benchmark run. | #L235-L268 |
BenchmarkResult.__post_init__ |
method | BenchmarkResult.__post_init__() -> not annotated |
Method BenchmarkResult.__post_init__ updates self.tpot, self.generation_tps, self.processing_tps. |
#L251-L268 |
BenchmarkSummary |
class | BenchmarkSummary(model_name: str, num_runs: int, total_prompt_tokens: int, total_generated_tokens: int, total_time: float, ttft_mean: float, ttft_min: float, ttft_max: float, ttft_p50: float, ttft_p95: float, tpot_mean: float, tpot_min: float, tpot_max: float, generation_tps_mean: float, generation_tps_max: float, processing_tps_mean: float, latency_mean: float, latency_min: float, latency_max: float, latency_p50: float, latency_p95: float, total_throughput_tps: float, requests_per_second: float, hardware_chip: str = '', hardware_memory_gb: float = 0.0, hardware_bandwidth_gbs: float = 0.0, resources: ResourceMetrics = field(default_factory=ResourceMetrics)) |
Summary statistics across all benchmark runs. | #L272-L315 |
calculate_percentile |
function | calculate_percentile(data: list, percentile: float) -> float |
Calculate percentile from a list. | #L318-L325 |
benchmark_single_prompt |
function | benchmark_single_prompt(model, tokenizer, prompt: str, max_tokens: int = 256, temperature: float = 0.7) -> Optional[BenchmarkResult] |
Benchmark a single prompt with detailed timing. | #L328-L394 |
run_benchmark |
function | run_benchmark(model_name: str, num_prompts: int = 5, max_tokens: int = 256, temperature: float = 0.7, warmup_runs: int = 1) -> Optional[BenchmarkSummary] |
Run the full benchmark suite. | #L397-L610 |
is_mllm_model |
function | is_mllm_model(model_name: str) -> bool |
Check if model name indicates a multimodal language model. | #L651-L657 |
MLLMBenchmarkResult |
class | MLLMBenchmarkResult(resolution: str, width: int, height: int, pixels: int, time_seconds: float, tokens_generated: int, tokens_per_second: float, response_preview: str, memory_gb: float = 0.0, mlx_memory_gb: float = 0.0) |
Result from a single MLLM benchmark run. | #L661-L674 |
download_test_image |
function | download_test_image(url: str, timeout: int = 30) -> Image.Image |
Download image from URL and return PIL Image. | #L677-L684 |
resize_image |
function | resize_image(img: Image.Image, width: int, height: int) -> Image.Image |
Resize image to specified dimensions. | #L687-L689 |
image_to_base64 |
function | image_to_base64(img: Image.Image, format: str = 'JPEG') -> str |
Convert PIL Image to base64 data URL. | #L692-L705 |
benchmark_mllm_resolution |
function | benchmark_mllm_resolution(model, processor, config, base_image: Image.Image, width: int, height: int, max_tokens: int = 256, warmup: bool = False) -> MLLMBenchmarkResult |
Run MLLM benchmark for a specific resolution. | #L708-L800 |
run_mllm_benchmark |
function | run_mllm_benchmark(model_name: str, quick: bool = False, max_tokens: int = 256, warmup_runs: int = 1) -> list[MLLMBenchmarkResult] |
Run MLLM benchmark across multiple image resolutions. | #L803-L913 |
print_mllm_summary |
function | print_mllm_summary(results: list[MLLMBenchmarkResult], model_name: str) -> not annotated |
Print MLLM benchmark summary. | #L916-L975 |
VideoBenchmarkResult |
class | VideoBenchmarkResult(config_name: str, fps: float, max_frames: int, frames_extracted: int, video_duration: float, time_seconds: float, prompt_tokens: int, completion_tokens: int, tokens_per_second: float, response_preview: str, memory_gb: float = 0.0, mlx_memory_gb: float = 0.0) |
Result from a single video benchmark run. | #L984-L999 |
create_test_video |
function | create_test_video(duration: float = 10.0, fps: float = 30.0, width: int = 640, height: int = 480) -> str |
Create a synthetic test video with colored frames and text. | #L1002-L1056 |
download_video |
function | download_video(url: str, timeout: int = 120) -> str |
Download video from URL and return local path. | #L1059-L1075 |
get_video_info |
function | get_video_info(video_path: str) -> dict |
Get information about a video file. | #L1078-L1094 |
benchmark_video_config |
function | benchmark_video_config(model, video_path: str, fps: float, max_frames: int, config_name: str, video_info: dict, max_tokens: int = 150, warmup: bool = False) -> VideoBenchmarkResult |
Run a single video benchmark configuration. | #L1097-L1162 |
run_video_benchmark |
function | run_video_benchmark(model_name: str, video_url: str = None, video_path: str = None, quick: bool = False, max_tokens: int = 150, warmup_runs: int = 1) -> list[VideoBenchmarkResult] |
Run video benchmark across multiple frame configurations. | #L1165-L1285 |
print_video_summary |
function | print_video_summary(results: list[VideoBenchmarkResult], model_name: str) -> not annotated |
Print video benchmark summary. | #L1288-L1341 |
print_summary |
function | print_summary(summary: BenchmarkSummary) -> not annotated |
Print a formatted summary of benchmark results using tabulate. | #L1349-L1441 |
main |
function | main() -> not annotated |
Run the benchmark. | #L1444-L1680 |