File size: 2,348 Bytes
3aac5ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Per-device card numbers from one bench_device.sh run: per-voice-count stalls and throughput, the largest voice count
with no stall in every round (and none below it), audio s/s at 8 and 16 voices, one-voice time to first audio, WER."""
import collections, json, os, re, statistics as st, sys

d = sys.argv[1]
def load(f):
    p = os.path.join(d, f)
    return [json.loads(l) for l in open(p) if l.strip().startswith("{")] if os.path.exists(p) else []

sides = ["stock", "turbo"]
rows = {s: collections.defaultdict(list) for s in sides}
for s in sides:
    for f in (f"cap-{s}.jsonl", f"cap-{s}b.jsonl"):
        for r in load(f):
            rows[s][r["conc"]].append(r)
concs = sorted(set().union(*[rows[s].keys() for s in sides]))
print("voices | " + " | ".join(f"{s} clean rounds | {s} longest stall ms | {s} audio s/s (mean)" for s in sides) + " | failed requests")
for c in concs:
    out, errs = [str(c)], 0
    for s in sides:
        rs = rows[s][c]
        if not rs:
            out += ["-", "-", "-"]; continue
        out += [f"{sum(r['stalled_b200'] == 0 for r in rs)}/{len(rs)}", f"{max(r['worst_ms_b200'] for r in rs):.0f}",
                f"{st.mean(r['audio_s_per_wall_s'] for r in rs):.1f}"]
        errs += sum(len(r["errors"]) + (r["conc"] - r["ok"]) for r in rs)
    print(" | ".join(out + [str(errs)]))
print()
for s in sides:
    live = 0
    for c in concs:
        rs = rows[s][c]
        if rs and all(r["stalled_b200"] == 0 and r["ok"] == c and not r["errors"] for r in rs):
            live = c
        else:
            break
    s8 = [r["audio_s_per_wall_s"] for r in rows[s].get(8, [])]
    s16 = [r["audio_s_per_wall_s"] for r in rows[s].get(16, [])]
    t = [r["ttfa_ms_median"] for r in load(f"ttfa-{s}.jsonl")]
    wer = None
    p = os.path.join(d, "rescore.log")
    if os.path.exists(p):
        m = re.search(rf"RESCORE \S*wer-{s} (\{{.*\}})", open(p).read())
        wer = json.loads(m.group(1)) if m else None
    print(json.dumps(dict(side=s, live_voices_no_stall=live, rounds=len(rows[s].get(concs[0], [])) if concs else 0,
                          audio_s_per_s_at_8=round(st.mean(s8), 1) if s8 else None,
                          audio_s_per_s_at_16=round(st.mean(s16), 1) if s16 else None,
                          ttfa_ms_one_voice_median=st.median(t) if t else None, ttfa_n=len(t), wer=wer)))