Renamed from vllm-embedding: nothing here is about embeddings, and the name had come from the parent working directory. edge-infer says what it does. The GitHub repository is renamed to match; nothing had been pushed yet. The audit found the packaging was incomplete in two ways. Scripts: 56 of them produced results that are published in this repo but were not included, so the numbers could be read and not checked. Added under benchmarks/edge_harness/experiments/ (one-off drivers: the AI Hub on-device runs, the 4-bit GEMM microbenchmark, fidelity and parity checks, checkpoint build and round-trip, activation capture, and the load generator used to prove the contention guard actually refuses) and benchmarks/edge_harness/runs/ (the 24 shell drivers behind published grids). Both directories carry a README saying plainly that they are a record of what was run rather than a supported interface -- most hardcode absolute paths from the machine they ran on. The supported entry points remain the tools one level up. One broken relative link fixed (comparison.md is under docs/engines/, not docs/analysis/). All other links and every script reference in the docs now resolve inside the repo. Secret scan: the token in ~/.qai_hub/client.ini is absent from the worktree and from all 61 commits. Worth noting that an earlier version of my own check reported a false positive, because `grep -rl ... | head` takes its exit status from head, which always succeeds -- the same class of mistake as the measurement errors this project keeps recording. The AI Hub scripts authenticate by reading that file at runtime and contain no credential. README reframed for the new name and the wider scope: the repository is the engine changes, the harness, the raw results, the baselines and the analyses, not just a patch set. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L1ax5wYLA6XbqEL1i8L9gZ
59 lines
2.1 KiB
Python
59 lines
2.1 KiB
Python
"""Expand a `cpu_int4` checkpoint back to a plain bf16 one.
|
|
|
|
Used as a control: if the engine is applying the quantized weights faithfully,
|
|
the expanded checkpoint must score exactly the same perplexity as the
|
|
quantized one, and any difference is the runtime's, not the quantizer's.
|
|
"""
|
|
import argparse, json, shutil
|
|
from pathlib import Path
|
|
|
|
import torch
|
|
from safetensors.torch import load_file, save_file
|
|
|
|
from vllm_omni.model_executor.layers.quantization.cpu_int4 import unpack_nibbles
|
|
|
|
|
|
def main():
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("--src", required=True)
|
|
ap.add_argument("--dst", required=True)
|
|
a = ap.parse_args()
|
|
src, dst = Path(a.src), Path(a.dst)
|
|
dst.mkdir(parents=True, exist_ok=True)
|
|
|
|
cfg = json.loads((src / "config.json").read_text())
|
|
group = cfg["quantization_config"]["group_size"]
|
|
cfg.pop("quantization_config", None)
|
|
|
|
state = {}
|
|
for shard in sorted(src.glob("*.safetensors")):
|
|
state.update(load_file(str(shard)))
|
|
|
|
out = {}
|
|
for name, t in state.items():
|
|
if name.endswith(".weight_packed"):
|
|
base = name[: -len(".weight_packed")]
|
|
codes = unpack_nibbles(t).float()
|
|
n, k = codes.shape
|
|
s = state[base + ".weight_scale"].float()
|
|
z = state[base + ".weight_zero"].float()
|
|
deq = ((codes.reshape(n, k // group, group) - 8.0) * s.unsqueeze(-1)
|
|
+ z.unsqueeze(-1)).reshape(n, k)
|
|
out[base + ".weight"] = deq.to(torch.bfloat16)
|
|
elif name.endswith((".weight_scale", ".weight_zero")):
|
|
continue
|
|
else:
|
|
out[name] = t
|
|
|
|
save_file(out, str(dst / "model.safetensors"), metadata={"format": "pt"})
|
|
(dst / "config.json").write_text(json.dumps(cfg, indent=2))
|
|
for f in ("tokenizer.json", "tokenizer_config.json", "special_tokens_map.json",
|
|
"vocab.json", "merges.txt", "generation_config.json", "chat_template.jinja"):
|
|
if (src / f).exists():
|
|
shutil.copy(src / f, dst / f)
|
|
print(json.dumps({"tensors": len(out), "group": group, "dst": str(dst)}))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|