okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
53623e56f
main
1#!/usr/bin/env python3 2"""Assemble data/engine.log from the engine log slices this report collected. 3 4The raw slices are one long block per server start (about 500 lines each, one 5per configuration and per interleaved request), which is too much for a PR. 6This keeps what the report is about from every slice: 7 8* the lines about the layer split, the PCIe probes, the expert caches, 9the resident stage, --batch and --pipeline-windows, 10* every completion line (`prompt N tokens = ...`) - the numbers in README, 11* the lines that say a feature was turned off or adjusted. 12 13and prefixes each section with the slice's name and how many lines it had. 14 15Usage: make_engine_log.py [--data DIR] 16""" 17import argparse 18import re 19from pathlib import Path 20 21DATA = Path (__file__ ).resolve ().parent .parent / 'data' 22 23KEEP = re .compile ( 24r'layer split|PCIe probe|pipeline-windows|--batch|resident|' 25r'expert cache|token graph|room for experts|prompt \d+ tokens =|' 26r'loads the dense weights|engine started|off:|WARNING|' 27r'session is up|KV streaming|GPU \d+:|decode expert cache hit|' 28r'strata mtp|strata batch|batch window|batch windows|no progress|\bnan\b' ,re .I ) 29 30ORDER = ['engine-interleave.log' ,'engine-ab-pipeline-off.log' , 31'engine-ab-stage-trim-off.log' ,'engine-ab-resident.log' , 32'soak-engine.log' ,'engine-ab-batch2.log' ,'engine-ab-batch4.log' , 33'batch-concurrent-batch2.engine.log' , 34'batch-concurrent-batch4.engine.log' ] 35 36 37def main (): 38p = argparse .ArgumentParser (description = __doc__ ) 39p .add_argument ('--data' ,type = Path ,default = DATA ) 40p .add_argument ('--out' ,type = Path ,default = None ) 41args = p .parse_args () 42out = args .out or (args .data / 'engine.log' ) 43parts = ['= engine.log: the lines of each slice this report kept =\n' , 44'built by scripts/make_engine_log.py; the raw slices sit beside it\n' ] 45names = [n for n in ORDER if (args .data / n ).exists ()] 46names += sorted (n .name for n in args .data .glob ('engine-*.log' ) 47if n .name not in names and n .name != 'engine.log' ) 48for name in names : 49text = (args .data / name ).read_text (encoding = 'utf-8' ,errors = 'replace' ) 50lines = text .splitlines () 51kept = [ln for ln in lines if KEEP .search (ln )] 52parts .append (f'\n=== { name } : { len ( lines ) } lines, { len ( kept ) } kept ===\n' ) 53parts .extend (ln + '\n' for ln in kept ) 54out .write_text ('' .join (parts ),encoding = 'utf-8' ) 55f' { out } : { out . stat (). st_size } bytes from { len ( names ) } slice(s)' ) 56 57 58if __name__ == '__main__' : 59main ()