A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 6, 10:45 UTC
Stop bench CLI from recursively casting all configs to `dict` (#37559)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Harry Mellor committed
Mar 19, 2026 at 14:04 UTC
572b4329133915cc21d7d588d0514d9e8e86dd75
8 files changed
+17
-16
benchmarks/benchmark_long_document_qa_throughput.py
+2
-2
@@ -40,9 +40,9 @@ LLM engine. You can refer to the `vllm.engine.arg_utils.EngineArgs` for more
40
details.
41
"""
42
43
-import dataclasses
43
import random
44
import time
45
+from dataclasses import fields
46
47
from vllm import LLM, SamplingParams
48
from vllm.engine.arg_utils import EngineArgs
@@ -124,7 +124,7 @@ def main(args):
124
125
# Create the LLM engine
126
engine_args = EngineArgs.from_cli_args(args)
127
- llm = LLM(**dataclasses.asdict(engine_args))
127
+ llm = LLM(**{f.name: getattr(engine_args, f.name) for f in fields(engine_args)})
128
sampling_params = SamplingParams(temperature=0, max_tokens=args.output_len)
129
130
print("------warm up------")
benchmarks/benchmark_prefix_caching.py
+2
-1
@@ -32,6 +32,7 @@ import dataclasses
32
import json
33
import random
34
import time
35
+from dataclasses import fields
36
37
from transformers import PreTrainedTokenizerBase
38
@@ -196,7 +197,7 @@ def main(args):
197
198
engine_args = EngineArgs.from_cli_args(args)
199
199
- llm = LLM(**dataclasses.asdict(engine_args))
200
+ llm = LLM(**{f.name: getattr(engine_args, f.name) for f in fields(engine_args)})
201
202
sampling_params = SamplingParams(
203
temperature=0,
benchmarks/benchmark_prioritization.py
+2
-2
@@ -3,10 +3,10 @@
3
"""Benchmark offline prioritization."""
4
5
import argparse
6
-import dataclasses
6
import json
7
import random
8
import time
9
+from dataclasses import fields
10
11
from transformers import AutoTokenizer, PreTrainedTokenizerBase
12
@@ -79,7 +79,7 @@ def run_vllm(
79
) -> float:
80
from vllm import LLM, SamplingParams
81
82
- llm = LLM(**dataclasses.asdict(engine_args))
82
+ llm = LLM(**{f.name: getattr(engine_args, f.name) for f in fields(engine_args)})
83
84
assert all(
85
llm.llm_engine.model_config.max_model_len >= (request[1] + request[2])
vllm/benchmarks/latency.py
+2
-2
@@ -3,10 +3,10 @@
3
"""Benchmark the latency of processing a single batch of requests."""
4
5
import argparse
6
-import dataclasses
6
import json
7
import os
8
import time
9
+from dataclasses import fields
10
from typing import Any
11
12
import numpy as np
@@ -85,7 +85,7 @@ def main(args: argparse.Namespace):
85
86
# NOTE(woosuk): If the request cannot be processed in a single batch,
87
# the engine will automatically process the request in multiple batches.
88
- llm = LLM(**dataclasses.asdict(engine_args))
88
+ llm = LLM(**{f.name: getattr(engine_args, f.name) for f in fields(engine_args)})
89
assert llm.llm_engine.model_config.max_model_len >= (
90
args.input_len + args.output_len
91
), (
vllm/benchmarks/mm_processor.py
+2
-2
@@ -14,10 +14,10 @@ Run:
14
"""
15
16
import argparse
17
-import dataclasses
17
import json
18
import time
19
from collections import defaultdict
20
+from dataclasses import fields
21
from datetime import datetime
22
from typing import TYPE_CHECKING, Any, Literal
23
@@ -225,7 +225,7 @@ def benchmark_multimodal_processor(
225
args.seed = 0
226
227
engine_args = EngineArgs.from_cli_args(args)
228
- llm = LLM(**dataclasses.asdict(engine_args))
228
+ llm = LLM(**{f.name: getattr(engine_args, f.name) for f in fields(engine_args)})
229
230
tokenizer = llm.get_tokenizer()
231
requests = get_requests(args, tokenizer)
vllm/benchmarks/startup.py
+2
-2
@@ -9,7 +9,6 @@ and cache operations) for both cold and warm scenarios:
9
"""
10
11
import argparse
12
-import dataclasses
12
import json
13
import multiprocessing
14
import os
@@ -17,6 +16,7 @@ import shutil
16
import tempfile
17
import time
18
from contextlib import contextmanager
19
+from dataclasses import fields
20
from typing import Any
21
22
import numpy as np
@@ -67,7 +67,7 @@ def run_startup_in_subprocess(engine_args, result_queue):
67
# Measure total startup time
68
start_time = time.perf_counter()
69
70
- llm = LLM(**dataclasses.asdict(engine_args))
70
+ llm = LLM(**{f.name: getattr(engine_args, f.name) for f in fields(engine_args)})
71
72
total_startup_time = time.perf_counter() - start_time
73
vllm/benchmarks/sweep/serve_workload.py
+2
-2
@@ -2,7 +2,7 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
import argparse
4
import math
5
-from dataclasses import asdict, dataclass
5
+from dataclasses import dataclass, fields
6
from pathlib import Path
7
from typing import ClassVar, Literal, get_args
8
@@ -267,7 +267,7 @@ class SweepServeWorkloadArgs(SweepServeArgs):
267
base_args = SweepServeArgs.from_cli_args(args)
268
269
return cls(
270
- **asdict(base_args),
270
+ **{f.name: getattr(base_args, f.name) for f in fields(base_args)},
271
workload_var=args.workload_var,
272
workload_iters=args.workload_iters,
273
)
vllm/benchmarks/throughput.py
+3
-3
@@ -3,12 +3,12 @@
3
"""Benchmark offline inference throughput."""
4
5
import argparse
6
-import dataclasses
6
import json
7
import os
8
import random
9
import time
10
import warnings
11
+from dataclasses import fields
12
from typing import Any
13
14
import torch
@@ -53,7 +53,7 @@ def run_vllm(
53
) -> tuple[float, list[RequestOutput] | None]:
54
from vllm import LLM, SamplingParams
55
56
- llm = LLM(**dataclasses.asdict(engine_args))
56
+ llm = LLM(**{f.name: getattr(engine_args, f.name) for f in fields(engine_args)})
57
assert all(
58
llm.llm_engine.model_config.max_model_len
59
>= (request.prompt_len + request.expected_output_len)
@@ -141,7 +141,7 @@ def run_vllm_chat(
141
"""
142
from vllm import LLM, SamplingParams
143
144
- llm = LLM(**dataclasses.asdict(engine_args))
144
+ llm = LLM(**{f.name: getattr(engine_args, f.name) for f in fields(engine_args)})
145
146
assert all(
147
llm.llm_engine.model_config.max_model_len