/major-ai-skills:vllmfrom major-ai-skills
Deploy and tune vLLM OpenAI-compatible servers: PagedAttention KV budgeting, continuous batching, chunked prefill, tensor parallel, quantization, and preemption/OOM failure modes.
Ships in major-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
vLLM is an open-source high-throughput LLM serving engine. PagedAttention stores KV cache in non-contiguous blocks (OS-page analogy), cutting fragmentation. Continuous batching schedules at iteration granularity; chunked prefill (default on V1 when possible) interleaves long prefills with decode so TTFT spikes do not starve live streams. Agents size GPU memory utilization vs max model length vs concurrency, expose the OpenAI-compatible HTTP API, and treat preemption warnings as capacity signals—not noise.
┌─────────────────────────────────────────────────────────────┐
│ vLLM engine topology │
│ │
│ Ingress: OpenAI-compatible HTTP │
│ ├── /v1/chat/completions | /v1/completions | /v1/models │
│ ├── /health (+ metrics / Prometheus in prod) │
│ └── SSE token streaming │
│ │
│ Scheduler + PagedAttention │
│ ├── Continuous batching (preempt / recompute when KV full) │
│ ├── Block table: logical tokens → physical KV blocks │
│ └── Chunked prefill + max_num_batched_tokens budget │
│ │
│ Workers │
│ ├── Tensor parallel (NCCL) / optional pipeline parallel │
│ ├── Quantization: awq | gptq | fp8 | bitsandbytes │
│ └── FlashAttention / FlashInfer kernels │
└─────────────────────────────────────────────────────────────┘
Use when
@openai-api clients.@huggingface-transformers generate.Do not use when
@pytorch / @huggingface-transformers Trainer.vllm serve <model> (current CLI) over ad-hoc imports for production processes.--gpu-memory-utilization (default 0.92) with headroom for CUDA graphs / NCCL; do not push ≥0.95 on multi-tenant boxes.--max-model-len to the product context you actually serve—unused context burns KV.--tensor-parallel-size N with Docker --ipc=host and adequate --shm-size; debug hangs with NCCL_DEBUG=INFO.--max-num-batched-tokens: lower (~2048) favors ITL; higher (>8192) favors throughput/TTFT on small models / large GPUs. Chunked prefill is on by default in V1 when possible.max_num_seqs / context—not as a silent retry loop.curl -f /health and /v1/models before attaching load balancers.HF_TOKEN)—never commit credentials; local OpenAI clients may use a placeholder api_key only when the server does not auth.start_vllm.sh:
#!/usr/bin/env bash
set -euo pipefail
MODEL_NAME="${MODEL_NAME:-Qwen/Qwen2.5-7B-Instruct}"
SERVED_MODEL_NAME="${SERVED_MODEL_NAME:-qwen2.5-7b}"
PORT="${PORT:-8000}"
TP_SIZE="${TP_SIZE:-1}"
GPU_MEM_UTIL="${GPU_MEM_UTIL:-0.90}"
MAX_MODEL_LEN="${MAX_MODEL_LEN:-8192}"
nvidia-smi --query-gpu=name,memory.total,memory.free --format=csv,noheader
export VLLM_LOGGING_LEVEL="${VLLM_LOGGING_LEVEL:-INFO}"
exec vllm serve "$MODEL_NAME" \
--served-model-name "$SERVED_MODEL_NAME" \
--host 0.0.0.0 \
--port "$PORT" \
--tensor-parallel-size "$TP_SIZE" \
--gpu-memory-utilization "$GPU_MEM_UTIL" \
--max-model-len "$MAX_MODEL_LEN" \
--dtype auto
Streaming client:
"""Async OpenAI-compatible client against a local vLLM server."""
from __future__ import annotations
import asyncio
import os
from openai import AsyncOpenAI
async def stream_chat(prompt: str) -> str:
base = os.environ.get("VLLM_BASE_URL", "http://127.0.0.1:8000/v1")
# Server without auth: placeholder key required by SDK shape only
client = AsyncOpenAI(base_url=base, api_key=os.environ.get("VLLM_API_KEY", "EMPTY"))
model = os.environ.get("VLLM_MODEL", "qwen2.5-7b")
stream = await client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": prompt},
],
temperature=0.2,
max_tokens=512,
stream=True,
)
parts: list[str] = []
async for chunk in stream:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)
parts.append(delta)
print()
return "".join(parts)
if __name__ == "__main__":
asyncio.run(stream_chat("Explain PagedAttention in three bullets."))
Recipes:
# FP8 / quantized path when weights support it
vllm serve Qwen/Qwen2.5-7B-Instruct --quantization fp8 --gpu-memory-utilization 0.85
# 4-GPU TP for larger instruct weights
vllm serve meta-llama/Llama-3.1-70B-Instruct --tensor-parallel-size 4 --max-model-len 16384
curl -f http://127.0.0.1:8000/health
curl -s http://127.0.0.1:8000/v1/models | head
| Signature | Likely cause | Fix path |
|---|---|---|
| CUDA OOM at load | Weights + KV reserve > util × VRAM | Lower --gpu-memory-utilization; shorten --max-model-len; quantize; increase TP |
OOM / ncclUnhandledCudaError without OutOfMemoryError | NCCL buffers after KV pool filled | Lower blocks override / util; ensure NCCL init accounted; upgrade vLLM/NCCL |
| Preemption warnings / latency spikes | KV cache thrash under concurrency | Lower max_num_seqs; raise util/TP; confirm chunked prefill; watch KV metrics |
| High TTFT under load | Long prefills starving decode | Keep chunked prefill; tune max_num_batched_tokens |
| Multi-GPU hang / NCCL timeout | Missing IPC/shm or bad P2P topology | Docker --ipc=host --shm-size=16g; NCCL_P2P_DISABLE=1 on broken PCIe; matching GPU SKUs |
max-model-len ValueError | Requested len > model / rope limit | Align with model card; use documented rope-scaling only when supported |
| Hub 401 on gated model | Missing HF token | HF_TOKEN from secret store; accept license |
| Client 404 model name | --served-model-name ≠ client model | Align names in /v1/models |
# GPU blocks — that is your KV budget.@docker / @kubernetes).0.0.0.0 is safe.@huggingface-transformers).@huggingface-transformers — model export, chat templates, fine-tunes@pytorch — CUDA/AMP fundamentals and NCCL-adjacent debugging context@openai-api — client patterns against compatible servers@docker — GPU container flags (ipc, shm-size, device mounts)@mlflow — record serving config experiments / eval metricsMANDATORY: Budget KV with
gpu-memory-utilizationandmax-model-lenbefore promising concurrency. Prefervllm serve. Health-check before routing traffic. Treat preemption as capacity failure. Never embed Hub or API secrets in scripts—read from the environment. Keep served model name aligned with clients.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alivirgo/major-ai-skills --plugin major-ai-skills412 skills in this plugin
/3d-slicerAutomate 3D Slicer research workflows with MRML, VTK/ITK, DICOM data, and Segment Editor. Use for software workflows, not clinical interpretation./abbreviated-git-statusInspect Git branch, staging, and working-tree changes with short or porcelain status output when a compact repository check is needed./ableton-liveAutomate Ableton Live sessions with Python MIDI Remote Scripts, Max for Live, AbletonOSC, and Link synchronization.Other plugins' skills for the same job
/act-as-a-personal-tutorExplain a subject step by step, assess prior knowledge, and use short exercises to check understanding before advancing.