#!/usr/bin/env python3 import math import os import struct import sys import tempfile import unittest import numpy as np sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from glm53_quantize import ( QTYPE_BF16, QTYPE_F32, QTYPE_I8, QTYPE_IQ2_XXS, QTYPE_Q2_K, QTYPE_Q4_K, QTYPE_Q8_0, Imatrix, Quantizer, TensorPlan, conversion_signature, iter_native_tensor_bytes, native_fp8_plan, regular_qtype, transform_regular, ) import glm53_full_quantize as full_glm class FakeSourceDB: def __init__(self, codes, scales): self.codes = codes self.scales = scales def info(self, name): if name.endswith("_scale_inv"): return {"dtype": "F32", "shape": list(self.scales.shape)} return {"dtype": "F8_E4M3", "shape": list(self.codes.shape)} def read(self, name): if name.endswith("_scale_inv"): return self.scales.astype("