Gradient accumulation sums gradients across multiple mini-batches before updating parameters, helping train with a larger effective batch size when GPU memory is limited. section 5.3.4
training_args = TrainingArguments( #1
per_device_train_batch_size=1,
gradient_accumulation_steps=4,
num_train_epochs=1,
learning_rate=2e-4,
fp16=True,
logging_steps=10,
output_dir="./finetuned-llama2-bitext",
save_strategy="no"
)
A training configuration uses a per-device batch size of 1 and accumulates gradients over 4 steps, for an effective batch size of 4. section 5.3.4
