Skip to main content

A sub-100ms, zero-dependency CLI tool to inspect ML model checkpoints and dynamically calculate VRAM requirements.

Project description

ModelInfo CLI

Python 3.10+ Dependencies License

ModelInfo is a terminal-native utility that inspects machine learning model checkpoints (.safetensors, .gguf, .pt) and calculates hardware requirements completely offline.

It reads binary headers directly using the Python standard library. By bypassing full tensor payload loading and strictly excluding heavy ecosystems like PyTorch or HuggingFace, the tool executes in under 100 milliseconds.

Features

  • Zero-Dependency Parsing: Reads the 8-byte JSON prefix of .safetensors files and the binary key-value metadata of .gguf directly via struct and json.
  • Sharded Model Support: Transparently parses model.safetensors.index.json to detect multi-file checkpoint distributions, gracefully guarding against partial downloads without crashing.
  • Dynamic VRAM Estimation: Extracts underlying model architecture (layers, heads, dimensions) to calculate exact VRAM limits, including dynamic KV cache footprints based on user-specified context lengths.
  • Precise Block Quantization: Factors in exact byte-scaling coefficients for GGUF formats (e.g., Q8, Q6, Q4) rather than naive averages, eliminating VRAM under-reporting.
  • Secure Pickling: Inspects legacy .pt files without executing arbitrary code by using a highly restricted pickle.Unpickler.
  • Terminal UI: Groups repetitive structural layers and color-codes VRAM heatmaps using rich.

Installation

Install directly from PyPI:

pip install modelinfo-cli

Development

To install from source and run the test suite:

git clone https://github.com/pipe1os/modelinfo-cli.git
cd modelinfo-cli
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Testing

The testing suite enforces cross-platform structural integrity and guards the zero-dependency latency constraint. Tests are isolated against custom binary mocks in tests/fixtures/.

Run the test suite using pytest:

pytest tests/ -v

Usage

Inspect a model checkpoint:

modelinfo mistral-7b.safetensors

Calculate the memory footprint with a specific KV cache context window:

modelinfo mistral-7b.safetensors --context 8192

Example Output

Format:         SafeTensors
Architecture:   Mistral (32 transformer layers)
Tensors:        291
Parameters:     7.2B
Dtype:          bf16
Disk size:      13.49 GB
VRAM (est):     ~15.2 GB (bf16, KV cache for 8192 tokens)

Top Tensors by Size:
  model.embed_tokens.weight                     [32000 x 4096]   bf16   131.1M params
  32x model.layers.[N].self_attn.q_proj.weight  [4096 x 4096]    bf16    16.8M params

Architecture

The system operates across three modules:

  1. Presentation (cli.py, ui.py): Parses arguments and formats tables via rich.
  2. Parsing Engine (parsers/): Specialized binary readers (safetensors.py, gguf.py, pytorch.py) strictly confined to standard library operations.
  3. Math Engine (calculator.py): Determines total parameter counts, maps data types to byte coefficients, and calculates dynamic memory allocations based on tensor shape heuristics.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

modelinfo_cli-1.0.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

modelinfo_cli-1.0.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modelinfo_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for modelinfo_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 48e34a22b87c2fe45653df433533a1ba83936eb255656184bd72916d7be585a5
MD5 4a8c753865f953f08e74ab666a1ac521
BLAKE2b-256 c0036e2789ff302ad67f8e4f6ecf5f248aa9c7d70cc2edfe788ac314f70269ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for modelinfo_cli-1.0.0.tar.gz:

Publisher: publish.yml on pipe1os/modelinfo-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: modelinfo_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for modelinfo_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 608c87ecb26cdd09ecad2a042b1e8c07dc0050cd0a7e86bcb8bf29f920dd558b
MD5 13e20f050e8eb009172e0db10f6f0668
BLAKE2b-256 7dea6a4294c51821df02fe86a85d0e97fe34096084ba4d4f955c8fd0caf13484

See more details on using hashes here.

Provenance

The following attestation bundles were made for modelinfo_cli-1.0.0-py3-none-any.whl:

Publisher: publish.yml on pipe1os/modelinfo-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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