mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-08-01 06:34:25 +08:00
[Bugfix] Fix benchmark script bug: inaccurate stats for vllm backend when max_model_len < input_len + output_len (#13691)
Signed-off-by: WangErXiao <863579016@qq.com>
This commit is contained in:
parent
95c617e04b
commit
8aca27fa11
@ -46,6 +46,12 @@ def run_vllm(requests: List[SampleRequest],
|
|||||||
warmup: bool = False) -> float:
|
warmup: bool = False) -> float:
|
||||||
from vllm import LLM, SamplingParams
|
from vllm import LLM, SamplingParams
|
||||||
llm = LLM(**vars(engine_args))
|
llm = LLM(**vars(engine_args))
|
||||||
|
assert all(
|
||||||
|
llm.llm_engine.model_config.max_model_len >= (
|
||||||
|
request.prompt_len + request.expected_output_len)
|
||||||
|
for request in requests), (
|
||||||
|
"Please ensure that max_model_len is greater than the sum of"
|
||||||
|
" prompt_len and expected_output_len for all requests.")
|
||||||
|
|
||||||
# Add the requests to the engine.
|
# Add the requests to the engine.
|
||||||
prompts: List[str] = []
|
prompts: List[str] = []
|
||||||
@ -115,6 +121,13 @@ async def run_vllm_async(
|
|||||||
async with build_async_engine_client_from_engine_args(
|
async with build_async_engine_client_from_engine_args(
|
||||||
engine_args, disable_frontend_multiprocessing) as llm:
|
engine_args, disable_frontend_multiprocessing) as llm:
|
||||||
|
|
||||||
|
assert all(
|
||||||
|
llm.model_config.max_model_len >= (request.prompt_len +
|
||||||
|
request.expected_output_len)
|
||||||
|
for request in requests), (
|
||||||
|
"Please ensure that max_model_len is greater than the sum of"
|
||||||
|
" prompt_len and expected_output_len for all requests.")
|
||||||
|
|
||||||
# Add the requests to the engine.
|
# Add the requests to the engine.
|
||||||
prompts: List[str] = []
|
prompts: List[str] = []
|
||||||
sampling_params: List[SamplingParams] = []
|
sampling_params: List[SamplingParams] = []
|
||||||
|
|||||||
@ -42,6 +42,10 @@ def main(args: argparse.Namespace):
|
|||||||
# NOTE(woosuk): If the request cannot be processed in a single batch,
|
# NOTE(woosuk): If the request cannot be processed in a single batch,
|
||||||
# the engine will automatically process the request in multiple batches.
|
# the engine will automatically process the request in multiple batches.
|
||||||
llm = LLM(**dataclasses.asdict(engine_args))
|
llm = LLM(**dataclasses.asdict(engine_args))
|
||||||
|
assert llm.llm_engine.model_config.max_model_len >= (
|
||||||
|
args.input_len + args.output_len), (
|
||||||
|
"Please ensure that max_model_len is greater than"
|
||||||
|
" the sum of input_len and output_len.")
|
||||||
|
|
||||||
sampling_params = SamplingParams(
|
sampling_params = SamplingParams(
|
||||||
n=args.n,
|
n=args.n,
|
||||||
|
|||||||
@ -13,6 +13,11 @@ from vllm.engine.arg_utils import EngineArgs
|
|||||||
from vllm.utils import FlexibleArgumentParser
|
from vllm.utils import FlexibleArgumentParser
|
||||||
|
|
||||||
|
|
||||||
|
#Select a equi-probable random priority
|
||||||
|
def get_random_flag():
|
||||||
|
return 0 if random.random() < 0.5 else 1
|
||||||
|
|
||||||
|
|
||||||
def sample_requests(
|
def sample_requests(
|
||||||
dataset_path: str,
|
dataset_path: str,
|
||||||
num_requests: int,
|
num_requests: int,
|
||||||
@ -55,8 +60,7 @@ def sample_requests(
|
|||||||
# Prune too long sequences.
|
# Prune too long sequences.
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#Select a equi-probable random priority
|
priority = get_random_flag()
|
||||||
priority = 0 if random.random() < 0.5 else 1
|
|
||||||
|
|
||||||
filtered_dataset.append((prompt, prompt_len, output_len, priority))
|
filtered_dataset.append((prompt, prompt_len, output_len, priority))
|
||||||
|
|
||||||
@ -71,6 +75,12 @@ def run_vllm(
|
|||||||
from vllm import LLM, SamplingParams
|
from vllm import LLM, SamplingParams
|
||||||
llm = LLM(**dataclasses.asdict(engine_args))
|
llm = LLM(**dataclasses.asdict(engine_args))
|
||||||
|
|
||||||
|
assert all(
|
||||||
|
llm.llm_engine.model_config.max_model_len >= (request[1] + request[2])
|
||||||
|
for request in requests), (
|
||||||
|
"Please ensure that max_model_len is greater than the sum of"
|
||||||
|
" input_len and output_len for all requests.")
|
||||||
|
|
||||||
# Add the requests to the engine.
|
# Add the requests to the engine.
|
||||||
prompts = []
|
prompts = []
|
||||||
sampling_params = []
|
sampling_params = []
|
||||||
@ -103,8 +113,8 @@ def main(args: argparse.Namespace):
|
|||||||
if args.dataset is None:
|
if args.dataset is None:
|
||||||
# Synthesize a prompt with the given input length.
|
# Synthesize a prompt with the given input length.
|
||||||
prompt = "hi" * (args.input_len - 1)
|
prompt = "hi" * (args.input_len - 1)
|
||||||
requests = [(prompt, args.input_len, args.output_len)
|
requests = [(prompt, args.input_len, args.output_len,
|
||||||
for _ in range(args.num_prompts)]
|
get_random_flag()) for _ in range(args.num_prompts)]
|
||||||
else:
|
else:
|
||||||
requests = sample_requests(args.dataset, args.num_prompts, tokenizer,
|
requests = sample_requests(args.dataset, args.num_prompts, tokenizer,
|
||||||
args.output_len)
|
args.output_len)
|
||||||
|
|||||||
@ -171,7 +171,12 @@ def run_vllm(
|
|||||||
) -> float:
|
) -> float:
|
||||||
from vllm import LLM, SamplingParams
|
from vllm import LLM, SamplingParams
|
||||||
llm = LLM(**dataclasses.asdict(engine_args))
|
llm = LLM(**dataclasses.asdict(engine_args))
|
||||||
|
assert all(
|
||||||
|
llm.llm_engine.model_config.max_model_len >= (
|
||||||
|
request.prompt_len + request.expected_output_len)
|
||||||
|
for request in requests), (
|
||||||
|
"Please ensure that max_model_len is greater than the sum of"
|
||||||
|
" prompt_len and expected_output_len for all requests.")
|
||||||
# Add the requests to the engine.
|
# Add the requests to the engine.
|
||||||
prompts: List[TextPrompt] = []
|
prompts: List[TextPrompt] = []
|
||||||
sampling_params: List[SamplingParams] = []
|
sampling_params: List[SamplingParams] = []
|
||||||
@ -229,6 +234,12 @@ async def run_vllm_async(
|
|||||||
|
|
||||||
async with build_async_engine_client_from_engine_args(
|
async with build_async_engine_client_from_engine_args(
|
||||||
engine_args, disable_frontend_multiprocessing) as llm:
|
engine_args, disable_frontend_multiprocessing) as llm:
|
||||||
|
assert all(
|
||||||
|
llm.model_config.max_model_len >= (request.prompt_len +
|
||||||
|
request.expected_output_len)
|
||||||
|
for request in requests), (
|
||||||
|
"Please ensure that max_model_len is greater than the sum of"
|
||||||
|
" prompt_len and expected_output_len for all requests.")
|
||||||
|
|
||||||
# Add the requests to the engine.
|
# Add the requests to the engine.
|
||||||
prompts: List[TextPrompt] = []
|
prompts: List[TextPrompt] = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user