Generated banner for Hf Mem
Generated logo for Hf Mem

Hf Mem

Hugging FaceOfficialPublished by Hugging Face

  • Skill
  • Tool integration
  • Data and AI
  • Apache-2.0
  • No issues found

From the author

Hugging Face CLI to estimate the required memory to load Safetensors or GGUF model weights for inference from the Hugging Face Hub
— the description by Hugging Face

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

hf-mem is a command-line tool designed to estimate the VRAM or system memory required to run inference for models hosted on the Hugging Face Hub. By utilizing HTTP Range requests, it retrieves necessary metadata from Safetensors or GGUF files without requiring a full download or local loading of weights. It supports advanced estimation, including KV cache requirements for LLMs and VLMs, by allowing users to specify context length, batch size, and precision settings.

What it does

  • Estimates memory usage for Safetensors and GGUF models directly from the Hugging Face Hub.
  • Calculates requirements without downloading or loading model weights locally.
  • Provides experimental support for estimating KV cache memory for LLMs and VLMs.
  • Supports configuration of context window length, batch size, and KV cache precision.
  • Outputs results in JSON format for easy integration into automated workflows.
  • Handles gated or private models via authentication tokens.

When to use it

  • When you need to determine if a specific model will fit on your available GPU or hardware.
  • When you want to quickly check memory requirements for multiple models before downloading.
  • When planning infrastructure or instance requirements for deploying LLMs or VLMs.
  • When you need to calculate memory overhead including KV cache for specific inference parameters.

Advantages

  • Fast estimation by avoiding full model downloads.
  • Lightweight execution using HTTP Range requests.
  • Supports a wide range of precision and quantization formats for GGUF.
  • Enables informed hardware selection for model deployment.

Usage examples

“How much VRAM do I need to run the Mistral-7B-v0.1 model?”
The agent runs hf-mem with the --experimental flag to provide an estimate of the model weights and the KV cache requirements based on default context settings.
“Will the Qwen3.5-397B-A17B-GGUF model fit on my machine if I use the Q4_K_M quantization?”
The agent executes hf-mem targeting the specific GGUF file to return the memory footprint for that quantization level.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/huggingface/hf-mem/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip hf-mem.zip -d .agents/skills

Documentation by Hugging Face

hf_mem estimates the required memory for inference, including model weights and an optional KV cache, for Safetensors and GGUF for models on the Hugging Face Hub using HTTP Range requests i.e., without downloading or loading any weights locally.

When to use?

  • User asks how much VRAM or memory a model needs to run

  • User wants to know if a model fits on their GPU or a given instance

  • User references a Hugging Face model ID or URL and asks about inference requirements

What are the requirements?

  • uv installed (for uvx)

  • HF_TOKEN env var or --hf-token flag (for gated or private models only)

How to run?

Run with --model-id pointing to the Hugging Face Hub repository which will check that it either contains Safetensors (via model.safetensors, model.safetensors.index.json if sharded, or model_index.json for Diffusers) or GGUF model weights within.

uvx hf-mem --model-id <model-id> --json-output

If the repository contains GGUF model weights in multiple precisions / quantizations, the estimations will be on a per-file basis, whereas for inference you won't load all of those but rather only a single precision. This being said, for GGUF you might as well need to provide --gguf-file to target the specific file (or path if sharded) you want to run.

uvx hf-mem --model-id <model-id> --gguf-file <file-or-path> --json-output

Additionally, hf-mem comes with an --experimental flag that will also calculate the KV cache memory requirements too, useful for large-language models, meaning it applies to LLMs (...ForCausalLM), VLMs (...ForConditionalGeneration), and GGUF models.

As per the context window, it will be read from the default or overridden with --max-model-len a la vLLM. And, same goes for the KV cache precision, which will default to the model precision unless manually set via --kv-cache-dtype a la vLLM too.

For Safetensors use as:

uvx hf-mem --model-id <model-id> --experimental [--max-model-len N] [--batch-size N] [--kv-cache-dtype auto|bfloat16|fp8|fp8_ds_mla|fp8_e4m3|fp8_e5m2|fp8_inc] --json-output

And, for GGUF use as:

uvx hf-mem --model-id <model-id> --gguf-file <file-or-path> --experimental [--max-model-len N] [--batch-size N] [--kv-cache-dtype auto|F32|F16|Q4_0|Q4_1|Q5_0|Q5_1|Q8_0|Q8_1|Q2_K|Q3_K|Q4_K|Q5_K|Q6_K|Q8_K|IQ2_XXS|IQ2_XS|IQ3_XXS|IQ1_S|IQ4_NL|IQ3_S|IQ2_S|IQ4_XS|I8|I16|I32|I64|F64|IQ1_M|BF16|TQ1_0|TQ2_0|MXFP4] --json-output

Examples

For Transformers with Safetensors weights:

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

For Diffusers with Safetensors weights:

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

For Sentence Transformers with Safetensors weights:

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

With --experimental to include the KV cache estimation for LLMs and VLMs:

uvx hf-mem --model-id mistralai/Mistral-7B-v0.1 --experimental --json-output

And, for LLMs or VLMs with GGUF weights:

uvx hf-mem --model-id unsloth/Qwen3.5-397B-A17B-GGUF --gguf-file Q4_K_M --experimental --json-output

Files

ATTRIBUTION.md

Attribution

This folder is an unmodified copy of the Agent Skill "hf-mem", distributed by AutoGineer (https://autogineer.com/agent-skills).

The skill's own files are unmodified copies. AutoGineer is not affiliated with or endorsed by the author or the publisher.

Files added by AutoGineer

  • ATTRIBUTION.md: this file, written by AutoGineer

  • LICENSE: copied from LICENSE

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Hugging Face
Publisher
Hugging Face (Official)
Source
huggingface/skills · skills/hf-mem · commit 25910b3
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Hugging Face.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download hf-mem.zip