Train Your Own AI

Running Inference Cheap: vLLM on a Rented GPU

FlopSource Research

You trained it, quantized it for your laptop in Episode 3, and preference-tuned it in Episode 5. Now it has to be served: many requests, all day, on a GPU you pay for by the hour. Serving is inference at volume, and the tool built for it is vLLM. This is the companion tutorial to Train Your Own AI, Episode 6: the verified vLLM build for a single 24 GB, 4090-class GPU. No headline hourly price is quoted here because rental prices move daily; check the directory for today's.

Why serving is a different engine

A naive server answers one request, finishes it, then starts the next. The GPU waits most of its life. vLLM attacks that waste twice:

Together they move your cost basis from cost per idle hour to cost per token.

The VRAM math on 24 GB

Everything must fit at once: weights, KV cache, and runtime overhead.

Install and serve your fine-tune

pip install vllm
vllm serve ./your-merged-model \
  --host 0.0.0.0 --port 8000 \
  --served-model-name your-finetune \
  --gpu-memory-utilization 0.90 \
  --max-model-len 8192

Or skip merging entirely. vLLM serves LoRA adapters directly: enable LoRA, pass the adapter as a named module, and set the max rank to 16, the rank this series trains at.

vllm serve unsloth/Qwen2.5-7B-Instruct \
  --enable-lora --max-lora-rank 16 \
  --lora-modules your-finetune=./dpo-out \
  --gpu-memory-utilization 0.90 --max-model-len 8192

The first launch takes longer because the weights download and load. After that the server is up on port 8000.

Hit it like it is OpenAI

vLLM exposes an OpenAI-compatible API, including /v1/chat/completions, /v1/completions, and /v1/models. The client change is the base URL:

from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1",
                api_key="EMPTY")

resp = client.chat.completions.create(
    model="your-finetune",
    messages=[{"role": "user",
               "content": "Summarize this ticket in one line."}])
print(resp.choices[0].message.content)

No custom client, and no rewrite when you move the model between a rented box, your own hardware, and a hosted API.

Where the cheap actually comes from

  1. Keep the GPU busy. Batch offline jobs instead of dribbling them in one at a time; continuous batching only pays when requests flow.
  2. Cache the shared prefix. With --enable-prefix-caching, requests that share a long system prompt can reuse that prefix's KV cache instead of recomputing it.
  3. Fit the card. A quantized serving copy that fits comfortably beats a bigger model that forces the next GPU tier.
  4. Stop it when it stops. A rented GPU charges for idle hours exactly like busy ones.

Your true price is one formula: cost per 1M tokens = (hourly rate / 3600) / sustained tokens per second x 1,000,000.

Measure it, do not guess it

  1. Throughput: total tokens per second across all requests under realistic prompts, not one lonely request.
  2. Time to first token (TTFT): the wait users actually feel.
  3. Server signals: vLLM exposes /metrics (Prometheus), /health, and /v1/models, so queue depth and cache use are visible, not guessed.
  4. If you are cache-bound (throughput flat, latency climbing): shorten max model length, serve a quantized copy, or cap concurrent sequences.

Recap, and what is next

Serving is its own engine: PagedAttention and continuous batching let one 4090-class GPU carry many requests at once. Do the VRAM math first, serve with one vllm serve command (merged model or a LoRA adapter, no merge), talk to it with the OpenAI client you already have, and prove your cost per million tokens with measured throughput.

Next in the series: eval harnesses, proving your fine-tune actually worked.

Find the cheapest GPU for your next run

Live pricing, hardware specs, and availability across 30 GPU clouds, neoclouds, and bare-metal providers.

Open the Directory