Add accuracy test to CI: MMLU (#882)

This commit is contained in:
Ying Sheng
2024-08-01 21:20:17 -07:00
committed by GitHub
parent 76e59088d8
commit ae7ee01a8e
24 changed files with 831 additions and 136 deletions
+32
View File
@@ -1,6 +1,8 @@
"""Common utilities for testing and benchmarking"""
import asyncio
import subprocess
import time
from functools import partial
import numpy as np
@@ -11,6 +13,8 @@ from sglang.lang.backend.openai import OpenAI
from sglang.lang.backend.runtime_endpoint import RuntimeEndpoint
from sglang.utils import get_exception_traceback
MODEL_NAME_FOR_TEST = "meta-llama/Meta-Llama-3.1-8B-Instruct"
def call_generate_lightllm(prompt, temperature, max_tokens, stop=None, url=None):
assert url is not None
@@ -379,3 +383,31 @@ def get_call_select(args):
raise
return func
def popen_launch_server(model, port, timeout, *args):
command = [
"python3",
"-m",
"sglang.launch_server",
"--model-path",
model,
"--host",
"localhost",
"--port",
str(port),
*args,
]
process = subprocess.Popen(command, stdout=None, stderr=None)
base_url = f"http://localhost:{port}/v1"
start_time = time.time()
while time.time() - start_time < timeout:
try:
response = requests.get(f"{base_url}/models")
if response.status_code == 200:
return process
except requests.RequestException:
pass
time.sleep(10)
raise TimeoutError("Server failed to start within the timeout period.")