Why is vLLM sometimes hard to configure?
vLLM supports hundreds of models, but default settings only work out of the box for a subset of them. Without the right settings, your vLLM workers may fail to load, produce incorrect outputs, or miss key features. Different model architectures have different requirements for tokenization, attention mechanisms, and features like tool calling or reasoning. For example, Mistral models use a specialized tokenizer mode and config format, while reasoning models like DeepSeek-R1 require you to specify a reasoning parser. When deploying a model, check its Hugging Face README and the vLLM documentation for required or recommended settings.Mapping environment variables to vLLM CLI flags
When running vLLM withvllm serve, the engine is configured using command-line flags. On Runpod, you set these options with environment variables instead.
Each vLLM command-line argument has a corresponding environment variable. Convert the flag name to uppercase with underscores: --tokenizer_mode becomes TOKENIZER_MODE, --enable-auto-tool-choice becomes ENABLE_AUTO_TOOL_CHOICE, and so on.
Example: Deploying Mistral
To launch a Mistral model using the vLLM CLI, you would run a command similar to this:
This pattern applies to any vLLM command-line flag. Find the corresponding environment variable name and add it to your endpoint configuration.
Model-specific configurations
The table below lists recommended environment variables for popular model families. These settings handle common requirements like tokenization modes, tool calling support, and reasoning capabilities. Not all models in a family require all settings. Check your model’s documentation for exact requirements.Selecting GPU size based on the model
Selecting the right GPU for vLLM is a balance between model size, quantization, and your required context length. Because vLLM pre-allocates memory for its KV (Key-Value) cache to enable high-throughput serving, you generally need more VRAM than the bare minimum required just to load the model.VRAM estimation formula
A reliable rule of thumb for estimating the required VRAM for a model in vLLM is:- FP16/BF16 (unquantized): 2 bytes per parameter.
- INT8 quantized: 1 byte per parameter.
- INT4 (AWQ/GPTQ): 0.5 bytes per parameter.
- KV cache buffer: vLLM typically reserves 10-30% of remaining VRAM for the KV cache to handle concurrent requests.
Context window vs. VRAM
The more context you need (e.g., 32k or 128k tokens), the more VRAM the KV cache consumes. If you encounter Out-of-Memory (OOM) errors, use theMAX_MODEL_LEN environment variable to cap the context. For example, a 7B model that OOMs at 32k context on a 24 GB card will often run perfectly at 16k.
GPU memory utilization
By default, vLLM attempts to use 90% of the available VRAM (GPU_MEMORY_UTILIZATION=0.90).
- If you OOM during initialization: Lower this to
0.85. - If you have extra headroom: Increase it to
0.95to allow for more concurrent requests.
Quantization (AWQ/GPTQ)
If you are limited by a single GPU, use a quantized version of the model (e.g.,Meta-Llama-3-8B-Instruct-AWQ). This reduces the weight memory by 50-75% compared to FP16, allowing you to fit larger models on cards like the RTX 4090 (24 GB) or A4000 (16 GB).