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. Seamlessly reads adjacent config.json for robust fallback logic.
  • 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. Actively warns users if requested context exceeds the model's native limit.
  • 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.1.0.tar.gz (14.4 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.1.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modelinfo_cli-1.1.0.tar.gz
  • Upload date:
  • Size: 14.4 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.1.0.tar.gz
Algorithm Hash digest
SHA256 1b82b1b675ce46d8bcb3599124410c52b48ffb601dd9428c232e615e2e1aca90
MD5 e43fbb6aeca4acc7f924fc591ef45ff6
BLAKE2b-256 759aa65cbc0d75501711d0d8e9a6d3b79089ffa9f29021e30bc63d8d7e8669df

See more details on using hashes here.

Provenance

The following attestation bundles were made for modelinfo_cli-1.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: modelinfo_cli-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8eba05b487034393b934ab86e55f03f70c1d7d071750ec91ddaadad288facea3
MD5 1d382ba86c920e0589dea0eabfeedcb3
BLAKE2b-256 cfbe5edf07f4e1ff8d0e360f1ccff75be0c3fe64c8fbf872a4e556d1d673fd08

See more details on using hashes here.

Provenance

The following attestation bundles were made for modelinfo_cli-1.1.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