hf-mem estimates the memory required to run any model from the Hugging Face Hub, or from a local path, without downloading the weights. It reads the Safetensors, GGUF and ONNX metadata via HTTP Range requests, and only depends on httpx2.
The estimate covers the model weights, the KV cache for generative models, and the runtime overhead of the inference engine (activations, encoder, graphs and runtime), for Transformers, Diffusers, Sentence Transformers, GGUF and ONNX models (without the ONNX Runtime overhead).
Run it with uv as uvx hf-mem <model>, where <model> is a Hugging Face Hub model ID (optionally with @revision, and with :<quantization> for GGUF), an URL, or a local path.
$ uvx hf-mem zai-org/GLM-5.3-Flash
ββ¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬ hf-mem v1.0.0 β
ββ΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β€
β INFERENCE MEMORY ESTIMATE FOR β
β https://hf.co/zai-org/GLM-5.3-Flash @ main β
β w/ max-model-len=1048576, batch-size=1 β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β TOTAL MEMORY β 329.36 GiB (321.34B PARAMS + KV CACHE + OVERHEAD) β
β REQUIREMENTS β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β MODEL (9.67B PARAMS, 15.46 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β BF16 β 12.90 / 329.36 GiB β
β 6.93B PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β F8_E4M3 β 2.55 / 329.36 GiB β
β 2.74B PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β F32 β 0.00 / 329.36 GiB β
β 462.94K PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β EXPERTS (288 x 1.08B PARAMS, 290.32 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β F8_E4M3 β 290.25 / 329.36 GiB β
β 311.65B PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β F32 β 0.07 / 329.36 GiB β
β 19.02M PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β KV CACHE (1048576 TOKENS, 16.80 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β BF16 β 16.80 / 329.36 GiB β
β 1048576 TOKENS β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β OVERHEAD (6.78 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ACTIVATIONS β 3.17 / 329.36 GiB β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ENCODER β 0.03 / 329.36 GiB β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β GRAPHS β 1.69 / 329.36 GiB β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β RUNTIME β 1.88 / 329.36 GiB β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββFor generative models (LLMs, VLMs, omni and speech models) the KV cache is estimated for the context length in config.json and a single sequence, which can be changed with --max-model-len and --batch-size. The KV cache dtype defaults to auto, which as in vLLM is the model dtype unless the quantization_config declares a quantized KV cache, and can be set with --kv-cache-dtype (e.g. fp8).
$ uvx hf-mem Qwen/Qwen3.8-27B --max-model-len 32768 --batch-size 4
ββ¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬ hf-mem v1.0.0 β
ββ΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β€
β INFERENCE MEMORY ESTIMATE FOR β
β https://hf.co/Qwen/Qwen3.8-27B @ main β
β w/ max-model-len=32768, batch-size=4 β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β TOTAL MEMORY β 70.15 GiB (27.78B PARAMS + KV CACHE + OVERHEAD) β
β REQUIREMENTS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β MODEL (27.78B PARAMS, 51.75 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β BF16 β 51.75 / 70.15 GiB β
β 27.78B PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β KV CACHE (131072 TOKENS, 9.19 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β BF16 β 9.19 / 70.15 GiB β
β 131072 TOKENS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β OVERHEAD (9.22 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ACTIVATIONS β 4.38 / 70.15 GiB β
β β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ENCODER β 1.61 / 70.15 GiB β
β β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β GRAPHS β 1.34 / 70.15 GiB β
β β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β RUNTIME β 1.88 / 70.15 GiB β
β β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ$ uvx hf-mem Qwen/Qwen-Image-2.1
ββ¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬ hf-mem v1.0.0 β
ββ΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β€
β INFERENCE MEMORY ESTIMATE FOR β
β https://hf.co/Qwen/Qwen-Image-2.1 @ main β
βββββββββββββββββββ¬βββββββββββββββββββββββββββββββ€
β TOTAL MEMORY β 30.84 GiB (16.22B PARAMS) β
β REQUIREMENTS β ββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄βββββββββββββββββββββββββββββββ€
β TEXT_ENCODER (8.77B PARAMS, 16.33 GiB) β
βββββββββββββββββββ¬βββββββββββββββββββββββββββββββ€
β BF16 β 16.33 / 30.84 GiB β
β 8.77B PARAMS β ββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄βββββββββββββββββββββββββββββββ€
β TRANSFORMER (7.12B PARAMS, 13.25 GiB) β
βββββββββββββββββββ¬βββββββββββββββββββββββββββββββ€
β BF16 β 13.25 / 30.84 GiB β
β 7.12B PARAMS β ββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄βββββββββββββββββββββββββββββββ€
β VAE (337.74M PARAMS, 1.26 GiB) β
βββββββββββββββββββ¬βββββββββββββββββββββββββββββββ€
β F32 β 1.26 / 30.84 GiB β
β 337.74M PARAMS β ββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄βββββββββββββββββββββββββββββββ$ uvx hf-mem google/embeddinggemma-2
ββ¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬ hf-mem v1.0.0 β
ββ΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β€
β INFERENCE MEMORY ESTIMATE FOR β
β https://hf.co/google/embeddinggemma-2 @ main β
βββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ€
β TOTAL MEMORY β 1.39 GiB (744.37M PARAMS) β
β REQUIREMENTS β ββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ€
β BF16 β 1.39 / 1.39 GiB β
β 744.37M PARAMS β ββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββGGUF repositories list every file, and a quantization tag as in llama.cpp (<model>:Q4_K_M, case-insensitive) or --file (a tag, file, directory or any shard of a sharded file) estimates a single one. The mmproj projector of vision and audio models is included as llama.cpp does, picking the one with the same quantization, or else Q8_0, F16, BF16 or F32, together with the compute buffer of its encoders in the overhead.
$ uvx hf-mem LiquidAI/LFM3-1.7B-GGUF
ββ¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬ hf-mem v1.0.0 β
ββ΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β€
β INFERENCE MEMORY ESTIMATE FOR β
β https://hf.co/LiquidAI/LFM3-1.7B-GGUF @ main β
β w/ max-model-len=262144, batch-size=1 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β FILES β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β 6.85 GiB (3.22 GiB WEIGHTS + 3.01 GiB KV + 0.62 GiB OVERHEAD) β
β LFM3-1.7B-BF16.gguf β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β 6.85 GiB (3.22 GiB WEIGHTS + 3.01 GiB KV + 0.62 GiB OVERHEAD) β
β LFM3-1.7B-F16.gguf β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β 4.81 GiB (1.18 GiB WEIGHTS + 3.01 GiB KV + 0.62 GiB OVERHEAD) β
β LFM3-1.7B-NVFP4.gguf β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β 4.64 GiB (1.02 GiB WEIGHTS + 3.01 GiB KV + 0.62 GiB OVERHEAD) β
β LFM3-1.7B-Q4_K_M.gguf β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β 4.79 GiB (1.16 GiB WEIGHTS + 3.01 GiB KV + 0.62 GiB OVERHEAD) β
β LFM3-1.7B-Q5_K_M.gguf β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β 4.95 GiB (1.32 GiB WEIGHTS + 3.01 GiB KV + 0.62 GiB OVERHEAD) β
β LFM3-1.7B-Q6_K.gguf β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β 5.34 GiB (1.71 GiB WEIGHTS + 3.01 GiB KV + 0.62 GiB OVERHEAD) β
β LFM3-1.7B-Q8_0.gguf β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β 4.60 GiB (0.97 GiB WEIGHTS + 3.01 GiB KV + 0.62 GiB OVERHEAD) β
β LFM3-1.7B-QAD-Q4_0.gguf β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ$ uvx hf-mem unsloth/Qwen3.8-27B-GGUF:UD-Q4_K_M
ββ¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬ hf-mem v1.0.0 β
ββ΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β€
β INFERENCE MEMORY ESTIMATE FOR β
β https://hf.co/unsloth/Qwen3.8-27B-GGUF @ main β
β FOR `Qwen3.8-27B-UD-Q4_K_M.gguf` β
β w/ max-model-len=262144, batch-size=1 β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β TOTAL MEMORY β 32.76 GiB (27.78B PARAMS + KV CACHE + OVERHEAD) β
β REQUIREMENTS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β CPU MEMORY β 0.67 GiB (1.27B PARAMS OFFLOADED, NOT ON GPU) β
β HOST MEMORY β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β MODEL (26.05B PARAMS, 14.66 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Q5_K β 4.50 / 32.76 GiB β
β 7.03B PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β IQ4_XS β 4.43 / 32.76 GiB β
β 8.96B PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Q4_K β 3.25 / 32.76 GiB β
β 6.20B PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Q6_K β 1.69 / 32.76 GiB β
β 2.21B PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β IQ4_NL β 0.31 / 32.76 GiB β
β 587.20M PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Q3_K β 0.25 / 32.76 GiB β
β 623.90M PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β IQ3_S β 0.14 / 32.76 GiB β
β 356.52M PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Q8_0 β 0.08 / 32.76 GiB β
β 76.02M PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β F32 β 0.01 / 32.76 GiB β
β 2.67M PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β MMPROJ (460.73M PARAMS, 0.86 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β F16 β 0.85 / 32.76 GiB β
β 457.67M PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β F32 β 0.01 / 32.76 GiB β
β 3.06M PARAMS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β KV CACHE (262144 TOKENS, 16.15 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β F16 β 16.15 / 32.76 GiB β
β 262144 TOKENS β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β OVERHEAD (1.09 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ACTIVATIONS β 0.15 / 32.76 GiB β
β β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ENCODER β 0.47 / 32.76 GiB β
β β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β RUNTIME β 0.47 / 32.76 GiB β
β β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ--file also selects a single *.safetensors file or shard set, e.g. on ComfyUI repositories that ship multiple checkpoints.
ONNX repositories list every variant, grouping the files loaded together (e.g. encoder_model and decoder_model_merged, or vision_encoder, embed_tokens and decoder_model_merged in Transformers.js exports) with their external data, and --file estimates a single variant, file or directory (e.g. an ONNX Runtime GenAI folder).
$ uvx hf-mem onnx-community/Qwen3-0.6B-ONNX --file onnx/model_q4f16.onnx
ββ¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬ hf-mem v1.0.0 β
ββ΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β΄β€
β INFERENCE MEMORY ESTIMATE FOR β
β https://hf.co/onnx-community/Qwen3-0.6B-ONNX @ main β
β FOR `onnx/model_q4f16.onnx` β
β w/ max-model-len=40960, batch-size=1 β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ€
β TOTAL MEMORY β 4.91 GiB (FROM FILE SIZES + KV CACHE) β
β REQUIREMENTS β βββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββ€
β MODEL (0.53 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ€
β FILE SIZE β 0.53 / 4.91 GiB β
β β βββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββ€
β KV CACHE (40960 TOKENS, 4.38 GiB) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ€
β F16 β 4.38 / 4.91 GiB β
β 40960 TOKENS β βββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββThe weights are the initializers in the ONNX graph, and the KV cache comes from the past_* graph inputs, i.e. the dtype and the cached heads per token as exported, with the context length from config.json. ONNX files over 16 MiB with the weights inline are estimated from their file sizes, reading only the graph inputs at the end of the file, and the ONNX Runtime overhead is not estimated.
Local directories and files work the same way (including hf download --local-dir folders, shown with the downloaded commit), and models already downloaded to the Hugging Face cache are read from disk when unchanged on the Hub, or only from the cache with HF_HUB_OFFLINE=1.
uvx hf-mem ./path/to/model
HF_HUB_OFFLINE=1 uvx hf-mem Qwen/Qwen3-8BGated and private models need a token, read from --hf-token, HF_TOKEN, or the token saved by hf auth login.
-o json (or --output json) prints the estimate in bytes, and -o markdown prints a table to share in model cards, issues or pull requests.
uvx hf-mem Qwen/Qwen3-8B --max-model-len 32768 -o json{
"version": "hf-mem@1.0.0",
"model": "Qwen/Qwen3-8B",
"revision": "main",
"file": null,
"format": "safetensors",
"total": 27343113879,
"weights": {"bytes": 16381470720, "params": 8190735360, "dtypes": {"BF16": {"bytes": 16381470720, "params": 8190735360}}},
"offloaded": null,
"components": null,
"kv_cache": {"bytes": 4831838208, "dtype": "BF16", "max_model_len": 32768, "batch_size": 1, "layers": {"full": 36}},
"overhead": {"bytes": 6129804951, "activations": 3371389470, "encoder": 0, "graphs": 739780853, "runtime": 2018634628},
"moe": null,
"fit": null,
"warnings": []
}totalis the sum ofweights,kv_cacheandoverheadin bytes, and theoverheadparts are described in How it works;kv_cacheandoverheadarenullfor non-generative models.file,offloaded(weights in CPU memory, not intotal),components(per Diffusers component, file or GGUFmmproj),moe(base model and experts breakdown) andfit(with--gpu-memory) arenullwhen they do not apply, andparamsisnullwhen the weights come from file sizes (ONNX files with the weights inline).fithas thegpu_memoryandusablememory per GPU, the memoryrequiredon the given GPUs (with the overhead and the replicated KV cache per GPU), the GPUsneeded, whether itfits, and the longestmax_model_lenthat fits.formatissafetensors,gguforonnx.- GGUF and ONNX repositories with several files return a
fileslist with thefile,total,weights,kv_cacheandoverheadof each file instead.
from hf_mem import run
result = run("Qwen/Qwen3-8B", max_model_len=32768)
print(result.total, result.weights.bytes, result.kv_cache.bytes, result.overhead.bytes)
# 27343113879 16381470720 4831838208 6129804951
print(result.to_dict())run takes the same options as the CLI (revision, file, format, max_model_len, batch_size, kv_cache_dtype, hf_token, gpu_memory, gpu_memory_utilization and max_num_batched_tokens), and await arun(...) can be used within an async application. Both return an Estimate, or a Listing with one Estimate per file for GGUF and ONNX repositories.
Coding agents can use uvx hf-mem <model> -o json to answer questions such as how much memory a model needs or whether it fits on a given GPU (adding --gpu-memory), as described in the hf-mem skill.
hf-mem can also be added as an extension to the Hugging Face CLI as hf mem ...:
hf extensions add alvarobartt/hf-memhf-mem only reads the metadata of the weight files (the Safetensors headers, the GGUF metadata or the ONNX graph) with HTTP Range requests, and adds up the memory an inference engine needs on the GPU:
- Weights: the exact size of every tensor, per dtype and component. Weights that the engine keeps in CPU memory are reported apart, as vLLM does with the DeepSeek-V4.1 Engram tables and llama.cpp with the token embeddings.
- KV cache: what the engine allocates for
--max-model-lentokens and--batch-sizesequences, following the model's attention: full attention caches every token, sliding window layers only the window, latent and compressed attention (e.g. DeepSeek, GLM) a smaller record per token, and linear attention or Mamba layers a fixed state per sequence. - Overhead: the memory used on top of that, i.e. the activations of a forward pass, the vision or audio encoder for the largest input, the CUDA graphs, and the runtime (the CUDA context and library workspaces).
The KV cache and the overhead follow vLLM for Safetensors models and llama.cpp for GGUF models, as validated on NVIDIA T4 to H200 GPUs with vLLM 0.33, SGLang 0.5 and llama.cpp on 50+ models: the KV cache matches vLLM exactly for most architectures (within 3% for DeepSeek-V4.1, Kimi Linear and Qwen3.8-Flash-Next), the overhead is within 10% of vLLM's on median, and the vision and audio encoders of GGUF models are within 5% of llama.cpp's.
- The estimates follow vLLM and llama.cpp with their default settings, so other engines (e.g. SGLang, which reserves a fixed share of the GPU instead) and non-default settings use different amounts of memory.
- ONNX models have no overhead estimate, and GGUF and ONNX listings estimate each file from its size, so a single file (
:<quantization>or--file) gives the most accurate numbers. - vLLM profiles the vision encoder of some models (e.g. Qwen2.5-VL) with a video when it has more tokens than an image, which can reserve a few GiB more (
hf-memwarns about it). - PyTorch pickle weights (
.bin,.pt,.ckptor.nemo) are not supported, and encoder-decoder models (e.g. Whisper) have no KV cache estimate. - Kimi K3.1 defaults to vLLM's
fp8_ds_mlacache layout on Hopper. Use--kv-cache-dtype fp8for the per-tensor FP8 layout used by FlashInfer on Blackwell. - AMD and NVIDIA Blackwell GPUs go through the same accounting in vLLM, but have not been validated.