okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
2b36e8a02
main
1#!/usr/bin/env python3 2"""A wider identity gate than research/tools/dgx-spark-2026-10/dgx_quality.py's five: 24 prompts across code, prose, math, multilingual and tool-shaped 3asks, greedy, comparing the fused prompt path against MMQ byte for byte. 4 5python quality24.py CONFIG_A CONFIG_B OUT.json [--port 8091] 6""" 7import json 8import subprocess 9import sys 10import time 11import urllib .request 12from pathlib import Path 13 14ROOT = Path (__file__ ).resolve ().parents [3 ] 15PROMPTS = [ 16"Write a Python function that returns the longest palindromic substring of a string, with a docstring." , 17"In C, what does `static inline` mean at file scope and when should it be used? Two sentences." , 18"Explain the difference between a mutex and a semaphore to a junior developer, in under 100 words." , 19"Translate 'The server is down and we are investigating' into German, French and Spanish, one line each." , 20"Summarise the plot of Pride and Prejudice in exactly three sentences." , 21"What is the time complexity of building a binary heap, and why?" , 22"Write a SQL query that returns the five customers with the highest total order value." , 23"List four failure modes of a distributed lock and one mitigation each, as a table." , 24"给一个刚学编程的人解释什么是递归,100字以内。" , 25"Erkläre den Unterschied zwischen TCP und UDP in drei Sätzen." , 26"Écris une fonction JavaScript qui inverse une chaîne sans utiliser reverse()." , 27"What happens in a Linux system when you run `rm -rf /` as root? Be technical and brief." , 28"Give me a shell one-liner that finds the ten largest files under /var/log." , 29"Why does a transformer need positional encodings? Answer in two sentences." , 30"Write a haiku about a GPU fan spinning up." , 31"What is the difference between `git rebase` and `git merge` for a shared branch? Two sentences." , 32"Explain Bloom filters and give one production use case, under 80 words." , 33"Sort these numbers ascending and show the result: 42, 7, 19, 3, 88, 15." , 34"What does the error `CUDA error: an illegal memory access was encountered` usually mean?" , 35"Describe how to measure the power draw of a single process on Linux." , 36"Write a regex that matches ISO-8601 dates and explain each part." , 37"What is the difference between a process and a thread in one sentence?" , 38"Give me a JSON object with three fields describing a book, and no prose." , 39"Explain why 0.1 + 0.2 != 0.3 in floating point, briefly." , 40] 41 42 43def wait (port ,proc ): 44t0 = time .time () 45while time .time ()- t0 < 900 : 46if proc .poll ()is not None : 47raise SystemExit (f"server exited { proc . returncode } " ) 48try : 49with urllib .request .urlopen (f"http://127.0.0.1: { port } /v1/models" ,timeout = 5 )as r : 50if r .status == 200 : 51return 52except Exception : 53pass 54time .sleep (3 ) 55raise SystemExit ("server did not come up" ) 56 57 58def ask (port ,prompt ,max_new = 96 ): 59body = json .dumps ({"messages" : [{"role" :"user" ,"content" :prompt }],"max_tokens" :max_new ,"temperature" :0 , 60"chat_template_kwargs" : {"enable_thinking" :False }}).encode () 61req = urllib .request .Request (f"http://127.0.0.1: { port } /v1/chat/completions" ,data = body , 62headers = {"Content-Type" :"application/json" }) 63with urllib .request .urlopen (req ,timeout = 1800 )as r : 64out = json .loads (r .read ()) 65return out ["choices" ][0 ]["message" ].get ("content" ,"" ) 66 67 68def run_config (cfg_path ,port ,tag ): 69cfg = json .loads (Path (cfg_path ).read_text ()) 70cfg ["port" ]= port 71cfg ["log" ]= f"/tmp/quality24- { tag } .log" 72tmp = Path (f"/tmp/quality24- { tag } .json" ) 73tmp .write_text (json .dumps (cfg ,indent = 1 )) 74proc = subprocess .Popen ([sys .executable ,str (ROOT / "serve" / "server.py" ),"--engine" ,"strata" ,"--config" , 75str (tmp ),"--port" ,str (port )],cwd = str (ROOT ), 76stdout = subprocess .DEVNULL ,stderr = subprocess .DEVNULL ) 77answers = [] 78try : 79wait (port ,proc ) 80ask (port ,"Say hi." ,8 ) 81for p in PROMPTS : 82answers .append (ask (port ,p )) 83finally : 84proc .terminate () 85try : 86proc .wait (120 ) 87except subprocess .TimeoutExpired : 88proc .kill () 89return answers 90 91 92def main (): 93a_cfg ,b_cfg ,out_json = sys .argv [1 ],sys .argv [2 ],sys .argv [3 ] 94port = int (sys .argv [4 ])if len (sys .argv )> 4 else 8091 95a = run_config (a_cfg ,port ,"a" ) 96b = run_config (b_cfg ,port ,"b" ) 97same = sum (1 for x ,y in zip (a ,b )if x == y ) 98rows = [{"prompt" :p ,"a" :x ,"b" :y ,"identical" :x == y }for p ,x ,y in zip (PROMPTS ,a ,b )] 99Path (out_json ).write_text (json .dumps ({"identical" :same ,"total" :len (PROMPTS ),"rows" :rows },indent = 1 )) 100f" { same } of { len ( PROMPTS ) } answers identical" ) 101for i ,r in enumerate (rows ): 102if not r ["identical" ]: 103f" differs at prompt { i } : { r [ 'prompt' ][: 60 ]!r } " ) 104f" A: { r [ 'a' ][: 90 ]!r } " ) 105f" B: { r [ 'b' ][: 90 ]!r } " ) 106 107 108if __name__ == "__main__" : 109main ()