Engine di inferenza ottimizzato per produzione
vLLM è un engine di inferenza LLM ad alte prestazioni con PagedAttention, continuous batching e API compatibile OpenAI. Ideale per carichi di lavoro pesanti.
1. Installazione
pip install vllm
2. Avviare il server
python -m vllm.entrypoints.openai.api_server \
--model meta-llama/Llama-3.2-8B-Instruct \
--host 0.0.0.0 \
--port 8000 \
--tensor-parallel-size 2 \
--gpu-memory-utilization 0.9 \
--max-model-len 8192
3. API compatibile OpenAI
# Chat completion
curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d "{
\"model\": \"meta-llama/Llama-3.2-8B-Instruct\",
\"messages\": [{\"role\": \"user\", \"content\": \"Ciao\"}],
\"temperature\": 0.7
}"
# Con Python
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="dummy")
response = client.chat.completions.create(
model="meta-llama/Llama-3.2-8B-Instruct",
messages=[{"role": "user", "content": "Ciao"}]
)
4. Vantaggi vs Ollama
- Throughput: 2-4x superiore grazie a PagedAttention e continuous batching
- Multi-GPU: tensor parallelism nativo
- API OpenAI: drop-in replacement per applicazioni esistenti
- Quantizzazione: supporto AWQ, GPTQ, SqueezeLLM
5. Quando usare vLLM vs Ollama
- Ollama: uso personale, chat interattiva, semplicità
- vLLM: produzione, alto throughput, multi-utente
vLLM gira su ARMANDILLO AI con 2x RTX 3060 in tensor parallel, servendo richieste API ad alta velocità.