feat: add priority based scheduling with priority based request acceptance and preemption (#8746)
This commit is contained in:
@@ -17,7 +17,7 @@ from dataclasses import dataclass
|
||||
from functools import partial
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import Awaitable, Callable, List, Optional, Tuple
|
||||
from typing import Any, Awaitable, Callable, List, Optional, Tuple
|
||||
|
||||
import aiohttp
|
||||
import numpy as np
|
||||
@@ -1390,6 +1390,41 @@ async def send_concurrent_generate_requests(
|
||||
return await asyncio.gather(*tasks)
|
||||
|
||||
|
||||
async def send_concurrent_generate_requests_with_custom_params(
|
||||
base_url: str,
|
||||
custom_params: List[dict[str, Any]],
|
||||
) -> Tuple[int, Any]:
|
||||
"""Sends generate request concurrently with custom parameters and returns status code and response json tuple. Max concurrency is num_requests."""
|
||||
|
||||
base_payload = {
|
||||
"text": """
|
||||
System: You are a helpful assistant.
|
||||
User: What is the capital of France?
|
||||
Assistant: The capital of France is
|
||||
""",
|
||||
"sampling_params": {
|
||||
"temperature": 0,
|
||||
"max_new_tokens": 50,
|
||||
},
|
||||
}
|
||||
|
||||
async def async_generate_with_priority(req):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(
|
||||
f"{base_url}/generate",
|
||||
json=req,
|
||||
) as response:
|
||||
resp_json = await response.json()
|
||||
return (response.status, resp_json)
|
||||
|
||||
tasks = []
|
||||
for c in custom_params:
|
||||
req = base_payload.copy()
|
||||
req.update(c)
|
||||
tasks.append(asyncio.create_task(async_generate_with_priority(req)))
|
||||
return await asyncio.gather(*tasks)
|
||||
|
||||
|
||||
class CustomTestCase(unittest.TestCase):
|
||||
def _callTestMethod(self, method):
|
||||
max_retry = int(
|
||||
|
||||
Reference in New Issue
Block a user