Appearance
Capítulo 6: Multi-GPU
Para modelos muy grandes que no caben en una sola GPU, puedes distribuir la carga entre múltiples GPUs.
Conceptos de Paralelismo
Tensor Parallelism
- Cada GPU computation una parte de cada tensor
- Requiere comunicación intensa entre GPUs
- NVLink recomendado
- Mejor para GPUs similares
Pipeline Parallelism
- Cada GPU computation un rango de capas
- Comunicación menos intensa
- Latencia de pipeline (bursts)
- Más tolerante a GPUs heterogéneas
Configuraciones Soportadas
GPUs Homogéneas
bash
# 3 GPUs idénticas
python main.py --params-b 405 --context 8192 --quantization int4 --multi-gpu --gpu-config "3x4090"GPUs Heterogéneas
bash
# Mixing GPUs
python main.py --params-b 405 --context 8192 --quantization int4 --multi-gpu --gpu-config "2x4090,1x3090"Modos de Paralelismo
bash
# Tensor parallelism (default)
--multi-gpu-mode tensor
# Pipeline parallelism
--multi-gpu-mode pipelineEjemplos de Uso
Escenario 1: 3x RTX 4090 con Tensor Parallelism
bash
python main.py --params-b 405 --context 8192 --quantization int4 --multi-gpu --gpu-config "3x4090"Resultado:
============================================
CONFIGURACIÓN MULTI-GPU
============================================
Modelo: 405B INT4
Contexto: 8192
GPUs: 3x RTX 4090 (72GB total)
Modo: Tensor Parallelism
• VRAM por GPU: 24 GB
• Carga por GPU: ~22 GB
• Comunicación: NVLink recomendada
Rendimiento estimado:
• Tokens/segundo: ~40-60
• Ancho de banda necesario: AltoEscenario 2: GPUs Mixtas
bash
python main.py --params-b 405 --multi-gpu --gpu-config "2x4090,1x3090" --multi-gpu-mode pipelineResultado:
============================================
CONFIGURACIÓN MULTI-GPU (HETEROGÉNEA)
============================================
Modelo: 405B INT4
GPUs: 2x RTX 4090 + 1x RTX 3090
Modo: Pipeline Parallelism
Distribución de capas:
• RTX 4090 #1: Capas 1-30
• RTX 4090 #2: Capas 31-60
• RTX 3090: Capas 61-80
Notas:
• GPU más lenta limita el pipeline
• Recomendado: misma velocidad de GPUEscenario 3: Modelos Grandes
bash
# 70B en 2 GPUs
python main.py --params-b 70 --context 4096 --multi-gpu --gpu-config "2x3090"
# 405B en 8 GPUs
python main.py --params-b 405 --context 8192 --multi-gpu --gpu-config "8xA100"Tabla de Requisitos
| Modelo | Parámetros | GPUs | VRAM/GPU (INT4) |
|---|---|---|---|
| LLaMA 7B | 7B | 1 | 8 GB |
| LLaMA 13B | 13B | 1 | 16 GB |
| LLaMA 70B | 70B | 2-4 | 18 GB |
| Mixtral 8x7B | 56B | 2 | 14 GB |
| LLaMA 405B | 405B | 8 | 24 GB |
Consideraciones
NVLink vs PCIe
- Tensor Parallelism: Requiere NVLink para mejor rendimiento
- Pipeline Parallelism: Funciona con PCIe
Latencia
- Tensor: Baja latencia, alto throughput
- Pipeline: Mayor latencia inicial (warmup)
Heterogeneidad
- Tensor: GPUs deben ser similares
- Pipeline: Más tolerante a diferencias
Commits Relacionados
feat: Add advanced inference configuration features (v0.2.0)- Soporte multi-GPU
Siguiente Capítulo
En el Capítulo 7, exploraremos configuraciones avanzadas y casos de uso.