Files
leleka/scripts/upstream-rest/turns.py
T

18 lines
840 B
Python

#!/usr/bin/env python3
"""Per-turn TTFT / decode tok/s / wall of the long-session.json of e2e run directories: turns.py RUN_DIR [RUN_DIR ...]"""
import json
import os
import sys
for r in sys.argv[1:]:
d = json.load(open(os.path.join(r, "long-session.json")))
turns = d if isinstance(d, list) else d.get("turns") or d.get("results") or []
if isinstance(d, dict) and not turns:
print(r, list(d)[:8])
continue
cells = " ".join(f"{t.get('ttft_s')}/{t.get('decode_tok_s')}" for t in turns)
wall = sum(t.get("wall_s", 0) for t in turns)
ttft = sum(t.get("ttft_s", 0) for t in turns)
dec = sum(t.get("decode_tok_s", 0) for t in turns) / max(len(turns), 1)
print(f"{os.path.basename(r):<24} ttft/decode per turn: {cells} | sum ttft {ttft:.1f} s, mean decode {dec:.1f} tok/s, sum wall {wall:.1f} s")