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.
  • Remote Hugging Face Hub Inspection: Inspect any public or gated model directly via its repo ID (e.g., modelinfo meta-llama/Llama-2-7b-hf) without downloading the 15GB checkpoint. Uses concurrent byte-range requests to pluck the binary headers directly off the CDN in under 2 seconds.
  • 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. Defaults to 8192 tokens to prevent unrealistic VRAM calculations, while still warning users if the requested context exceeds the model's native limit. Estimates include a standard 600MB CUDA context overhead.
  • 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. Breaks down memory footprints into Weights, KV Cache, and Overhead.

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 local model checkpoint:

modelinfo mistral-7b.safetensors

Inspect a remote model directly from the Hugging Face Hub:

modelinfo meta-llama/Llama-2-7b-hf

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.2.0.tar.gz (17.1 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.2.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modelinfo_cli-1.2.0.tar.gz
  • Upload date:
  • Size: 17.1 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.2.0.tar.gz
Algorithm Hash digest
SHA256 65d0a552a59dd984a4b0f6f33f87eb99b737312ba5cd73346cc644ac5d94ec4e
MD5 d6dab14e0d4920d85597988febe3b766
BLAKE2b-256 eedbed53cb79605d03b7048df533ac38deede0d9ea4d39b4aef2e4cb9aad7de7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: modelinfo_cli-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a2271b8ddc4842397a2c2e299ebbd6dc26ce97e37423066340ae135f1bd46cd
MD5 07283b604758d0c4d7c06cd133419940
BLAKE2b-256 47eaa0e11a1c8e193c3c27fb31fce45860ffe72a428e288df12e6e3750435d46

See more details on using hashes here.

Provenance

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