Skip to main content

ModelInfo CLI

Python 3.10+ Dependencies License

ModelInfo Demo

ModelInfo is a CLI tool 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. It skips the full tensor payload entirely (no PyTorch, no HuggingFace) and parses in under 100ms.

Features

  • Zero-Dependency Parsing: Reads .safetensors 8-byte JSON prefixes and .gguf binary key-value metadata directly via struct and json (falling back to config.json if needed).
  • Remote Hugging Face Hub Inspection: Pass a repo ID (e.g., meta-llama/Llama-2-7b-hf) and it uses concurrent byte-range requests to read the headers off the CDN in under 2 seconds. No need to download the checkpoint.
  • Parses model.safetensors.index.json to support sharded models without crashing on partial downloads.
  • Dynamic VRAM & vLLM Capacity Planning: Calculates exact VRAM limits based on the model's architecture and your target context length. If you use the --vllm flag, it switches to a "Serving Capacity" simulation that calculates exactly how many tokens fit in the PagedAttention pool based on your --gpu-util ratio.
  • Hardware Fit Diagnostics: Check if a model fits your cluster with --gpu (e.g. --gpu RTX4090 or --gpu auto). It enforces Apple Silicon's 75% unified memory wire limit, and you can explicitly model multi-GPU NCCL communication penalties with --topology and --strategy.
  • Side-by-Side Comparison: Pass multiple models to trigger a comparison table (parameters, data types, context lengths, VRAM footprints).
  • Uses exact ggml_type mappings for GGUF formats to calculate byte-scaling coefficients, preventing VRAM under-reporting.
  • Secure Pickling: Inspects legacy .pt files safely using a restricted pickle.Unpickler.
  • The UI (built with rich) groups repetitive layers and color-codes VRAM heatmaps.

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

Tests cover the binary parsers and verify the sub-100ms local parse constraint using 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

For gated models (e.g., Llama 2), you must provide authentication by setting the HF_TOKEN environment variable. You can create a token in your Hugging Face settings.

export HF_TOKEN="hf_your_token_here"
modelinfo meta-llama/Llama-2-7b-hf

Alternatively, the tool will automatically read tokens stored by the hf auth login command (located in ~/.cache/huggingface/token).

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

modelinfo mistral-7b.safetensors --context 8192

Adjust the VRAM heat-mapping thresholds for your specific hardware (e.g., an 80GB card):

modelinfo meta-llama/Llama-2-7b-hf --max-vram 80

Determine if a model fits your specific hardware:

modelinfo mistralai/Mistral-7B-v0.1 --gpu "RTX 4090"
modelinfo mistralai/Mistral-7B-v0.1 --gpu auto

Compare multiple models side-by-side against a hardware target:

modelinfo mistralai/Mistral-7B-v0.1 Qwen/Qwen2.5-0.5B --gpu 12

Simulate exactly how many tokens you can serve using vLLM on a specific multi-GPU topology:

modelinfo mistralai/Mistral-7B-v0.1 --vllm --gpu 4xRTX4090 --topology pcie4 --strategy tp

Example Output (Single Model)

Format:          SafeTensors
Architecture:    MistralForCausalLM (32 layers)
Tensors:         291
Parameters:      7.2B
Dtype:           BF16
Disk size:       13.49 GB
VRAM (est):      ~15.07 GB Total Minimum Required
                   ├─ Weights:    13.49 GB
                   ├─ KV Cache:   1.0 GB (Default 8192 tokens. Native limit: 32,768)
                   └─ Overhead:   600.0 MB (CUDA Context + Activations)
Hardware Fit:    ✗ No (Requires 15.07 GB, Hardware has 12.0 GB)

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

Example Output (Comparison)

Model              Params    Dtype    Context    VRAM        Fits
Mistral-7B-v0.1    7.2B      BF16     8K         15.07 GB    ✗
Qwen2.5-0.5B       494.0M    BF16     8K         1.6 GB      ✓

Command Reference

Argument Example Description
[files...] modelinfo model.safetensors Inspect a single model (local path or Hugging Face repo ID).
[files...] modelinfo modelA modelB Pass multiple files/repos to automatically render a side-by-side comparison table instead of a deep-dive summary.
--gpu --gpu rtx4090 Check if the model fits. Accepts GPU names (rtx4090, b200, rx7900xtx), explicit VRAM limits in GB (--gpu 24), or local hardware auto-discovery (--gpu auto).
--context --context 32768 Adjust the target KV cache length. Essential for calculating the dynamic memory footprint of long-context models. Defaults to 8192.
--batch-size --batch-size 32 Batch size for dynamic KV cache footprint calculation. Defaults to 1.
--max-vram --max-vram 80 Adjusts the color-coded heat mapping thresholds (Green/Yellow/Red) in the terminal output to match a specific hardware ceiling.
--vllm --vllm --gpu auto Switches from additive memory checking to a serving capacity simulation. Shows exactly how many tokens fit in the PagedAttention pool.
--gpu-util --gpu-util 0.9 Sets the vLLM gpu_memory_utilization ratio. Defaults to 0.9 (reserves 10% for PyTorch context).
--topology --topology nvlink Set interconnect topology to calculate exact communication overhead penalties (nvlink, pcie4, pcie3). Defaults to pcie4.
--strategy --strategy tp Selects the parallelization strategy for multi-GPU setups (tp for Tensor Parallelism, pp for Pipeline Parallelism). Defaults to tp.
--tensors --tensors Bypasses the algorithmic speed estimation and forces the tool to fetch all remote shards, displaying an exact size breakdown of every tensor.
--timeout --timeout 30 Network timeout in seconds for remote Hugging Face fetches. Defaults to 10.
-v, --version modelinfo -v Show program's version number and exit.

Architecture

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) that use only the standard library.
  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.

Metadata

Release files for modelinfo-cli 1.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modelinfo-cli 1.4.4
File Size Uploaded Provenance
modelinfo_cli-1.4.4.tar.gz 30.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for modelinfo-cli 1.4.4
File Interpreter ABI Platform
modelinfo_cli-1.4.4-py3-none-any.whl Python 3 none any Details

Total release size: 55.5 kB

Release files / modelinfo_cli-1.4.4.tar.gz

Download URL modelinfo_cli-1.4.4.tar.gz
Size 30.3 kB
Tags Source
SHA-256 checksum
How to use checksums
93f1b20ae62336a1d5a1ca04b8c665b6389924b21f2181b94686124a82166f1f
BLAKE2b-256 checksum
How to use checksums
586a6e693a289c736f15c9251fe4eeaba6a1bc2fae5966530de33ece4394d21e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 27, 2026.

Transparency log

Release files / modelinfo_cli-1.4.4-py3-none-any.whl

Download URL modelinfo_cli-1.4.4-py3-none-any.whl
Size 25.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5fe41d2bb5f91df008bea70c42304f4fc0d9cebf146e611f7c074d5fa242bc0a
BLAKE2b-256 checksum
How to use checksums
4d189cb83ce8809d5b9e786fad773a409e2a4158e06fc55fb91a6f88e8d012e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 27, 2026.

Transparency log

Security for modelinfo-cli 1.4.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for modelinfo_cli-1.4.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page