Skip to main content

[!WARNING] hf-mem is still experimental and therefore subject to major changes across releases, so please keep in mind that breaking changes may occur until v1.0.0.

hf-mem is a CLI to estimate inference memory requirements for Hugging Face models, written in Python. hf-mem is lightweight, only depends on httpx2, as it pulls the Safetensors and / or GGUF metadata via HTTP Range requests. It's recommended to run with uv for a better experience.

hf-mem lets you estimate the inference requirements to run any model from the Hugging Face Hub, including Transformers, Diffusers and Sentence Transformers models, or really any model as long as it contains any of Safetensors or GGUF weights.

Read more information about hf-mem in this short-form post, but note it's not up-to-date as it was written in January 2026.

Usage

CLI (Recommended)

Transformers

uvx hf-mem --model-id MiniMaxAI/MiniMax-M2

Diffusers

uvx hf-mem --model-id Qwen/Qwen-Image

Sentence Transformers

uvx hf-mem --model-id google/embeddinggemma-300m

Python

You can also run it programmatically with Python as:

from hf_mem import run

result = run(model_id="MiniMaxAI/MiniMax-M2", experimental=True)
print(result)
# Result(model_id='MiniMaxAI/MiniMax-M2', revision='main', filename=None, memory=230121630720, kv_cache=24964497408, total_memory=255086128128, details=False)

If you're already inside an async application, use arun(...) instead:

from hf_mem import arun

result = await arun(model_id="MiniMaxAI/MiniMax-M2", experimental=True)
print(result)
# Result(model_id='MiniMaxAI/MiniMax-M2', revision='main', filename=None, memory=230121630720, kv_cache=24964497408, total_memory=255086128128, details=False)

Experimental

By enabling the --experimental flag, you can enable the KV Cache memory estimation for LLMs (...ForCausalLM) and VLMs (...ForConditionalGeneration), even including a custom --max-model-len (defaults to the config.json default), --batch-size (defaults to 1), and the --kv-cache-dtype (defaults to auto which means it uses the default data type set in config.json under torch_dtype or dtype, or rather from quantization_config when applicable).

Additionally, for Mixture of Experts (MoEs), the --experimental flag also adds a weights-only breakdown of the base model and all the experts combined.

uvx hf-mem --model-id MiniMaxAI/MiniMax-M2 --experimental

GGUF

If the repository contains GGUF model weights, those will be listed by default (only if there are no Safetensors weights, otherwise the GGUFs will be ignored) and the memory will be estimated for each one of those; whereas if a specific file is provided, then the memory estimation will be targeted for that given file instead.

uvx hf-mem --model-id TheBloke/deepseek-llm-7B-chat-GGUF --experimental

Or if you want to only get the estimation on a given file:

uvx hf-mem --model-id TheBloke/deepseek-llm-7B-chat-GGUF --gguf-file deepseek-llm-7b-chat.Q2_K.gguf --experimental

Skills

Optionally, you can add hf-mem as an agent skill, which allows the underlying coding agent to discover and use it when provided as a SKILL.md, e.g., .claude/skills/hf-mem/SKILL.md.

More information can be found at Anthropic Agent Skills and how to use them.

Extensions

Optionally, you can also add hf-mem as an extension to the Hugging Face Hub CLI under hf as hf mem .... First you need to install hf as explained in Hugging Face CLI - "Getting started". To add hf-mem as an extension, all you need to do is run:

hf extensions add alvarobartt/hf-mem

More information can be found at Hugging Face Hub CLI - "How Python extensions are installed".

Once installed, you can use hf-mem via hf as hf mem ... along with the rest of Hugging Face extensions you have installed (which you can list via hf extensions list).

References

Metadata

Release files for hf-mem 0.5.6

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

Source distribution (sdist)

Source distribution for hf-mem 0.5.6
File Size Uploaded
hf_mem-0.5.6.tar.gz 26.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hf-mem 0.5.6
File Interpreter ABI Platform
hf_mem-0.5.6-py3-none-any.whl Python 3 none any Details

Total release size: 60.2 kB

Release files / hf_mem-0.5.6.tar.gz

Download URL hf_mem-0.5.6.tar.gz
Size 26.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4a95abf3293d928111e1dfe41baf2d94e261b0557a6a84ae0e26ff438398ffb0
BLAKE2b-256 checksum
How to use checksums
c85f2de2850a8bddada31d184e321491f0f7e447181bd635a1f51ade805b7391
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / hf_mem-0.5.6-py3-none-any.whl

Download URL hf_mem-0.5.6-py3-none-any.whl
Size 33.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ee5824f82276cca1aca1eb06e5b578ad2cb7cc634af6c6354197b6ebdca62f8
BLAKE2b-256 checksum
How to use checksums
cb88c1bbfdfe53c65f9b91f95b7561dc8868a4146f2ffeaba713d921bd545645
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.5.6 This release

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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