update (#5625)
Some checks failed
CE Compile Job / ce_job_pre_check (push) Has been cancelled
CE Compile Job / print_ce_job_pre_check_outputs (push) Has been cancelled
CE Compile Job / FD-Clone-Linux (push) Has been cancelled
CE Compile Job / Show Code Archive Output (push) Has been cancelled
CE Compile Job / BUILD_SM8090 (push) Has been cancelled
CE Compile Job / BUILD_SM8689 (push) Has been cancelled
CE Compile Job / CE_UPLOAD (push) Has been cancelled
Deploy GitHub Pages / deploy (push) Has been cancelled
Publish Job / publish_pre_check (push) Has been cancelled
Publish Job / print_publish_pre_check_outputs (push) Has been cancelled
Publish Job / FD-Clone-Linux (push) Has been cancelled
Publish Job / Show Code Archive Output (push) Has been cancelled
Publish Job / BUILD_SM8090 (push) Has been cancelled
Publish Job / BUILD_SM8689 (push) Has been cancelled
Publish Job / PADDLE_PYPI_UPLOAD_8090 (push) Has been cancelled
Publish Job / PADDLE_PYPI_UPLOAD_8689 (push) Has been cancelled
Publish Job / Run FD Image Build (push) Has been cancelled
Publish Job / Run FastDeploy Unit Tests and Coverage (push) Has been cancelled
Publish Job / Run FastDeploy LogProb Tests (push) Has been cancelled
Publish Job / Extracted partial CE model tasks to run in CI. (push) Has been cancelled
Publish Job / Run Base Tests (push) Has been cancelled
Publish Job / Run Accuracy Tests (push) Has been cancelled
Publish Job / Run Stable Tests (push) Has been cancelled
CI Images Build / FD-Clone-Linux (push) Has been cancelled
CI Images Build / Show Code Archive Output (push) Has been cancelled
CI Images Build / CI Images Build (push) Has been cancelled
CI Images Build / BUILD_SM8090 (push) Has been cancelled
CI Images Build / Run FastDeploy Unit Tests and Coverage (push) Has been cancelled
CI Images Build / Run FastDeploy LogProb Tests (push) Has been cancelled
CI Images Build / Extracted partial CE model tasks to run in CI. (push) Has been cancelled
CI Images Build / Run Base Tests (push) Has been cancelled
CI Images Build / Publish Docker Images Pre Check (push) Has been cancelled

This commit is contained in:
Zhang Yulong
2025-12-17 21:38:14 +08:00
committed by GitHub
parent 94be5ebdd1
commit f45c131ddf
3 changed files with 191 additions and 45 deletions

View File

@@ -74,6 +74,8 @@ class RequestFuncOutput:
tpot: float = 0.0 # avg next-token latencies
prompt_len: int = 0
prompt_tokens: int = 0 # 推理侧返回输入token数
reasoning_tokens: int = 0 # 思考长度
res_ttft: int = 0 # 包含思考首token时延
error: str = ""
metrics: dict = field(default_factory=dict)
@@ -198,11 +200,14 @@ async def async_request_eb_openai_chat_completions(
request_id = "None"
ttft = 0.0
res_ttft = 0.0
st = time.perf_counter()
most_recent_timestamp = st
token_timestamps = []
try:
async with session.post(url=api_url, json=payload, headers=headers) as response:
async with session.post(
url=api_url, json=payload, headers=headers, read_bufsize=10 * 1024 * 1024
) as response:
data = {}
if response.status == 200:
async for chunk_bytes in response.content:
@@ -242,6 +247,14 @@ async def async_request_eb_openai_chat_completions(
else:
output.itl.append(timestamp - most_recent_timestamp)
# response首token
if res_ttft == 0.0:
if content:
res_ttft = choices[0]["arrival_time"]
output.res_ttft = res_ttft
usage = data.get("usage", {})
output.reasoning_tokens = max(usage.get("completion_tokens", 0) - 1, 0)
output.generated_text += content or ""
output.reasoning_content += reason_content or ""
# print(f"####content:{data}")
@@ -262,6 +275,7 @@ async def async_request_eb_openai_chat_completions(
if output.generated_text.strip() == "":
output.success = False
output.reasoning_tokens = output.output_tokens
output.error = "No generated text found!"
else:
output.success = True
@@ -284,7 +298,7 @@ async def async_request_eb_openai_chat_completions(
output.request_id = request_id
# 保存失败请求结果
if not output.success:
if not output.success or output.output_tokens == 0:
with open("error_output.txt", "a") as f:
f.write(str(output) + "\n")
if pbar: