# Verify the per-layer-type forward patch in quantize_autoround.py leaves the model's logits unchanged. import runpy, sys, torch sys.argv = ["x", "/model", "/quant/calib/calib_256x2048.pt", "/tmp/unused"] src = open("/quant/quantize_autoround.py").read().split("t0 = time.time()")[0] # setup + patch, no quantization g = {"__name__": "check"} from transformers import AutoModelForCausalLM ref = AutoModelForCausalLM.from_pretrained("/model", dtype=torch.bfloat16, trust_remote_code=True).to("xpu").eval() x = torch.load("/quant/calib/calib_256x2048.pt")[3][:, :1000].to("xpu") with torch.no_grad(): a = ref(x).logits.float() del ref exec(src, g) m = g["model"].to("xpu").eval() with torch.no_grad(): b = m(x).logits.float() print("max |dlogit|", (a - b).abs().max().item(), "top1 agree", (a.argmax(-1) == b.argmax(-1)).float().mean().item())