"""Is the earlier bit-identity failure reproducible? Stress the pattern that failed: warm W -> P+ (REUSED) -> P+ (COLD), repeated N times, and count mismatches. If mismatches recur, it is a race/contamination bug. If not, the earlier failure had another cause. """ import json, urllib.request, hashlib URL="http://127.0.0.1:8300/v1/chat/completions" def ask(prompt, mt=8, temp=0): body={"model":"glm-5.3-exl3","messages":[{"role":"user","content":prompt}],"max_tokens":mt, "temperature":temp,"return_token_ids":True} r=urllib.request.Request(URL,data=json.dumps(body).encode(),headers={"Content-Type":"application/json"}) d=json.loads(urllib.request.urlopen(r,timeout=3600).read()) st=d.get("tensorfold",{}) or {} ids=st.get("token_ids") or [] return st.get("cached"), hashlib.sha256(json.dumps(ids).encode()).hexdigest()[:16] unit="The service validated the payload and emitted a structured record with stable ids. " bad=0; tot=0 for it in range(8): base=(unit*(60+it*7)) # a DIFFERENT base each iteration (new conversation) W=base+"\nReply with YES." P=base+"\nReply with OK. Be brief." # P+ pattern: multi-token suffix cW,sW=ask(W) cR,sR=ask(P) cC,sC=ask(P) ok = (sR==sC) tot+=1; bad += (not ok) print(f" it{it}: warm_cached={cW:5} reused_cached={cR:5} cold_cached={cC:5} " f"reused={sR} cold={sC} MATCH={ok}", flush=True) print(f"\n mismatches: {bad}/{tot}") print("### STRESS DONE")