"""Summarize synthetic metrics only; never reads generated text or credentials.""" import argparse,json,pathlib,re,statistics p=argparse.ArgumentParser();p.add_argument('directory');a=p.parse_args();root=pathlib.Path(a.directory) rows=json.loads((root/'results.json').read_text());summary={} for arm in ('serial_mtp','pipeline'): r=[x for x in rows if x['arm']==arm];short=[x for x in r if x['case'].startswith('solo-short')] parallel=[x for x in r if x['case'].startswith('parallel-short')] summary[arm]={'completed_cases':len(r), 'solo_short_output_tok_s':[y['backend_timings'].get('predicted_per_second') for x in short for y in x['rows']], 'parallel_short_per_request_output_tok_s':[y['backend_timings'].get('predicted_per_second') for x in parallel for y in x['rows']], 'cases':{x['case']:{'wall_seconds':x['wall_seconds'],'output_tok_s':[y['backend_timings'].get('predicted_per_second') for y in x['rows']], 'input_tok_s':[y['backend_timings'].get('prompt_per_second') for y in x['rows']], 'cached_tokens':[y['backend_timings'].get('cache_n') for y in x['rows']], 'new_input_tokens':[y['backend_timings'].get('prompt_n') for y in x['rows']], 'resources':x['resources']} for x in r}} log=root/f'engine-{arm}.log' if log.exists(): text=log.read_text(errors='replace') summary[arm]['resolved_resident_gib']=re.findall(r'(?:resident RAM mode:|resident) ([0-9.]+) GiB of experts in RAM',text)[:1] summary[arm]['batch_groups_reported']=sorted(set(re.findall(r'(?:batch_groups|batch groups)[= :]+([0-9]+)',text))) summary[arm]['batch_mtp_disabled_reported']=bool(re.search(r'(?i)(?:batch-mtp.{0,100}(?:off|disabled|ignored|left off)|(?:off|disabled|ignored).{0,100}batch-mtp)',text)) print(json.dumps(summary,indent=2))