Guides · published
How to check a GGUF file’s SHA-256 on Mac
Compare a downloaded model file with the publisher’s exact SHA-256, handle a mismatch, and keep the revision and filename together. Includes a tested macOS checksum workflow.
A familiar filename is not enough to identify a downloaded model. Before starting a large GGUF, compare its SHA-256 with the publisher’s checksum for the same filename and repository revision. This is a file-integrity check. It does not establish that the model is safe, correctly licensed, compatible with your runtime, or small enough for your Mac.
1. Keep the file and its reference together
Record the repository URL, immutable revision if available, exact filename, file size and published SHA-256. A checksum for a different quantization, another revision, or one shard of a split download cannot verify your file. Check every required shard separately.
Use the publisher’s file record or checksum manifest. Do not treat a checksum you calculated from your own download as independent confirmation that you downloaded the intended artifact. If the publisher provides no trustworthy reference digest, save your local digest for reproducibility and state that external verification is still missing.
2. Calculate the local digest
Replace the example path with your file’s absolute path. Keep the quotes, including for names that contain spaces.
model_file='/absolute/path/model.gguf'
shasum -a 256 "$model_file"
stat -f '%z' "$model_file"
The first command prints the SHA-256 and filename. The second prints the file’s size in bytes on macOS. Compare the size with the publisher’s byte count when one is provided; a matching size alone does not establish matching contents. Hashing reads the file, so a large GGUF can take time.
3. Check against the publisher’s digest
Replace the placeholder with the complete 64-character hexadecimal SHA-256 from the exact file
record. Keep the same model_file value from the previous step.
expected_sha='PASTE_THE_PUBLISHERS_64_CHARACTER_SHA256_HERE'
check_model_sha256() {
if [ "${#expected_sha}" -ne 64 ]; then
printf '%s\n' 'Expected exactly 64 hexadecimal characters; check skipped.' >&2
return 2
fi
case "$expected_sha" in
*[!0-9a-fA-F]*)
printf '%s\n' 'Expected only hexadecimal characters; check skipped.' >&2
return 2
;;
esac
printf '%s %s\n' "$expected_sha" "$model_file" | shasum -a 256 -c -
}
check_model_sha256
The function checks the digest’s length and characters before invoking shasum. A SHA-1 digest
has the wrong length for this procedure; do not substitute it for the publisher’s SHA-256.
In our fixture test, an unguarded shasum -a 256 -c check accepted a matching SHA-1 entry,
so the input check matters even when -a 256 is present.
The space between the digest and filename matters: the format above supplies two spaces.
For a matching file, shasum prints the filename followed by OK. Count the check as successful
only when that line names your intended file. A digest mismatch produces FAILED and a nonzero
exit status. The example assumes a filename without newlines or backslashes; those characters
require escaping in a checksum list, as described in the linked shasum documentation.
If the check fails, stop before using that file. First recheck the filename, revision, quantization, shard and copied digest. If those all match the publisher’s record, obtain a fresh copy from that source and verify it again. Do not silently change the expected digest to match a failed download.
4. Carry the identity into the next step
Keep the checked digest beside the runtime version and command you actually use. The Mac startup guide covers the next stage; the llama-bench guide explains the additional information needed for a reproducible measurement.
For this article we tested the checksum-list command with a disposable text fixture whose filename contained a space, then changed its bytes and confirmed rejection. We also checked the macOS size command. The raw command record includes the original fixture text and digest. No new model was downloaded or loaded in this test. The commands above read your file; they do not modify or remove it.
A follow-up test record covers the exact
validation function in both zsh and bash: lowercase and uppercase SHA-256 matched, changed bytes
failed, and five malformed-input cases returned before shasum was called. It includes the
unguarded SHA-1 baseline and the test setup. These remain file-check fixtures, not model tests.