Sync the repo with the working directory: full NOTES.md (rounds 4-5, LFM3-VL), VL tests and test images, quality eval, AutoRound W4A16 quantization scripts and calibration recipe, the variant.sh MODEL/DOCKER_ENV options, and the remaining benchmark results. Large regenerable artifacts (INT4 checkpoint, ref_vl.pt, raw logprob dumps) stay out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
851 B
Python
17 lines
851 B
Python
# 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())
|