#!/usr/bin/env python3 """One-off: re-create the OLD plain-float32 "NNU1" export format for a same-moment, apples-to-apples bench comparison against the new int16 "NNU2" quantized format. Not the real exporter (export_nnue_weights.py is the real one now) -- throwaway, delete after use. """ import struct import sys import torch from nnue_feature_spec import DIMENSIONS from nnue_model import L1, L2, L3 ckpt = torch.load(sys.argv[1], map_location="cpu", weights_only=True) sd = ckpt["model"] names = ["ft.weight", "ft_bias", "fc1.weight", "fc1.bias", "fc2.weight", "fc2.bias", "fc3.weight", "fc3.bias"] with open(sys.argv[2], "wb") as f: f.write(b"NNU1") f.write(struct.pack("<4I", DIMENSIONS, L1, L2, L3)) for name in names: arr = sd[name].detach().contiguous().to(torch.float32).numpy() f.write(arr.tobytes()) print(f"wrote {sys.argv[2]}")