"""CPU functional implementation tests; run on authorized remote server only.""" import json from pathlib import Path import struct import tempfile import unittest import numpy as np from functional.model import StreamingLM,causal_conv,silu,attention,norm from functional.run import probability_metrics,error_rows class FunctionalTests(unittest.TestCase): def test_streamed_projection_embedding_and_output_head(self): rng=np.random.default_rng(7) arrays={'model.language_model.embed_tokens.weight':rng.normal(size=(19,4)).astype(np.float32), 'model.language_model.test.weight':rng.normal(size=(9,4)).astype(np.float32)} header={};offset=0;body=b'' for name,arr in arrays.items(): raw=arr.tobytes();header[name]={'shape':list(arr.shape),'dtype':'F32','data_offsets':[offset,offset+len(raw)]} body+=raw;offset+=len(raw) encoded=json.dumps(header).encode() with tempfile.TemporaryDirectory() as d: Path(d,'model.safetensors').write_bytes(struct.pack('