DEV Community

TECHDEV
TECHDEV

Posted on Originally published at github.com

Qwen4 shipped 35B parameters this week. I built a one-command check that your weights are byte-for-byte what the publisher published

This week two open-weight releases landed at the same time: Qwen4-35B-A3B, and DeepSeek-V4.1-Flash at 748B parameters, a model its authors say runs on a single RTX 4090. The downloads are measured in hundreds of gigabytes, and the operators running them locally now carry the whole verification burden themselves.

Here is the question nobody has a one-line answer for: is the weights directory you just downloaded byte-for-byte what the publisher published?

The download tool verifies while it downloads, but only when you download through that tool. A manual download, a cached copy, a mirror, or a copy from another machine bypasses it completely. And once the files sit on your disk, nothing checks them again before the first run.

The Hub already publishes the answer

Hugging Face Hub publishes a hash for every large file in a repo: the LFS oid in the tree API. What I verified live before writing a single line of the verifier is that the oid is the sha256 of the file content. I pulled the tree for hf-internal-testing/tiny-random-gpt2, took the oid for model.safetensors (8111d5afb0715dbf5a31396d31432cb56370ba23f6650a035ea0fc8a20b4e500), downloaded the real file from the Hub CDN, and sha256sum returned exactly that value.

So the check is not a guess and not a new trust root. It is a comparison against the hash the registry itself published, at a pinned revision, with no token and no key.

What I built

hfverify is a zero-dependency TypeScript CLI. One audit, one verdict, one exit code your CI can gate on.

# Scaffold hfverify.json + hfverify.baseline.json
hfverify init

# Audit a weights directory against the Hub tree at a revision
hfverify audit hf-internal-testing/tiny-random-gpt2 --dir ./weights

# One-line CI gate: reads hfverify.json, prints one line, exits 0/1/2
hfverify check

# Regression check against a saved baseline
hfverify diff --baseline hfverify.baseline.json

# Background: what the LFS oid is, with source and check date
hfverify explain oid
Enter fullscreen mode Exit fullscreen mode

Every command accepts --json. Verdicts and exit codes:

Verdict Meaning Exit
CLEAN every verifiable file matches, nothing missing or extra 0
TAMPERED at least one file mismatches, or an extra file is present 1
INCOMPLETE at least one published file is missing 1
UNKNOWN nothing could be verified (gated model, API failure, bad input) 2

One rule matters most: files the Hub does not store in LFS (config.json, tokenizer files, small text files) have no published hash, so hfverify reports them UNVERIFIED, never MATCH. A repo with no LFS files at all audits as UNKNOWN. The tool never upgrades a verdict on the back of files it cannot verify.

What it found on real runs

Measured December 6, 2026, from a real transcript against the live Hub:

$ hfverify audit hf-internal-testing/tiny-random-gpt2 --dir ./weights
hfverify 0.1.0 - audit hf-internal-testing/tiny-random-gpt2@main
revision sha: 71034c5d8bde858ff824298bdedc65515b97d2b9
directory: ./weights
metadata pulled: 2026-12-06T07:13:38.348Z

files:
  UNVERIFIED .gitattributes  expected -  actual -
  UNVERIFIED config.json  expected -  actual -
  UNVERIFIED merges.txt  expected -  actual -
  MATCH      model.safetensors  expected 8111d5afb071  actual 8111d5afb071
  MATCH      pytorch_model.bin  expected 4fab47c12996  actual 4fab47c12996
  UNVERIFIED special_tokens_map.json  expected -  actual -
  MATCH      tf_model.h5  expected 9ccb1b43b02b  actual 9ccb1b43b02b
  UNVERIFIED tokenizer_config.json  expected -  actual -
  UNVERIFIED tokenizer.json  expected -  actual -
  UNVERIFIED vocab.json  expected -  actual -

summary: 3 verified (3 match, 0 mismatch), 0 missing, 0 extra, 7 unverified
Verdict: CLEAN
exit: 0
Enter fullscreen mode Exit fullscreen mode

Then I flipped one byte of model.safetensors at offset 100 and ran the same audit again. The hash moved from 8111d5afb071 to 27fe8c8d26e7, the summary went to 2 match and 1 mismatch, and the verdict went to TAMPERED, exit 1. hfverify check then printed GATE FAIL, exit 1. That is the whole point: a single changed byte, anywhere in a 454 KB file, is a failed gate, not a warning.

The Qwen3-0.6B fixture in the repo is metadata-only, recorded from the live tree API on the same day: model.safetensors oid f47f7117...96874b, size 1,503,300,328 bytes. The 1.5 GB file was not downloaded, and the fixture says so in its provenance sidecar. The tool audits metadata honestly or not at all; it never pretends it verified bytes it never read.

hfverify demo

The demo runs the real transcript: init, a CLEAN audit, the one-byte flip, a TAMPERED audit, a failing CI gate, and explain oid.

Where rivals beat us

Honesty first. Four places where something else is better:

  • huggingface_hub verifies during download, which is the right place if you download through it. hfverify exists for the cases it cannot see: manual downloads, caches, mirrors, copies.
  • Sigstore and model-signing are strictly stronger when the publisher has signed: they authenticate the publisher's identity, while hfverify only compares hashes with the Hub.
  • git lfs fsck is enough if you only need to know whether local LFS objects are intact against their pointers. It does not compare against the revision the Hub currently publishes, and it gives no verdict or CI exit code.
  • safetensors format checks are about format safety, not integrity against the publisher.

What hfverify adds is the one-line answer to one question, asked at install time, before the first run: do these bytes match what the registry published?

Honest limits

  • hfverify proves your local bytes match the bytes the Hub currently publishes at that revision. It does not prove the publisher is trustworthy: if the Hub itself is compromised, the published hash changes with the bytes and the audit still reports MATCH.
  • Files the Hub does not store in LFS have no published hash, so they report UNVERIFIED, never MATCH. A repo with no LFS files audits as UNKNOWN.
  • A gated model (401/403) cannot be audited: hfverify sends no token, by design. A Hub rate limit (429) also reports UNKNOWN rather than guessing.
  • hfverify never downloads weights itself; it only reads a directory you already downloaded.
  • The audit is a snapshot: if main moves after your audit, a later audit can differ. Pin a revision with --revision and use diff --baseline to catch drift.
  • Install is from source only for now. The npm package name hfverify is currently unclaimed (verified 404 on 2026-12-06) and is not published yet; publishing is pending an owner token decision.

Try it

git clone https://github.com/techdevfun/hfverify.git
cd hfverify
npm install
npm run build
node dist/src/cli.js audit hf-internal-testing/tiny-random-gpt2 --dir ./weights
Enter fullscreen mode Exit fullscreen mode

Source, tests (37/37), and the recorded fixtures with provenance: https://github.com/techdevfun/hfverify

You already trust the download enough to run it. One command tells you whether the bytes you run are the bytes that were published.

Top comments (0)