"""Full installed-model cold/warm chunk-guard reference, with exact state checks.""" import argparse,hashlib,json,os,subprocess,sys from pathlib import Path checkout,root,native,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)) from mtplx.server.openai import _server_runtime_env_overrides if os.environ.get('DS4_ISSUE110_STOCK_CONTROL')!='1': os.environ.update(_server_runtime_env_overrides(argparse.Namespace(model=str(root),generation_mode='ar'),None)) os.environ.update(MTPLX_COMPILED_GDN='1',MTPLX_QWEN4EXP_COMPILE='1',MTPLX_SUSTAINED_PREFILL='1') import mlx.core as mx import numpy as np from mlx_lm.utils import load_model from mtplx.models import qwen4_exp from mtplx.runtime import MTPLXRuntime,_load_tokenizer_resilient from mtplx.sampling import SamplerConfig from mtplx.generation import generate_ar from mtplx.cache_state import snapshot_cache from mtplx.session_bank import SessionBank from mtplx import moe_sorted_gather as msg from mtplx.kernels import moe_sorted_gather_nax as kernel assert mx.__version__=='0.32.2' assert os.environ.get('MTPLX_GDN_BOUNDARY_TAIL_INTERVAL')=='0' out.mkdir(parents=True,exist_ok=True) model,config=load_model(root,lazy=False,strict=True,get_model_classes=lambda **_:(qwen4_exp.Model,qwen4_exp.ModelArgs)) model.post_weight_load(root) tokenizer=_load_tokenizer_resilient(root,config) rt=MTPLXRuntime(model,tokenizer,root,False,None) def fingerprint(a): values=np.asarray(a.astype(mx.float32)).astype('