NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
BERT for PaddlePaddle
Resource
NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
BERT for PaddlePaddle

BERT is a method of pre-training language representations which obtains state-of-the-art results on a wide array of NLP tasks.

Benchmarking

The following section shows the steps to run benchmarks measuring the model performance in training and inference modes.

Training performance benchmark

Training performance benchmarks for pre-training can be obtained by running scripts/run_pretraining.sh, and fine-tuning can be obtained by running scripts/run_squad.sh for SQuAD, respectively. The required parameters can be passed through the command-line as described in Training process.

To benchmark the training performance on a specific batch size for pre-training, refer to Pre-training and turn on the <benchmark> flags. An example call to run pretraining for 20 steps (10 steps for warmup and 10 steps to measure, both in phase1 and phase2) and generate throughput numbers:

bash scripts/run_pretraining.sh \
    256 6e-3 amp 8 0.2843 7038 200 false \
    32 0 bert_pretraining 32 4e-3 0.128 1563 128 \
    /path/to/dataset/phase1 \
    /path/to/dataset/phase2 \
    /workspace/bert \
    None \
    /path/to/wikipedia/source \
    32 128 4 0.9 64 static \
    None true 10 10

To benchmark the training performance on a specific batch size for SQuAD, refer to Fine-tuning and turn on the <benchmark> flags. An example call to run training for 200 steps (100 steps for warmup and 100 steps to measure), and generate throughput numbers:

bash scripts/run_squad.sh \
    /path/to/pretrained/model \
    2 32 4.6e-5 0.2 amp 8 42 \
    /path/to/squad/v1.1 \
    vocab/bert-large-uncased-vocab.txt \
    results/checkpoints \
    train \
    bert_configs/bert-large-uncased.json \
    -1 true 100 100

Inference performance benchmark

Inference performance benchmark for fine-tuning can be obtained by running scripts/run_squad.sh. The required parameters can be passed through the command-line as described in Inference process.

To benchmark the inference performance on a specific batch size for SQuAD, run:

bash scripts/run_squad.sh \
    <pre-trained model path> \
    <epochs> <batch size> <learning rate> <warmup_proportion> <amp|fp32> <num_gpus> <seed> \
    <path to SQuAD dataset> \
    <path to vocab set> \
    <results directory> \
    eval \
    <BERT config path> \
    <max steps> <benchmark> <benchmark_steps> <benchmark_warmup_steps>

An example call to run inference and generate throughput numbers:

bash scripts/run_squad.sh \
    /path/to/pretrained/model \
    2 32 4.6e-5 0.2 amp 8 42 \
    /path/to/squad/v1.1 \
    vocab/bert-large-uncased-vocab.txt \
    results/checkpoints \
    eval \
    bert_configs/bert-large-uncased.json \
    -1 true 100 100

Results

The following sections provide details on how we achieved our performance and accuracy in training and inference.

Training accuracy results

Our results were obtained by running the scripts/run_squad.sh and scripts/run_pretraining.sh training scripts in the paddle NGC container unless otherwise specified.

Pre-training loss results: NVIDIA DGX A100 (8x A100 80GB)
DGX SystemGPUs / NodePrecisionAccumulated Batch size / GPU (Phase 1 and Phase 2)Accumulation steps (Phase 1 and Phase 2)Final LossTime to train(hours)Time to train speedup (TF32 to mixed precision)
32 x DGX A100 80GB8AMP256 and 1281 and 41.409~ 1.2 hours1.72
32 x DGX A100 80GB8TF32128 and 16b2 and 81.421~ 2.5 hours1
Pre-training loss curves

Pre-training Loss Curves

Fine-tuning accuracy results: NVIDIA DGX A100 (8x A100 80GB)
  • SQuAD
