"""Standalone artifact entry for the same qualified original-native BF16 MLU path. The model owns its full body, trained FP32 master head, processor and reference source. A fresh worker needs the pinned qualified runtime, not the parent model. """ import hashlib,json,sys from pathlib import Path def load(checkpoint,device='mlu:0'): import torch,torch_mlu device=torch.device(device) if device.type!='mlu':raise ValueError('This entry reproduces the qualified BF16 MLU path') torch.mlu.set_device(device.index or 0) checkpoint=Path(checkpoint).resolve();source=checkpoint/'native_runtime' for name in ['contract','warm_model','language_lora','loading_diagnostics']: if name in sys.modules: current=getattr(sys.modules[name],'__file__',None) if not current or hashlib.sha256(Path(current).read_bytes()).digest()!=hashlib.sha256((source/(name+'.py')).read_bytes()).digest(): raise ValueError('Use an isolated native inference worker; a different source module is already loaded') sys.path.insert(0,str(source)) from warm_model import load_native_reference provenance=json.loads((checkpoint/'TRAINING_PROVENANCE.json').read_text()) engine,info=load_native_reference({'staged_parent':str(checkpoint),'parent_revision':provenance['parent_revision']},device,final=True) return engine def image_from_raw(raw): """Same official outer cap/decode as training; pass returned PIL image to decide.""" import io from PIL import Image source=Path(__file__).resolve().parent/'native_runtime';sys.path.insert(0,str(source)) import official_images data=official_images.capped(raw,max_pixels=1638400) with Image.open(io.BytesIO(data))as image:return image.convert('RGB') if __name__=='__main__':print('{"status":"SOURCE_ONLY_NO_MODEL_LOAD","compute":"native MLU BF16","head_storage":"FP32"}')