Multi-node Bert-pretraining: Cost-efficient Approach

Jiahuang Lin, Xin Li, Gennady PekhimenkoarXiv 2020

Abstract

Training large-scale Transformer models like BERT-large typically requires multi-million dollar industrial hardware. This paper presents a practical roadmap for pre-training BERT-large in 12 days using an academic-scale cluster of budget-friendly NVIDIA T4 GPUs and standard 10Gb/s networking. By implementing software optimizations such as kernel fusion, automated mixed precision, and gradient accumulation, the authors achieved a 70% scaling efficiency. This approach reduces capital costs by approximately 90% compared to high-end industrial configurations, democratizing access to state-of-the-art NLP research.

Introduction

The computational demands of models like BERT-large have created a significant barrier to entry for researchers outside of "Big Tech." Standard benchmarks often rely on NVIDIA DGX workstations or Google TPU Pods, with clusters costing upwards of $5M. Furthermore, these systems utilize specialized interconnects like NVLink to handle massive communication overhead.

This research addresses the challenge of training these models on "commodity" hardware—specifically, clusters utilizing 10Gb/s Ethernet and budget GPUs. The goal is to prove that software-level optimizations can overcome hardware bottlenecks, making large-scale pre-training feasible for academic institutions and startups.

Hardware Configuration and System Architecture

The study utilized a 32-node cluster, with each node housing 8 NVIDIA T4 GPUs, totaling 256 GPUs. Unlike the high-bandwidth interconnects found in premium servers, this setup relies on standard PCIe switches and 10Gb/s network cards.

Hardware topology of a single node in the cluster, showing the connection between CPUs, PCIe switches, and T4 GPUs.

While the T4 is primarily marketed for inference, its Tensor Cores provide significant throughput for training when properly utilized. The primary challenge in this architecture is the relatively slow inter-node communication speed, which can severely limit scaling efficiency.

Software Optimization Methods

To achieve high efficiency on budget hardware, several key optimizations were implemented:

  • Data Sharding: To prevent I/O bottlenecks, datasets were pre-processed into HDF5 shards. This reduced data loading time from 10 minutes to under 2 minutes per epoch.
  • Automated Mixed Precision (AMP): By using FP16 for calculations while maintaining FP32 master weights, the researchers achieved a 1.7x to 2.5x speedup.
  • Kernel Fusion: Mathematical operations (e.g., GELU activation) were combined into single GPU kernels, reducing task-launch overhead and improving throughput by 11%.
  • Gradient Accumulation: To mitigate network latency, gradients were accumulated locally for four steps before a global update, significantly reducing the frequency of network synchronization.
  • Overlapping Communication: A pipelined approach was used to hide communication latency. As shown in the figure below, the system begins exchanging gradients for one layer while the GPU is still computing gradients for the subsequent layer.
Comparison of execution streams: the left side shows a sequential synchronization barrier, while the right side demonstrates overlapping the All-Reduce operation with the Backward pass to improve efficiency.

Results and Performance Analysis

The optimized setup successfully trained BERT-large in 12 days. Key performance metrics include:

  • Cost Efficiency: The acquisition cost of the T4 cluster (~$624k) was roughly 24 times lower than a comparable DGX-2 cluster.
  • Throughput: The combination of FP16 and Kernel Fusion resulted in a 2.78x speedup over non-optimized baselines.
  • Scaling Efficiency: Inter-node scaling efficiency improved from under 38% (without gradient accumulation) to 70%.
  • Model Accuracy: The model achieved an F1 score of 81-83% on SQuAD v1.1. While lower than the ~91% reported by industrial leaders, it demonstrates a functional model produced at a fraction of the cost.

Discussion and Limitations

The primary limitation of this approach is the observed accuracy gap. The 9-10% difference in F1 scores is likely attributable to limited hyperparameter tuning. Given the 12-day training cycle, exhaustive "trial and error" for learning rates and batch sizes was not feasible. Future work will focus on closing this performance gap through more efficient hyperparameter search strategies and exploring the scalability of these techniques for even larger models like GPT-3 on similar commodity hardware.

Summary updated

BibTeX
@misc{lin2020multi,
  author = {Jiahuang Lin and Xin Li and Gennady Pekhimenko},
  title = {{Multi-node Bert-pretraining: Cost-efficient Approach}},
  year = {2020},
  eprint = {2008.00177},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2008.00177},
}
Figure