Chapitre 3 : Service à grande échelle
vLLM
Service à haut débit avec PagedAttention :
from vllm import LLM, SamplingParams
llm = LLM(model="meta-llama/Llama-2-7b-hf")
sampling_params = SamplingParams(temperature=0.7, max_tokens=256)
outputs = llm.generate(["Hello, my name is"], sampling_params)
Text Generation Inference (TGI)
Serveur de production de Hugging Face :
docker run --gpus all -p 8080:80 \
ghcr.io/huggingface/text-generation-inference:latest \
--model-id meta-llama/Llama-2-7b-hf
Comparaison
| Cadre | Meilleur pour | Fonction clé |
|---|---|---|
| vLLM | Débit | PagedAttention |
| TGI | Production | Intégration HF |
| Triton | Multi-modèle | Optimisé par NVIDIA |
Équilibrage de charge
# Exemple : déploiement Kubernetes
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3 # Plusieurs réplicas pour l'équilibrage de charge
template:
spec:
containers:
- name: llm-server
resources:
limits:
nvidia.com/gpu: 1