liveBook · Manning

vLLM

As explained in Domain-Specific Small Language Models

A high-throughput model serving library for running and benchmarking language models with efficient attention and API compatibility.

vLLM is a high-throughput library for language-model inference and serving. It targets LLM-specific memory and batching problems rather than general machine-learning model serving. Its PagedAttention system stores key–value cache blocks noncontiguously, reducing fragmentation and enabling more flexible batching. section 11.1 section 11.5

Use vLLM in two main ways:

  • Run models offline through the Python API, including text generation, chat, classification, scoring, rewards, and embeddings. section 11.1.1
  • Serve models online through an OpenAI-compatible HTTP API supporting completions, chat completions, embeddings, tokenization, scoring, pooling, and reranking. section 11.1.2
  • Configure generation with sampling parameters such as temperature, top_p, and top_k, and process multiple conversations in batches. section 11.1.1
  • Run quantized models, including GGUF models, and deploy with Docker, Kubernetes, Nginx, or AWS. section 11.1.2 section 11.5

Offline generation and online benchmarking

A typical offline workflow installs vLLM, loads GPT-2 or Phi-3 Mini with the LLM class, configures SamplingParams, and calls generate or chat. An online workflow starts `vllm serve`, calls the endpoint with the OpenAI Python client, then benchmarks ShareGPT traffic for throughput, latency, and time to first token. section 11.1.1 section 11.1.2

import torch
from vllm import LLM

model_id = "openai-community/gpt2"
device = "cuda" if torch.cuda.is_available() else "cpu"
vllm_model = LLM(model_id, device=device)

Shows the minimal Python setup for loading a model with device selection before running inference. section 11.1.1

How Domain-Specific Small Language Models covers it

How deep it goes
Explains PagedAttention, KV-cache fragmentation, batching, APIs, deployment, and benchmarks, but defers detailed implementation code.
Examples
Demonstrates GPT-2 and Phi-3 Mini generation, chat templates, GGUF loading, OpenAI-client requests, and ShareGPT benchmarking.
What it assumes
Assumes Python, pretrained models, Hugging Face identifiers, and GPU environments, while providing introductory API workflows.
What you can do after
Operate/configure local and HTTP language-model inference, then measure throughput, latency, and time to first token.
How it connects
Connects PagedAttention with KV caching, OpenAI API compatibility, quantization, Docker, Kubernetes, and serving benchmarks.

Also explained in

Compare how 2 books explain vLLM →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Domain-Specific Small Language Models. The section links point to the parts of the book it draws on.