okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
f7e12d23c
main
1#!/usr/bin/env python3 2"""A stub engine for exercising `strata tune run` end to end, on every OS. 3 4Run it as ``[sys.executable, "stub_engine.py", "--serve", ...]`` (``strata_control.tuning.engine_command`` 5does that for any ``.py`` engine). It speaks the real serve protocol (READY / PP / T / DONE) and 6makes its decode speed depend on one flag, so a sweep has something real to find. It is NOT a model 7and its numbers mean nothing about any hardware -- it exists so the *sweep machinery* can be tested 8without weights. 9 10--kv int8 decodes at 200 tok/s 11anything else (including --kv fp16) decodes at 100 tok/s 12 13The prompt's length comes from the GEN line's token list, so the workload is genuinely the one the 14caller asked for. 15""" 16import sys 17 18 19def main (argv ): 20kv = "unknown" 21for index ,arg in enumerate (argv ): 22if arg == "--kv" and index + 1 < len (argv ): 23kv = argv [index + 1 ] 24if "--help" in argv : 25sys .stderr .write ("usage:\n --kv KV\n --ple-io MODE\n" ) 26return 0 27out = sys .stdout 28out .write ("READY 32768 stop\n" ) 29out .flush () 30for raw in sys .stdin : 31line = raw .strip () 32if line == "QUIT" or not line : 33return 0 34if not line .startswith ("GEN" ): 35continue 36fields = line .split () 37count = len (fields [- 1 ].split ("," )) 38try : 39max_new = int (fields [1 ]) 40except (IndexError ,ValueError ): 41max_new = 8 42decode_ms = 50.0 if kv == "int8" else 100.0 43out .write (f"PP { count } { count } 200.0 2560.0\n" ) 44for i in range (max_new ):# one T per token: the harness cross-checks the stream against DONE 45out .write (f"T { i } \n" ) 46out .write (f"DONE { max_new } { count } 200.0 { decode_ms } stop 0 0\n" ) 47out .flush () 48return 0 49 50 51if __name__ == "__main__" : 52sys .exit (main (sys .argv [1 :]))