okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
8ac4b945a
main
1"""#528: the restore-speed bench's own logic (no GPU): flag overrides and the pass/fail rule.""" 2import sys 3import unittest 4from pathlib import Path 5 6sys .path .insert (0 ,str (Path (__file__ ).resolve ().parent )) 7import conversation_restore_speed as R # noqa: E402 8 9 10def turn (name ,ids ,ms ,reused = 1 ): 11return {'name' :name ,'ids' :ids ,'generated' :len (ids ),'decode_ms' :ms ,'reused' :reused } 12 13 14class Bench (unittest .TestCase ): 15def test_override (self ): 16args = ['--max-context' ,'32768' ,'--kv' ,'int8' ] 17self .assertEqual (R .override (args ,R .parse_sets (['--max-context=65536' ,'--kv-resident=16384' ,'--kv=' ])), 18 ['--max-context' ,'65536' ,'--kv-resident' ,'16384' ]) 19 20def test_compare (self ): 21base = [turn ('A1' , [1 ,2 ],100 ,0 ),turn ('A2' , [3 ,4 ],100 )] 22ok = {'baseline' :base ,'candidate' : [turn ('A1' , [1 ,2 ],100 ,0 ),turn ('B2' , [9 ],10 ), 23turn ('A2' , [3 ,4 ],110 )]} 24self .assertEqual (R .compare (ok ,0.15 ), []) 25slow = {'baseline' :base ,'candidate' : [turn ('A1' , [1 ,2 ],100 ,0 ),turn ('A2' , [3 ,4 ],400 )]} 26self .assertTrue (any ('restored decode' in p for p in R .compare (slow ,0.15 ))) 27differ = {'baseline' :base ,'candidate' : [turn ('A1' , [1 ,2 ],100 ,0 ),turn ('A2' , [3 ,5 ],100 )]} 28self .assertTrue (any ('output differs' in p for p in R .compare (differ ,0.15 ))) 29unrestored = {'baseline' :base ,'candidate' : [turn ('A1' , [1 ,2 ],100 ,0 ),turn ('A2' , [3 ,4 ],100 ,0 )]} 30self .assertTrue (any ('not restored' in p for p in R .compare (unrestored ,0.15 ))) 31 32 33if __name__ == '__main__' : 34unittest .main ()