Aperçu
vLLM est un moteur d'inference LLM haute performance et économe en mémoire, doté de PagedAttention (quasi zéro gaspillage mémoire), batching continu, parallélisme tensoriel, décodage spéculatif, prefix caching et une API compatible OpenAI.
Installation
uv pip install vllm
Inference hors ligne
from vllm import LLM, SamplingParams
llm = LLM(model="Qwen/Qwen2.5-1.5B-Instruct")
params = SamplingParams(temperature=0.7, top_p=0.9, max_tokens=512)
outputs = llm.generate(["What is the capital of France?"], params)
for o in outputs:
print(o.outputs[0].text)
Serveur API
vllm serve Qwen/Qwen2.5-1.5B-Instruct --port 8000
# Client OpenAI :
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "Qwen/Qwen2.5-1.5B-Instruct", "messages": [{"role": "user", "content": "Hello!"}]}'
Multi-GPU
llm = LLM(model="meta-llama/Llama-3.1-8B", tensor_parallel_size=2)