HLAT: High-quality Large Language Model Pre-trained on AWS Trainium

Haozheng Fan, Hao Zhou, Guangtai Huang, Parameswaran Raman, Xinwei Fu, Gaurav Gupta, Dhananjay Ram, Yida Wang, Jun Huan

Abstract

As the demand for Large Language Model (LLM) pre-training scales, the industry faces a significant bottleneck in GPU availability and cost. This paper introduces HLAT (High-quality Large language model pre-trained on AWS Trainium), a family of 7B and 70B parameter models trained from scratch on AWS Trainium accelerators. By leveraging the NeuronX Distributed Training (NxDT) library and implementing specific architectural and software optimizations, we demonstrate that Trainium can produce models competitive with the LLaMA family while achieving a ~40% reduction in training costs. Our work provides a comprehensive blueprint for large-scale foundation model training on non-GPU hardware.

1. Introduction

The "GPU squeeze" has become a defining constraint in artificial intelligence research, with high costs and limited supply of NVIDIA hardware creating barriers to entry. AWS Trainium represents a purpose-built alternative designed specifically for deep learning workloads. However, the nascent ecosystem around such custom silicon often lacks the battle-tested training recipes available for CUDA-based systems.

HLAT bridges this gap by establishing a proven methodology for training multi-billion parameter models on Trainium. We pre-trained our models on 1.8 trillion tokens using up to 4,096 Trainium accelerators, proving that the hardware-software stack is ready for heavyweight foundation model development.

2. Methodology

2.1 Model Architecture

The HLAT models utilize a decoder-only Transformer architecture, following the design principles of the LLaMA family. Key components include:

  • RMSNorm for improved training stability.
  • SwiGLU activation functions to enhance non-linearity.
  • Rotary Positional Embeddings (RoPE) for better long-context handling.

2.2 Distributed Training Stack

Training was conducted on trn1.32xlarge instances using the NeuronX Distributed Training (NxDT) library. To manage the 70B parameter scale, we employed 3D Parallelism, combining Tensor, Pipeline, and Data parallelism to shard the model across 256 instances (4,096 chips).

Key software optimizations included:

  • Online Dataloader: To avoid the bottleneck of pre-tokenizing multi-terabyte datasets, we developed a loader that tokenizes and packs samples on-the-fly using CPU resources while the accelerators perform computations.
  • Layer Coalescing: We optimized the Trainium execution graph by combining Q, K, and V layers into single operations, significantly reducing communication overhead and increasing throughput.
  • Automatic Fault Recovery: Given the statistical likelihood of hardware failures at the 4,000-chip scale, we implemented a mechanism in NxDT that automatically replaces faulty nodes and resumes training from the most recent checkpoint. This increased system uptime from 77% to approximately 99%.

2.3 Precision and Stability

For the HLAT-7B model, we utilized Stochastic Rounding (SR) with BF16 precision, which provides an unbiased estimate of FP32. However, our experiments revealed that SR introduced instability in the 70B model due to nondeterministic normalization errors in deeper architectures. Consequently, for the 70B scale, we transitioned to a custom mixed-precision strategy to ensure convergence.

3. Datasets and Training

3.1 Pre-training Corpus

The models were trained on a 1.8 trillion token corpus comprising high-quality open-source data, including RedPajama-1T, peS2o (academic papers), and OpenWebMath.

3.2 Upsampling Strategy

For the final 400 billion tokens of the 70B model's training, we implemented a specialized upsampling strategy. We increased the proportion of Wikipedia, C4, StackExchange, Arxiv, and GitHub code. This targeted data mix was designed to specifically bolster the model's reasoning and programming capabilities in the final stages of convergence.

4. Results and Insights

4.1 Performance Benchmarks

HLAT-70B achieved a score of 65.1% on MMLU, placing it in direct competition with LLaMA-1 and OpenLLaMA. The upsampling strategy proved highly effective, yielding a 10% improvement in math (GSM8K) and a 5% improvement in coding (HumanEval) tasks compared to the base pre-training phase.

4.2 The Math Reasoning "Phase Change"

A notable observation during training was the non-linear emergence of mathematical ability. Performance on GSM8K remained relatively stagnant for the first trillion tokens before exhibiting an exponential increase. This suggests that logical reasoning capabilities require a specific threshold of data exposure before the model can effectively generalize.

4.3 Cost Efficiency

The most critical finding for infrastructure planning is the cost-to-performance ratio. The Cost Per 4-million Tokens (CPT) on Trainium was approximately 60% of the cost of comparable NVIDIA A100-based instances, representing a 40% total saving for the pre-training run.

5. Limitations and Future Work

While HLAT demonstrates the viability of Trainium, several areas for growth remain. The current models are base models only and have not undergone Supervised Fine-Tuning (SFT) or RLHF. Additionally, while 1.8T tokens was a competitive standard during development, state-of-the-art models are now moving toward 15T+ tokens. Future iterations will focus on scaling the token count and maturing the software ecosystem to reduce the manual tuning required for compiler flags and parallelism degrees.

6. Conclusion

HLAT proves that AWS Trainium is a heavyweight contender for LLM pre-training. By providing a stable, high-performance, and cost-effective alternative to traditional GPU clusters, this work lowers the barrier for organizations to develop their own large-scale foundation models. The training scripts and configurations have been open-sourced to support the continued growth of the Trainium ecosystem.

Summary updated

BibTeX
@inproceedings{fan2024hlat,
  author = {Haozheng Fan and Hao Zhou and Guangtai Huang and Parameswaran Raman and Xinwei Fu and Gaurav Gupta and Dhananjay Ram and Yida Wang and Jun Huan},
  title = {{HLAT: High-quality Large Language Model Pre-trained on AWS Trainium}},
  booktitle = {IEEE Big Data},
  year = {2024},
  doi = {10.1109/bigdata62323.2024.10825098},
}
Figure