Download serving/donor_diff.py from drowzeys/keys-GLM-5.3-EXL3: direct link, hf CLI and curl.
- Browser
- Download file 834 Bytes
-
https://huggingface.co/drowzeys/keys-GLM-5.3-EXL3/resolve/main/serving/donor_diff.py
- Command line
-
hf download hf://drowzeys/keys-GLM-5.3-EXL3/serving/donor_diff.py
-
curl -L -o donor_diff.py https://huggingface.co/drowzeys/keys-GLM-5.3-EXL3/resolve/main/serving/donor_diff.py
834 Bytes
| import json, torch, os, sys | |
| from safetensors import safe_open | |
| M="/models/GLM-5.3-EXL3-3bpw"; D="/models/glm53-ablit-donor-derisked" | |
| idx=json.load(open(f"{M}/model.safetensors.index.json"))["weight_map"] | |
| man=json.load(open(f"{D}/MANIFEST.json"))["layers"] | |
| print("layer rel_l2 cos donor_bits") | |
| for L in range(79): | |
| key=f"model.layers.{L}.self_attn.o_proj.weight" | |
| if key not in idx: print(L,"no-stock"); continue | |
| with safe_open(f"{M}/{idx[key]}","pt") as f: w=f.get_tensor(key).float() | |
| info=man[str(L)]; raw=open(f"{D}/L{L}.bin","rb").read() | |
| d=torch.frombuffer(bytearray(raw),dtype=torch.bfloat16).view(info["shape"]).float() | |
| rel=((d-w).norm()/w.norm()).item(); cos=torch.nn.functional.cosine_similarity(d.flatten(),w.flatten(),dim=0).item() | |
| print(f"{L:2d} {rel:.4f} {cos:.5f} {info.get('bits')}", flush=True) | |