Skip to content

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 pipeline

Ejemplos 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: Alto

Escenario 2: GPUs Mixtas

bash
python main.py --params-b 405 --multi-gpu --gpu-config "2x4090,1x3090" --multi-gpu-mode pipeline

Resultado:

============================================
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 GPU

Escenario 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

ModeloParámetrosGPUsVRAM/GPU (INT4)
LLaMA 7B7B18 GB
LLaMA 13B13B116 GB
LLaMA 70B70B2-418 GB
Mixtral 8x7B56B214 GB
LLaMA 405B405B824 GB

Consideraciones

  • 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.