GPUsBatch size / GPU (TF32 and FP16)Accuracy - TF32(% F1)Accuracy - mixed precision(% F1)Time to train(hours) - TF32Time to train(hours) - mixed precisionTime to train speedup (TF32 to mixed precision)
83291.1391.110.0780.0561.39
Training stability test
Pre-training stability test
Accuracy MetricSeed 0Seed 1Seed 2Seed 3Seed 4MeanStandard Deviation
Final Loss1.4091.3671.5281.4341.4701.4420.049
Fine-tuning stability test
  • SQuAD

Training stability with 8 GPUs, FP16 computations, batch size of 32:

Accuracy MetricSeed 0Seed 1Seed 2Seed 3Seed 4Seed 5Seed 6Seed 7Seed 8Seed 9MeanStandard Deviation
Exact Match %84.0784.3983.9483.7883.8584.4784.1384.2084.0383.8084.070.225
f1 %90.8691.0090.8290.5690.7691.1190.7790.9090.6590.5490.800.173

Training performance results

Training performance: NVIDIA DGX A100 (8x A100 80GB)

Our results were obtained by running the script run_pretraining.sh in the PaddlePaddle:22.12-py3 NGC container on NVIDIA DGX A100 (8x A100 80GB) GPUs. Performance numbers (in sequences per second) were averaged over a few training iterations.

Pre-training NVIDIA DGX A100 (8x A100 80GB)
GPUsBatch size / GPU (TF32 and FP16)Accumulation steps (TF32 and FP16)Sequence lengthThroughput - TF32(sequences/sec)Throughput - mixed precision(sequences/sec)Throughput speedup (TF32 - mixed precision)Weak scaling - TF32Weak scaling - mixed precision
18192 and 819264 and 321283076332.061.001.00
88192 and 819264 and 32128242849902.067.917.88
14096 and 4096256 and 1285121072192.051.001.00
84096 and 4096256 and 12851285117242.267.957.87
Pre-training NVIDIA DGX A100 (8x A100 80GB) Multi-node Scaling
NodesGPUs / nodeBatch size / GPU (TF32 and FP16)Accumulated Batch size / GPU (TF32 and FP16)Accumulation steps (TF32 and FP16)Sequence lengthMixed Precision ThroughputMixed Precision Strong ScalingTF32 ThroughputTF32 Strong ScalingSpeedup (Mixed Precision to TF32)
18126 and 2568192 and 819264 and 3212849901242812.06
28126 and 2564096 and 409632 and 1612895811.9246381.912.07
48126 and 2562048 and 204816 and 8128192623.8694453.892.04
88126 and 2561024 and 10248 and 4128375267.52183357.552.05
168126 and 256512 and 5124 and 21287115614.263552614.632.00
328126 and 256256 and 2562 and 112814208728.476970128.712.04
1816 and 324096 and 4096256 and 1285121724185112.03
2816 and 322048 and 2048128 and 6451233051.9216011.882.06
4816 and 321024 and 102464 and 3251264923.7732403.812.00
8816 and 32512 and 51232 and 16512128847.4763297.442.04
16816 and 32256 and 25616 and 85122549314.791227314.422.08
32816 and 32128 and 1288 and 45124930728.602404728.262.05
Fine-tuning NVIDIA DGX A100 (8x A100 80GB)
  • SQuAD
GPUsBatch size / GPU (TF32 and FP16)Throughput - TF32(sequences/sec)Throughput - mixed precision(sequences/sec)Throughput speedup (TF32 - mixed precision)Weak scaling - TF32Weak scaling - mixed precision
132 and 32831201.451.001.00
832 and 326298761.397.597.30

Inference performance results

Inference performance: NVIDIA DGX A100 (1x A100 80GB)

Our results were obtained by running scripts/run_squad.sh in the PaddlePaddle:22.08-py3 NGC container on NVIDIA DGX A100 with (1x A100 80G) GPUs.

Fine-tuning inference on NVIDIA DGX A100 (1x A100 80GB)
  • SQuAD
GPUsBatch Size (TF32/FP16)Sequence LengthThroughput - TF32(sequences/sec)Throughput - Mixed Precision(sequences/sec)
132/32384131158

To achieve these same results, follow the steps in the Quick Start Guide.

The inference performance metrics used were items/second.