One bit, two files, same reported digest
The most useful case in Tensor Header Desk is a pair of files that the inspector cannot distinguish. Both files are 98,720 bytes: an 8-byte little-endian length prefix, a 384-byte JSON header, and 98,328 bytes of payload. The header declares two tensors. bias is F64 with shape [3] and range [0, 24). weights is F64 with shape [4096, 3] and range [24, 98328). Ranges are counted from the start of payload, with the end position excluded. Together the tensors hold 12,291 scalars.
For the altered copy I changed exactly one bit. The last payload byte, index 98,719, received XOR 1. The prefix and header were not touched. Two independent checks agree on the header. A direct byte comparison shows that the first 392 bytes of the two files are identical. The tool reports the same header SHA-256 for both, 72b2638c12271d621908dec34e8b5389c0eb77ce70c2c1d66d692bd69300f48e, while the complete file SHA-256 values differ.
That shared digest does not mean the files are equal. The tool hashes only the prefix plus the header, and the payload sits outside that scope. In this example the two checks support each other: the byte comparison identifies the identical stretch, and the digest records its hash. What this shows about payload is simple. A same-length change leaves declared ranges, element counts, and file size intact, and those are the only payload-facing facts the checker reads.
The tool is published as a Hugging Face Space, with a standalone app running the same code.
What the checker reads
The checker is a structural lint for the moment just before a loader allocates memory. Safetensors stores tensor names, shapes, dtypes, and byte ranges in a JSON header. The first eight bytes carry the header length as a little-endian unsigned integer, and the payload follows the header. The inspector reads those eight bytes and the supported-size header, then uses the complete file size for coverage. Tensor values are never read.
Against the declared ranges it checks for a truncated header, reversed ranges, offsets beyond the end of payload, overlapping tensors, holes between ranges, misplaced empty ranges, and trailing bytes after the last declared tensor. A scalar has shape [] and one element. A dimension whose value is 0 leaves no elements to store.
That same design explains what the checker cannot see. Ranges record endpoints and computed widths. They do not include the bytes themselves, so two payloads can occupy identical ranges while their contents differ. Interval coverage is blind to a same-length content change.
The page renders the verdict, findings, tensor table, and a digest explicitly labelled prefix plus header.
Tensor Header Desk in a local browser, original screenshot from the accepted November 5 package. The capture is the local tool UI; it says nothing about hosted behavior or weight correctness.
Capability boundaries
Some outcomes describe what the tool can inspect rather than what is wrong with the file. A header above 1 MiB, more than 10,000 tensors, JSON nesting above 32, or an unknown dtype returns outside-profile. The dtype table has 22 entries, including 4-bit and 6-bit types, but those entries are layout bit widths. The tool never decodes F4 or F6 into numbers; it only knows whether the declared bit count divides by eight.
I froze a corpus of 320 synthetic and serialization fixtures and compared each against the pinned official reader, safetensors 0.8.0. If comparison is narrowed to the binary accept/reject outcome, the two readers agree on 317 of 320: both accept 283, and both reject 34. The three remaining cases differ for specific reasons. The official reader accepts a duplicate tensor name by overwriting the repeated name, while my tool rejects any decoded duplicate key at any depth by policy. The official reader accepts a valid header just over my 1 MiB cap, and it accepts 10,001 empty tensors past my 10,000 descriptor cap; my tool marks those two outside-profile. Agreement here concerns the pass/reject label only. It does not say the readers produce identical parsed fields or identical interpretations of every descriptor.
The original model was serialized, not retrained
The example uses my earlier CPU Character Router, the model from an out-of-domain abstention study. Its weights and bias already existed. I serialized them exactly as F64 and checked all 12,291 values against the original JSON model. This is serialization of an accepted existing model, not a new fit or a new model identity.
The router's failed out-of-domain abstention result stays as it was. The tool does not run the model, and I did not run the bit-flipped file through inference to claim a measured change. The counterexample is narrow. It shows what a header-only digest and a bounded range check can say about payload contents.
Whole-file equality and private report data
A whole-file digest answers a different question. Obtained from a trusted independent channel, it can confirm that complete bytes match another copy, which is useful after a download or duplication. Byte equality does not extend to weight correctness, source safety, license validity, or loader robustness. Each of those requires separate evidence.
Reports carry their own exposure. The downloaded report includes tensor names, metadata, and the original UTF-8 header, and those may contain private strings. Clear removes the selection and the visible report, but it is not secure memory erasure. A selected local file stays on the File/Blob path and is never uploaded. The six included examples take a second path: the loader fetches complete same-origin JSON/base64 carriers under fixtures-web/, reconstructs the exact bytes, and hands them to the same bounded inspector. Those example requests read full carrier bytes over the network.
Reproduce the counterexample
To check this yourself, download the two JSON carriers from the fixed commit c1b5e505666747c7bad5d7015b87f9ccecdf2173. Opening the hosted app does not create these local files; you need the actual carriers from the commit.
Place both files in a local directory named fixtures-web/, then run the script below from the directory that contains that folder. The script is a read-only stdlib reproduction for this one counterexample. The carrier hashes are consistency pins against the saved package, not an independent authenticity check.
python3 - <<'PY' """ Read-only check of the fixed payload-bitflip counterexample. Put router-good.json and router-payload-bitflip.json under fixtures-web/, then run from the directory containing that folder. """ import json, base64, hashlib, struct from pathlib import Path PINS = { "router-good": (98720, "eaf600b428ca7ce94e2fa420cf8e313fc702d7962a47ec819979b32174e8bc8d"), "router-payload-bitflip": (98720, "d54a8ef765aba2914096aa5b71618b372e0687bacae6063b35fca16c57acf1a1"), } HEADER_SHA = "72b2638c12271d621908dec34e8b5389c0eb77ce70c2c1d66d692bd69300f48e" def load(name): length, pin_sha = PINS[name] entry = json.loads(Path("fixtures-web", name + ".json").read_text(encoding="utf-8"), parse_int=str) assert set(entry) == {"schema", "source_file", "encoding", "byte_length", "sha256", "data_base64"} assert entry["schema"] == "tensor-header-example-bytes/v1" assert entry["encoding"] == "base64" assert entry["source_file"] == "fixtures/%s.safetensors" % name assert int(entry["byte_length"]) == length assert entry["sha256"] == pin_sha raw = base64.b64decode(entry["data_base64"], validate=True) assert len(raw) == length assert hashlib.sha256(raw).hexdigest() == pin_sha n = struct.unpack("<Q", raw[:8])[0] assert n == 384 and 8 + n < len(raw) return raw[:8 + n], raw a_head, a = load("router-good") b_head, b = load("router-payload-bitflip") assert a_head == b_head assert hashlib.sha256(a_head).hexdigest() == HEADER_SHA assert hashlib.sha256(a).hexdigest() != hashlib.sha256(b).hexdigest() diff = [i for i, (x, y) in enumerate(zip(a, b)) if x != y] assert diff == [98719] assert a[98719] ^ b[98719] == 1 print("prefix+header identical:", hashlib.sha256(a_head).hexdigest()) print("whole SHA-256 good:", hashlib.sha256(a).hexdigest()) print("whole SHA-256 flip:", hashlib.sha256(b).hexdigest()) print("single differing byte:", diff[0], "one bit:", 1) PY The script decodes each carrier, checks its declared byte length and SHA-256, reads the eight-byte prefix, compares the prefix-plus-header bytes directly, and asserts the only differing byte is 98,719 with a single-bit XOR.
Source and license
The original tool, synthetic fixtures, model serialization, and reports are Apache-2.0, written by me, Renchao Wu. The Safetensors format and reference implementation belong to their original authors.

