"""Isolate the extra oracle snapshot that changed the reported key's zero sign.""" import hashlib,json,subprocess,sys from pathlib import Path checkout,native,old_oracle,out=map(Path,sys.argv[1:5]) assert subprocess.check_output(['git','-C',str(checkout),'rev-parse','HEAD'],text=True).strip()=='9882703f3105363ddc37eca9f97aa09a1d387112' sys.path.insert(0,str(checkout)) import mlx.core as mx import numpy as np from mtplx.models.qwen4_exp import QSACache from mtplx.cache_state import snapshot_cache,snapshot_cache_lazy_hybrid assert mx.__version__=='0.32.2' def data(a):return np.asarray(a.view(mx.uint16 if a.dtype==mx.bfloat16 else mx.uint32)).tobytes() def cache(a): c=QSACache();c.state=(a,a,None,None);return c cases=[] for dtype in [mx.bfloat16,mx.float32]: bits=np.array([0x80000000,0,0xbf800000,0x3f800000,0,0x80000000,0x40000000,0xc0000000],dtype=np.uint32) a=mx.array(bits.view(np.float32).reshape(1,2,1,4)).astype(dtype) c=cache(a);raw=c.state[0];lazy=snapshot_cache_lazy_hybrid([c]);deep=snapshot_cache([c]) row=dict(dtype=str(dtype),shape=list(a.shape),raw=data(raw).hex(),lazy=data(lazy.states[0][0]).hex(),deep=data(deep.states[0][0]).hex()) assert row['raw']==row['lazy'] and row['raw']!=row['deep'] cases.append(row) traces=[] for phase in ['cold-prefill','cold','warm']: f=native/(phase+'-key35.f32');before=f.read_bytes();shape=(1,2,len(before)//(2*256*4),256) a=mx.array(np.frombuffer(before,dtype='