Skip to main content

gpu-fit

PyPI Tests Python License: MIT

Try it in your browser → · no install, nothing leaves your browser

Will this LLM fit on this GPU, at this context length, for this many users, and how fast?

gpu-fit answers that before you rent the GPU. It reads the model's config and weight sizes from Hugging Face and works out vLLM's memory budget: weights, runtime overhead, KV cache, how many requests fit at full context, and the longest single request. Then it prints the vllm serve command.

New in 0.4: sharing the GPU with something else? --reserve-gib gives the exact --gpu-memory-utilization vLLM will accept (details).

$ gpu-fit Qwen/Qwen3-32B --context 32k --concurrency 4

  GPU          smallest setup    requests at full ctx     KV tokens
  L4           8× L4                             11.0       361,200
  L40S         4× L40S                           12.0       394,683
  A100-80      2× A100-80                        10.3       336,234
  H100         2× H100                           10.2       333,577
  H200         1× H200                            8.3       270,751
  ...
$ gpu-fit deepseek-ai/DeepSeek-V3 --gpu H200 --tp 8 --context 128k

  vLLM budget per GPU             129.2 GiB
    weights                        80.2 GiB
    runtime overhead                3.0 GiB
    left for KV cache              46.0 GiB
  KV cache capacity              702,962 tokens
  Requests at full context       5.4
  Longest single request         163,840 tokens

✓ Fits. Suggested command:
  vllm serve deepseek-ai/DeepSeek-V3 --max-model-len 131072 --tensor-parallel-size 8 --max-num-seqs 256

Install

pip install gpu-fit        # no dependencies, Python 3.10+

What gpu-fit models

A parameters-times-bytes estimate is a good start. Newer architectures change the answer, so gpu-fit reads them:

Architecture What changes gpu-fit
Grouped-query attention KV per token depends on KV heads, not attention heads ✓
Hybrid (linear attention + full attention, e.g. Qwen3-Next family) Only full-attention layers grow with context; the rest hold fixed state per request ✓
MLA (DeepSeek) Compact latent KV, but copied to every tensor-parallel GPU ✓
Sliding window (Gemma, Mistral) Window layers stop growing past the window ✓
FP8 / AWQ / GPTQ checkpoints Exact weight size from the safetensors metadata ✓
Tensor parallel beyond KV heads KV heads get replicated, not split ✓
Hybrid --max-num-seqs limit vLLM refuses to start above the state-slot count ✓ warns first
FP8 KV cache Doubles capacity: --kv-cache-dtype fp8 ✓

Options

gpu-fit MODEL [--gpu L40S | --gpu-mem-gib 48] [--tp 2] [--context 128k]
              [--concurrency 8] [--max-num-seqs 32] [--kv-cache-dtype fp8] [--util 0.92]
              [--reserve-gib 12] [--overhead-gib 2.0] [--bandwidth-gbs 864] [--json]
  • MODEL: a Hugging Face id, or a local folder with config.json and *.safetensors. Gated models need HF_TOKEN in the environment.
  • Leave out --gpu to compare every GPU in the catalog with the smallest tensor-parallel size that works.
  • --json for scripts and CI.

Sharing the GPU with something else

vLLM grabs a fixed share of the GPU at startup and doesn't coordinate with anything else on the card: an OCR model, an embedding server, a second vLLM, or the old pod during a rolling deploy. It refuses to start if free memory is below total × gpu_memory_utilization, and if the other process grows later, someone runs out of memory.

Tell gpu-fit how much the other processes need per GPU and it works out the highest --gpu-memory-utilization vLLM will accept, and what still fits in what's left:

gpu-fit Qwen/Qwen3-8B --gpu L40S --reserve-gib 12 --context 16k --concurrency 8 --kv-cache-dtype fp8
...
✓ Fits. Suggested command:

  vllm serve Qwen/Qwen3-8B \
  --max-model-len 16384 \
  --kv-cache-dtype fp8 \
  --max-num-seqs 8 \
  --gpu-memory-utilization 0.72

Start the other processes first, and size --reserve-gib for their peak, not their idle use. gpu-fit keeps 0.5 GiB back for vLLM's own CUDA context at startup.

How the maths works

vLLM takes gpu_memory_utilization × GPU memory, loads the weights, profiles a forward pass (activations, CUDA graphs), and gives the rest to the KV cache. gpu-fit mirrors that:

KV pool   = memory × utilization − weights / tp − overhead
KV/token  = 2 × full-attention layers × KV heads per GPU × head dim × dtype bytes
requests  = KV pool / (context × KV/token + sliding-window KV + recurrent state)

Speed estimates

gpu-fit also estimates decode speed (tokens per second): for one user, and per user at your concurrency. Generating a token is memory-bound, so the estimate divides the GPU's memory bandwidth by what each step reads: the weights (for mixture-of-experts models, only the experts in use) plus every active request's KV cache, with a fixed per-layer cost that matters for small MoE models. Prompt processing is not included. It's a planning estimate: real numbers from your hardware are welcome (see CONTRIBUTING.md).

Accuracy, measured

Predicted vs what vLLM 0.31 actually allocated on an AWS g6e.xlarge (1× L40S 48 GB), 32K context, --max-num-seqs 32. Raw data and method: bench/.

Model Type KV tokens (vLLM) KV tokens (gpu-fit) Error
Qwen/Qwen3-8B dense 175,696 174,637 −0.6%
Qwen/Qwen3-14B dense 75,888 76,880 +1.3%
Qwen/Qwen3.8-27B-FP8 hybrid + vision 137,216 134,077 −2.3%
Qwen/Qwen3.6-35B-A3B-FP8 hybrid MoE + vision 179,361 158,477 −11.6% (cautious)
  • Weights and KV per token come straight from the config, so they're exact.
  • Runtime overhead (activations, CUDA graphs, non-torch memory) is calibrated from these runs at vLLM's default gpu_memory_utilization of 0.92: about 2.15 GiB for text models and 2.9 GiB when vLLM also profiles a vision encoder, plus a little more for each --max-num-seqs slot. Override it with --overhead-gib. (Before 0.4.0 gpu-fit assumed a 0.9 default and a smaller overhead; predictions at the default are unchanged.)
  • vLLM 0.34 changed this. On CUDA it now sizes the KV cache from memory actually free after warm-up ("extensible KV cache") and uses the whole GPU unless you set --gpu-memory-utilization. Not measured yet: expect more KV capacity than gpu-fit predicts; the estimate stays on the safe side. Measurements on 0.34 are next.
  • Hybrid models have a hard limit on --max-num-seqs. Each request needs one recurrent-state slot. Ask for more slots than fit and vLLM refuses to start; gpu-fit tells you the limit first (it predicted 156 where vLLM reported 164).
  • Treat the output as a planning estimate and confirm on the real GPU before you commit money.

Help make it exact: share what vLLM printed on your hardware (see CONTRIBUTING.md). Every measurement improves the defaults for everyone.

Roadmap

  • Memory model calibrated on real hardware (L40S)
  • Hybrid --max-num-seqs limit warning
  • Browser calculator
  • Decode speed estimate, MoE-aware
  • Shared-GPU budgeting (--reserve-gib)
  • Re-measure on vLLM 0.34 (extensible KV cache)
  • Workload mode: safe concurrency, throughput and cost per 1,000 requests
  • Speed calibrated against measured vLLM throughput
  • More GPUs measured (L4, H100) and models (Llama, Gemma, Mistral) from community results
  • Prompt-processing (prefill) time and time-to-first-token
  • Cost per million tokens for cloud GPUs
  • SGLang and TensorRT-LLM memory models
  • LoRA adapters and speculative decoding

License

MIT

Metadata

Release files for gpu-fit 0.4.1

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

Source distribution (sdist)

Source distribution for gpu-fit 0.4.1
File Size Uploaded Provenance Actions
gpu_fit-0.4.1.tar.gz 20.9 kB With provenance Details for gpu_fit-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gpu-fit 0.4.1
File Interpreter ABI Platform Actions
gpu_fit-0.4.1-py3-none-any.whl Python 3 none any Details for gpu_fit-0.4.1-py3-none-any.whl

Total release size: 38.1 kB

Release files / gpu_fit-0.4.1.tar.gz

Download URL gpu_fit-0.4.1.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5c4a8337bd8a7c563ebe31f3fe8944c0bc75c9a34b22bc5f8d94a06ae268454f
BLAKE2b-256 checksum
How to use checksums
3b29de5acf0464350b2a72353fa086a73ed5ff71f64aae12f66978e809875b11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 20, 2026.

Transparency log

Release files / gpu_fit-0.4.1-py3-none-any.whl

Download URL gpu_fit-0.4.1-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
921c734fd27b03f7c0556b4f4e048e696b19e9c779b776373832fc5066d88b29
BLAKE2b-256 checksum
How to use checksums
7fc1f4f1db9c9e4041c4f0355a3078dbed0a21dccff237dc38e2b79a32330dd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 20, 2026.

Transparency log

Security for gpu-fit 0.4.1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gpu_fit-0.4.1.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 Nov 20, 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