okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
6e1085c1d
main
1"""Repeat the mixed 30-minute soak after startup, retaining guard stops.""" 2import argparse 3import json 4import socket 5import subprocess 6import sys 7import time 8 9from strata_bench_continue import Continuation ,b 10 11 12def main (): 13parser = argparse .ArgumentParser () 14parser .add_argument ("--model" ,choices = ("iq2_xs" ,"iq3_s" ),required = True ) 15args = parser .parse_args () 16with socket .socket ()as sock : 17if sock .connect_ex (("127.0.0.1" ,b .PORT ))== 0 : 18raise RuntimeError ("Benchmark service is occupied; it was preserved" ) 19runner = Continuation (["iq3_xxs" ,"iq3_s" ]) 20 (b .OUT / f"soak-retry- { args . model } .pid" ).write_text (str (b .os .getpid ())) 21supervisor = subprocess .Popen ([sys .executable ,str (b .SCRIPT ),"--watchdog" ,str (b .os .getpid ()), 22str (runner .clock ["measurement_stop_epoch" ]+ 300 )],stdout = subprocess .DEVNULL , 23stderr = subprocess .DEVNULL ,creationflags = b .FLAGS ) 24began ,count ,outcome ,reason = None ,0 ,"not_started" ,None 25try : 26runner .budget ("soak_retry_prepare" ,min (420 ,max (0 ,runner .hard - time .monotonic ()))) 27runner .init_tokenizer () 28runner .inventory () 29if runner .hard - time .monotonic ()< 1800 + 60 : 30raise b .CaseError ("insufficient reserve for a complete 30-minute soak" ) 31runner .start (args .model ) 32runner .budget ("soak_retry" ,1800 ) 33began = time .monotonic () 34outcome = "running" 35while runner .left ()> 5 : 36if count % 4 == 0 : 37runner .perform (f"soak-retry-check- { count } " , 38"Calculate 17 multiplied by 19. Reply only with the integer result." , 39group = "soak_retry" ,max_tokens = 16 ,expected = "323" ) 40else : 41target = (512 ,32768 ,128000 )[(count - 1 )% 3 ] 42runner .perform (f"soak-retry- { count } " ,runner .make (target ,rep = 1000 + count ),target , 43group = "soak_retry" ,max_tokens = 512 ) 44count += 1 45time .sleep (min (5 ,runner .left ())) 46outcome = "duration_completed" 47except b .CaseError as exc : 48reason = str (exc ) 49outcome = "duration_completed" if began and reason == "deadline" and time .monotonic ()- began >= 1795 else "stopped" 50except Exception as exc : 51outcome ,reason = "unexpected_error" ,f" { type ( exc ). __name__ } : { exc } " 52raise 53finally : 54result = {"model" :args .model ,"outcome" :outcome ,"reason" :reason , 55"observed_request_window_seconds" :time .monotonic ()- began if began else 0 , 56"completed_requests" :count ,"weights_mode" :runner .weights_mode , 57"engine_environment" :getattr (runner ,"engine_environment" , {}),"target_seconds" :1800 , 58"startup_included_in_duration" :False } 59b .write (b .OUT / f"soak-retry- { args . model } .json" ,result ) 60runner .event ("soak_retry_finish" ,** result ) 61if runner .active_worker and runner .active_worker .poll ()is None : 62b .kill_tree (runner .active_worker ) 63for job in runner .child_jobs : 64b .kill_tree (job ) 65runner .stop () 66runner .monitor .done .set () 67if supervisor .poll ()is None : 68supervisor .terminate () 69 70 71if __name__ == "__main__" : 72main ()