| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | import lm_eval |
| 5 | |
| 6 | from ...utils import RemoteOpenAIServer |
| 7 | |
| 8 | # arc-easy uses prompt_logprobs=1, logprobs=1 |
| 9 | TASK = "arc_easy" |
| 10 | FILTER = "acc_norm,none" |
| 11 | RTOL = 0.03 |
| 12 | EXPECTED_VALUE = 0.62 |
| 13 | |
| 14 | # FIXME(rob): enable prefix caching once supported. |
| 15 | MODEL = "meta-llama/Llama-3.2-1B-Instruct" |
| 16 | MODEL_ARGS = f"pretrained={MODEL},enforce_eager=True,enable_prefix_caching=False,gpu_memory_utilization=0.8" # noqa: E501 |
| 17 | SERVER_ARGS = [ |
| 18 | "--enforce_eager", |
| 19 | "--no_enable_prefix_caching", |
| 20 | "--gpu-memory-utilization=0.8", |
| 21 | ] |
| 22 | NUM_CONCURRENT = 100 |
| 23 | |
| 24 | |
| 25 | def test_prompt_logprobs_e2e(): |
| 26 | results = lm_eval.simple_evaluate( |
| 27 | model="vllm", model_args=MODEL_ARGS, tasks=TASK, batch_size="auto" |
| 28 | ) |
| 29 | |
| 30 | measured_value = results["results"][TASK][FILTER] |
| 31 | assert ( |
| 32 | measured_value - RTOL < EXPECTED_VALUE |
| 33 | and measured_value + RTOL > EXPECTED_VALUE |
| 34 | ), f"Expected: {EXPECTED_VALUE} | Measured: {measured_value}" |
| 35 | |
| 36 | |
| 37 | def test_prompt_logprobs_e2e_server(): |
| 38 | with RemoteOpenAIServer(MODEL, SERVER_ARGS) as remote_server: |
| 39 | url = f"{remote_server.url_for('v1')}/completions" |
| 40 | |
| 41 | model_args = ( |
| 42 | f"model={MODEL}," |
| 43 | f"base_url={url}," |
| 44 | f"num_concurrent={NUM_CONCURRENT},tokenized_requests=False" |
| 45 | ) |
| 46 | |
| 47 | results = lm_eval.simple_evaluate( |
| 48 | model="local-completions", |
| 49 | model_args=model_args, |
| 50 | tasks=TASK, |
| 51 | ) |
| 52 | |
| 53 | measured_value = results["results"][TASK][FILTER] |
| 54 | assert ( |
| 55 | measured_value - RTOL < EXPECTED_VALUE |
| 56 | and measured_value + RTOL > EXPECTED_VALUE |
| 57 | ), f"Expected: {EXPECTED_VALUE} | Measured: {measured_value}" |