Skip to content

Commit

Permalink
Benchmark serving structured output (#10880)
Browse files Browse the repository at this point in the history
Signed-off-by: Chendi Xue <[email protected]>
Co-authored-by: Michael Goin <[email protected]>
  • Loading branch information
xuechendi and mgoin authored Dec 4, 2024
1 parent 10398b4 commit 82eb5ea
Show file tree
Hide file tree
Showing 2 changed files with 887 additions and 0 deletions.
6 changes: 6 additions & 0 deletions benchmarks/backend_request_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class RequestFuncInput:
model: str
best_of: int = 1
logprobs: Optional[int] = None
extra_body: Optional[dict] = None
multi_modal_content: Optional[dict] = None
ignore_eos: bool = False

Expand All @@ -36,6 +37,7 @@ class RequestFuncOutput:
ttft: float = 0.0 # Time to first token
itl: List[float] = field(
default_factory=list) # List of inter-token latencies
tpot: float = 0.0 # avg next-token latencies
prompt_len: int = 0
error: str = ""

Expand Down Expand Up @@ -242,6 +244,8 @@ async def async_request_openai_completions(
"stream": True,
"ignore_eos": request_func_input.ignore_eos,
}
if request_func_input.extra_body:
payload.update(request_func_input.extra_body)
headers = {
"Authorization": f"Bearer {os.environ.get('OPENAI_API_KEY')}"
}
Expand Down Expand Up @@ -336,6 +340,8 @@ async def async_request_openai_chat_completions(
"stream": True,
"ignore_eos": request_func_input.ignore_eos,
}
if request_func_input.extra_body:
payload.update(request_func_input.extra_body)
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.environ.get('OPENAI_API_KEY')}",
Expand Down
Loading

0 comments on commit 82eb5ea

Please sign in to comment.