Add Qwen3.6 validation and benchmark coverage
This commit is contained in:
@@ -14,6 +14,7 @@ extra moving parts aren't worth it for the first iteration.
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import random
|
||||
import statistics
|
||||
import time
|
||||
from dataclasses import asdict, dataclass
|
||||
@@ -38,6 +39,7 @@ class QualityRow:
|
||||
n_total: int
|
||||
n_correct: int
|
||||
n_errors: int
|
||||
n_length: int
|
||||
accuracy: float
|
||||
mean_completion_tokens: float
|
||||
mean_ttft_ms: float
|
||||
@@ -58,7 +60,9 @@ class QualityCase:
|
||||
tpot_ms: float
|
||||
e2e_s: float
|
||||
error: str | None
|
||||
finish_reason: str | None
|
||||
response_preview: str
|
||||
response_text: str
|
||||
|
||||
|
||||
async def _run_one_task(
|
||||
@@ -66,7 +70,10 @@ async def _run_one_task(
|
||||
) -> tuple[QualityRow, list[QualityCase]]:
|
||||
problems = task_mod.load()
|
||||
if cfg.quality_limit is not None:
|
||||
problems = problems[: cfg.quality_limit]
|
||||
if cfg.quality_seed is not None and cfg.quality_limit < len(problems):
|
||||
problems = random.Random(cfg.quality_seed).sample(problems, cfg.quality_limit)
|
||||
else:
|
||||
problems = problems[: cfg.quality_limit]
|
||||
print(f"[quality] {ep.name} / {task_name}: {len(problems)} problems "
|
||||
f"(max_tokens={max_tokens})")
|
||||
|
||||
@@ -75,13 +82,20 @@ async def _run_one_task(
|
||||
async with httpx.AsyncClient(timeout=cfg.request_timeout_s) as client:
|
||||
for prob in problems:
|
||||
messages = task_mod.make_messages(prob["problem"])
|
||||
extra_body = dict(ep.extra_body or {})
|
||||
extra_body.update({
|
||||
"top_k": cfg.quality_top_k,
|
||||
"top_p": cfg.quality_top_p,
|
||||
"presence_penalty": cfg.quality_presence_penalty,
|
||||
"repetition_penalty": cfg.quality_repetition_penalty,
|
||||
})
|
||||
r = await chat_stream(
|
||||
client, ep.base_url, ep.model_id, messages,
|
||||
max_tokens=max_tokens,
|
||||
temperature=cfg.quality_temperature,
|
||||
api_key=ep.api_key,
|
||||
timeout=cfg.request_timeout_s,
|
||||
extra_body=ep.extra_body,
|
||||
extra_body=extra_body,
|
||||
)
|
||||
pred = task_mod.extract_answer(r.text) if r.error is None else None
|
||||
correct = task_mod.score(pred, prob["answer"]) if r.error is None else False
|
||||
@@ -91,8 +105,9 @@ async def _run_one_task(
|
||||
correct=correct, completion_tokens=r.completion_tokens,
|
||||
ttft_ms=r.ttft_s * 1000 if r.ttft_s > 0 else -1.0,
|
||||
tpot_ms=r.tpot_s * 1000 if r.tpot_s > 0 else -1.0,
|
||||
e2e_s=r.e2e_s, error=r.error,
|
||||
e2e_s=r.e2e_s, error=r.error, finish_reason=r.finish_reason,
|
||||
response_preview=(r.text or "")[:240].replace("\n", " "),
|
||||
response_text=r.text or "",
|
||||
))
|
||||
mark = "✓" if correct else ("E" if r.error else "✗")
|
||||
print(f" [{mark}] {prob['id']:>4s} gold={prob['answer']:>6s} "
|
||||
@@ -109,7 +124,9 @@ async def _run_one_task(
|
||||
n_total=len(cases),
|
||||
n_correct=correct,
|
||||
n_errors=errors,
|
||||
accuracy=correct / max(len(cases) - errors, 1),
|
||||
n_length=sum(1 for c in cases if c.finish_reason == "length"),
|
||||
# Transport/runtime failures are incorrect attempts, not exclusions.
|
||||
accuracy=correct / max(len(cases), 1),
|
||||
mean_completion_tokens=statistics.mean(c.completion_tokens for c in ok) if ok else 0.0,
|
||||
mean_ttft_ms=statistics.mean(c.ttft_ms for c in ok if c.ttft_ms > 0) if ok else -1.0,
|
||||
mean_tpot_ms=statistics.mean(c.tpot_ms for c in ok if c.tpot_ms > 0) if ok else -1.0,
|
||||
|
||||
Reference in New Issue
Block a user