Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Ggml org Llama cpp GGUF Hash

From Leeroopedia
Revision as of 12:39, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Ggml_org_Llama_cpp_GGUF_Hash.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Hashing, GGUF
Last Updated 2026-02-15 00:00 GMT

Overview

CLI tool that computes cryptographic and non-cryptographic hashes of GGUF model files at both per-tensor and whole-model granularity for integrity verification.

Description

Parses command-line options for hash type selection (xxh64, sha1, sha256, uuid), opens GGUF files via the gguf API, iterates over tensor data, and feeds each tensor's raw bytes through the selected hash algorithm(s). Supports manifest generation (outputting hash lines per tensor and for the full model) and manifest verification (parsing a manifest file and comparing computed hashes against stored values). Uses a UUIDv5 namespace derived from llama.cpp's Wikipedia URL for generating deterministic model IDs from tensor content.

Usage

Use this tool when you need to verify the integrity of GGUF model files, detect tensor-level corruption or modification, generate hash manifests for model distribution, or compare model files across different sources.

Code Reference

Source Location

Signature

// Enums
enum hash_exit_code_t { HASH_EXIT_SUCCESS = 0, HASH_EXIT_FAILURE = 1, HASH_EXIT_MISMATCH = 2, ... };
enum hash_manifest_result_t { HASH_MANIFEST_NOT_FOUND, HASH_MANIFEST_MISMATCH, HASH_MANIFEST_OK };

// Structs
struct hash_params {
    std::string input;
    bool xxh64 = false;
    bool sha1 = false;
    bool sha256 = false;
    bool uuid = false;
    bool no_layer = false;
    bool manifest_is_usable = false;
    std::string manifest_file;
};

struct manifest_check_params {
    bool xxh64 = false;
    bool sha1 = false;
    bool sha256 = false;
    bool uuid = false;
};

int main(int argc, char ** argv);

Import

#include "ggml.h"
#include "gguf.h"
#include "xxhash/xxhash.h"
#include "sha1/sha1.h"
#include "sha256/sha256.h"

I/O Contract

Inputs

Name Type Required Description
input std::string Yes Path to the GGUF model file to hash
xxh64 bool No Enable xxHash64 hashing algorithm
sha1 bool No Enable SHA-1 hashing algorithm
sha256 bool No Enable SHA-256 hashing algorithm
uuid bool No Enable UUIDv5 generation from tensor content
no_layer bool No Skip per-tensor (layer) hashing, compute only whole-model hash
manifest_file std::string No Path to manifest file for verification mode

Outputs

Name Type Description
exit_code hash_exit_code_t Exit status indicating success, failure, or mismatch
hash_output stdout Per-tensor and whole-model hash strings printed to standard output
manifest stdout Hash manifest lines in "hash filename" format when generating

Usage Examples

# Generate SHA-256 hashes for all tensors in a model
./gguf-hash --sha256 model.gguf

# Generate a manifest with xxh64 hashes
./gguf-hash --xxh64 model.gguf > model.manifest

# Verify a model against an existing manifest
./gguf-hash --sha256 --manifest model.manifest model.gguf

# Generate a UUIDv5 identifier for the model
./gguf-hash --uuid model.gguf

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment