New Tool Radar

Local AI

Set the Model Dtype for vLLM with –dtype When GPU Memory Is Small

Switch vLLM to --dtype float16 on a small GPU to cut memory use, and know when the auto default is better.

Schematic with three steps: Check what auto picks; Force float16 for a tight fit; Avoid float32.

vLLM picks the model dtype automatically, choosing bfloat16 on Ampere and newer GPUs. On a small card, forcing –dtype float16 cuts memory use by about 5 percent versus bfloat16, which can be the difference between a model fitting and an out-of-memory error.

What you need

  • vLLM installed on a Linux machine with an NVIDIA GPU
  • A model to serve, and its VRAM budget
  • nvidia-smi for checking VRAM use

Step 1: Check what auto picks

Start the server once with no dtype flag and read the startup log. On Ampere and newer GPUs the auto default is bfloat16; on older cards it may differ.

Step 2: Force float16 for a tight fit

Restart with vllm serve <model> –dtype float16. The guide reports this cuts memory use by about 5 percent versus bfloat16 at a marginal quality loss. If the GPU has under 16 GB of VRAM, also set –max-model-len conservatively.

Step 3: Avoid float32

Do not use –dtype float32 for serving; it doubles VRAM use versus the 16-bit dtypes and is almost never what you want. If float16 still does not fit, switch to a smaller model or a quantized checkpoint instead.

Worked example: a 3B model on a 16 GB card

The table below is a synthetic example. The dtype behaviour and the 5 percent figure come from the cited vLLM setup guide; the card is illustrative.

Dtype Memory vs bfloat16 When to use it
auto (bfloat16) Baseline Default on Ampere and newer
float16 About 5 percent less Tight VRAM fit
float32 About double Almost never for serving

Expected result (UNTESTED). with –dtype float16 the server starts on the small card where the auto dtype ran out of memory, and answers requests. This check was not run live; the dtype behaviour comes from the cited vLLM setup guide.

Limits

  • The memory saving is about 5 percent, not a fix for a model far too large.
  • Float16 can lose a little quality versus bfloat16 on some models.
  • The dtype flag applies at server start; changing it needs a restart.
  • Quantized checkpoints such as FP8 or 4-bit AWQ save far more than a dtype change.

Sources

See all