Skip to main content

Check what a quantized tensor actually means: GRIT descriptors carry the numeric contract, and `grit scan` audits safetensors/GGUF files you already have

Project description

GRIT — Grouped Reduced-precision Interchange Type

A Q4_K blob and an MXFP4 blob are both "4-bit weights", but their decodes differ, their layouts differ, and nothing at the file boundary says so. GRIT makes that contract explicit: a 64-byte descriptor that can be checked against the bytes in O(1), fingerprinted, and diffed field-by-field when two artifacts disagree.

Start here: audit files you already have

grit scan requires zero adoption by any framework. Point it at safetensors or GGUF files, or at a directory tree:

grit-scan [--deep] [--json] PATH...

It recovers descriptors from a __grit__ safetensors header key or grit.desc.<tensor> GGUF KV entries (inferring them from well-known ggml block structs otherwise) and reports descriptor-vs-bytes violations, cross-file gid disagreements with field-by-field diffs, grade-drift clusters, and NOTE_ASSUMED escape-hatch exposure.

Exit codes: 0 clean, 1 structural violation, 2 disagreement, 3 warnings only, 4 unparseable.

The explicit contract fields

A GRIT array is a quadruple (Grade, Placement, Planes, Shape):

  • Grade — the complete numeric contract: element format, group sizes, scale formats, zero-point convention, sparsity, rounding and saturation promises. It has one canonical string form and a derived 64-bit id (gid).
  • Placement — the physical layout, carried as a 64-bit value, never a type parameter. New silicon means a new constant, not a new type.
  • Planes — up to four byte buffers: data, scale0, scale1, aux.
  • Shape — rank and extents, carried in the view.

The core guarantee: equal gid and equal plane bytes implies bit-identical decode() on every conformant implementation — and the descriptor check never has undefined behaviour, even on adversarial 64-byte input. gid certifies decode agreement and nothing else: not calibration quality, not provenance, not trustworthiness.

This package

Pure Python, standard library only; numpy is an optional extra used by grit.to_array() and is never imported at module scope. It is one of five independent implementations (C, C++, Rust, Python, TypeScript) that pass a shared 64-entry conformance vector suite generated by the executable reference, and that agree bit-for-bit on cross-language gid values.

The normative specification, the reference implementation, and the vector suite live in the project repository.

Licensed under Apache-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grit_datatype-1.0.0.tar.gz (52.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grit_datatype-1.0.0-py3-none-any.whl (44.6 kB view details)

Uploaded Python 3

File details

Details for the file grit_datatype-1.0.0.tar.gz.

File metadata

  • Download URL: grit_datatype-1.0.0.tar.gz
  • Upload date:
  • Size: 52.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for grit_datatype-1.0.0.tar.gz
Algorithm Hash digest
SHA256 adfac4dedf1bddf93f91bed47c163a5abf598e2ec32875aac86d803725801883
MD5 e2230f9b941561396a34bb00d5985d4e
BLAKE2b-256 cca6399ea09dc9427ec377783627aa1a100544aee3ef35b1789094f33c7ecfd8

See more details on using hashes here.

File details

Details for the file grit_datatype-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: grit_datatype-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 44.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for grit_datatype-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa2202a793239e558181fa397f782b1ea9eda10b7d542299a1746a78b17d4df5
MD5 eaaa5c651792791e839cba6340bb20f3
BLAKE2b-256 327b9ddfb4d34e6c5c9d60f0ba50e2176964985f64aae73e59948ef06b3eef98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page