Spaces:
Sleeping
Sleeping
Commit ·
1304e7c
1
Parent(s): 3fb3586
perf(eval): KI-024 — parallelize 96-Q gold eval with --workers semaphore
Browse filesWas fully serial: 96 questions × ~25s = 38 min total. Now defaults to 6
concurrent under a semaphore. Cap is upstream NIM (40 req/min, ~2 calls
per question), so 6 workers gives ~5× speedup before saturating. Output
order preserved via indexed result slots + a log lock for printing.
Use --workers 1 to reproduce historical serial timing if needed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- eval/run.py +24 -8
eval/run.py
CHANGED
|
@@ -276,6 +276,10 @@ async def main():
|
|
| 276 |
parser.add_argument("--policy", default=None)
|
| 277 |
parser.add_argument("--no-judge", action="store_true",
|
| 278 |
help="Use regex grader instead of Groq LLM-judge (free of rate limits; used by sweeps)")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
args = parser.parse_args()
|
| 280 |
|
| 281 |
if not GOLD_FILE.exists():
|
|
@@ -287,16 +291,28 @@ async def main():
|
|
| 287 |
if args.limit:
|
| 288 |
gold = gold[: args.limit]
|
| 289 |
|
| 290 |
-
print(f"Running eval on {len(gold)} questions...\n")
|
| 291 |
-
results: list[EvalRecord] = []
|
| 292 |
t0 = time.time()
|
| 293 |
-
for i, g in enumerate(gold, 1):
|
| 294 |
-
rec = await run_one(g, no_judge=args.no_judge)
|
| 295 |
-
results.append(rec)
|
| 296 |
-
ok_factual = "✓" if rec.factual_match else "✗"
|
| 297 |
-
ok_cite = "✓" if rec.citation_present else " "
|
| 298 |
-
print(f"[{i:>3}/{len(gold)}] {ok_factual} {ok_cite} [{rec.judge_score:.2f}] {rec.question[:60]:<60} | {rec.judge_reason[:60]}")
|
| 299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
elapsed = time.time() - t0
|
| 301 |
|
| 302 |
# Aggregate
|
|
|
|
| 276 |
parser.add_argument("--policy", default=None)
|
| 277 |
parser.add_argument("--no-judge", action="store_true",
|
| 278 |
help="Use regex grader instead of Groq LLM-judge (free of rate limits; used by sweeps)")
|
| 279 |
+
parser.add_argument("--workers", type=int, default=6,
|
| 280 |
+
help="Concurrent questions in flight. KI-024 — was serial, now parallel. "
|
| 281 |
+
"Cap is NIM's 40 req/min (~2 calls per question); 6 workers gives ~5× "
|
| 282 |
+
"speedup before saturating. Drop to 1 to reproduce historical serial timing.")
|
| 283 |
args = parser.parse_args()
|
| 284 |
|
| 285 |
if not GOLD_FILE.exists():
|
|
|
|
| 291 |
if args.limit:
|
| 292 |
gold = gold[: args.limit]
|
| 293 |
|
| 294 |
+
print(f"Running eval on {len(gold)} questions with {args.workers} workers...\n")
|
| 295 |
+
results: list[EvalRecord] = [None] * len(gold) # preserve order
|
| 296 |
t0 = time.time()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
|
| 298 |
+
sema = asyncio.Semaphore(args.workers)
|
| 299 |
+
log_lock = asyncio.Lock()
|
| 300 |
+
completed_counter = {"n": 0}
|
| 301 |
+
|
| 302 |
+
async def run_with_sema(idx: int, g: dict) -> None:
|
| 303 |
+
async with sema:
|
| 304 |
+
rec = await run_one(g, no_judge=args.no_judge)
|
| 305 |
+
results[idx] = rec
|
| 306 |
+
async with log_lock:
|
| 307 |
+
completed_counter["n"] += 1
|
| 308 |
+
i = completed_counter["n"]
|
| 309 |
+
ok_factual = "✓" if rec.factual_match else "✗"
|
| 310 |
+
ok_cite = "✓" if rec.citation_present else " "
|
| 311 |
+
print(f"[{i:>3}/{len(gold)}] {ok_factual} {ok_cite} [{rec.judge_score:.2f}] "
|
| 312 |
+
f"{rec.question[:60]:<60} | {rec.judge_reason[:60]}",
|
| 313 |
+
flush=True)
|
| 314 |
+
|
| 315 |
+
await asyncio.gather(*(run_with_sema(i, g) for i, g in enumerate(gold)))
|
| 316 |
elapsed = time.time() - t0
|
| 317 |
|
| 318 |
# Aggregate
|