Skip to main content

Distributed Training

AITraining supports multi-GPU training through Accelerate, with optional DeepSpeed Zero-3 optimization for large models.

Requirements

Distribution Backends

Quick Start

DDP (Default)

With multiple GPUs, DDP is used automatically:

DeepSpeed

For large models, use DeepSpeed Zero-3:

Python API

YAML Configuration

How It Works

Accelerate Launch

Training is launched through Accelerate:
  1. AITraining detects available GPUs
  2. Launches training via accelerate launch
  3. For DeepSpeed, adds --use_deepspeed and Zero-3 flags
  4. Logs accelerate env for debugging

DDP Settings

When using DDP:
  • ddp_find_unused_parameters=False is set for performance
  • Each GPU processes a portion of the batch
  • Gradients are synchronized across GPUs

DeepSpeed Zero-3

When using DeepSpeed:
  • Model parameters are sharded across GPUs
  • Uses --deepspeed_multinode_launcher standard for multi-node
  • Zero-3 configuration is applied automatically
  • Model saving uses accelerator.get_state_dict() with unwrapping

Multi-Node Training

For multi-node DeepSpeed training:
The --deepspeed_multinode_launcher standard flag is passed automatically.

Task-Specific Behavior

LLM Training

  • Default: DDP when multiple GPUs detected
  • DeepSpeed: Explicitly set --distributed-backend deepspeed

Seq2Seq and VLM

  • Auto-selects DeepSpeed for many-GPU cases
  • Uses multi-GPU DDP for PEFT + quantization + bf16 combinations

Checkpointing with DeepSpeed

When using DeepSpeed, PEFT adapter saving is handled differently. The SavePeftModelCallback is not used; instead, saving uses accelerator.get_state_dict(trainer.deepspeed) and unwraps the model.

GPU Selection

Control which GPUs to use:

Troubleshooting

Check Accelerate Environment

Common Issues

Next Steps

LoRA/PEFT

Efficient fine-tuning

Quantization

Reduce memory usage