NVIDIA
NVIDIA
BERT for TensorFlow
Resource
NVIDIA
NVIDIA
BERT for TensorFlow

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

Performance

Benchmarking

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

Benchmarking can be performed for both training and inference. Both scripts run the BERT model for fine tuning. You can specify whether benchmarking is performed in FP16 or FP32 by specifying it as an argument to the benchmarking scripts.

Both of these benchmarking scripts enable you to run a number of epochs and extract performance numbers.

Training performance benchmark

Training benchmarking can be performed by running the script:

scripts/finetune_train_benchmark.sh squad <fp16/fp32> <use_xla> <num_gpu> <batch_size/gpu> <lr> 

Inference performance benchmark

Inference benchmarking can be performed by running the script:

scripts/finetune_inference_benchmark.sh squad <fp16/fp32> <use_xla> <batch_size> <path-to-checkpoint> 

Results

The following sections provide details on how we achieved our performance and accuracy in training and inference for Question Answering fine tuning.

Training accuracy results

Our results were obtained by running the run_squad.py training script in the TensorFlow 19.03-py3 NGC container on NVIDIA DGX-1 with 8x V100 32G GPUs.

Number of GPUsBatch size per GPUTraining time with FP16 (Hrs)Training time with FP32 (Hrs)
840.510.77
Training stability test

The following tables compare F1 scores across 5 different training runs with different seeds, for both FP16 and FP32 respectively. The runs showcase consistent convergence on all 5 seeds with very little deviation.

FP16, 8x GPUsseed #1seed #2seed #3seed #4seed #5meanstd
F191.1690.6990.9990.9491.1790.990.196
Exact match84.283.6884.1483.9584.3484.060.255
FP32, 8x GPUsseed #1seed #2seed #3seed #4seed #5meanstd
F190.6790.890.9490.8390.9390.830.11
Exact match83.5683.9683.9983.9584.1283.920.21

Training performance results

Our results were obtained by running batch sizes up to 3x GPUs on a 16GB V100 and up to 10x GPUs on a 32G V100 with mixed precision.

NVIDIA DGX-1 (8x V100 16G)

Our results were obtained by running the scripts/run_squad.sh training script in the TensorFlow 19.03-py3 NGC container on NVIDIA DGX-1 with 8x V100 16G GPUs. Performance numbers (in tokens per second) were averaged over an entire training epoch.

Number of GPUsBatch size per GPUFP32 sentences/secFP16 sentences/secSpeed-up with mixed precisionMulti-gpu weak scaling with FP32Multi-gpu weak scaling with FP16
127.4111.861.61.01.0
4223.69935.341.493.22.98
8244.2964.961.475.985.48
Number of GPUsBatch size per GPUFP32 sentences/secFP16 sentences/secSpeed-up with mixed precisionMulti-gpu weak scaling with FP32Multi-gpu weak scaling with FP16
13-14.86--1.0
43-44.17--2.97
83-78.89--5.3

Note: The respective values for FP32 runs that use a batch size of 3 are not available due to out of memory errors that arise. Batch size of 3 is only available on using FP16.

To achieve these same results, follow the Quick Start Guide outlined above.

NVIDIA DGX-1 (8x V100 32G)

Our results were obtained by running the scripts/run_squad.sh training script in the TensorFlow 19.03-py3 NGC container on NVIDIA DGX-1 with 8x V100 32G GPUs. Performance numbers (in sentences per second) were averaged over an entire training epochs.

Number of GPUsBatch size per GPUFP32 sentences/secFP16 sentences/secSpeed-up with mixed precisionMulti-gpu weak scaling with FP32Multi-gpu weak scaling with FP16
148.5518.142.121.01.0
4432.1352.851.643.762.91
8462.8395.281.517.355.25
Number of GPUsBatch size per GPUFP32 sentences/secFP16 sentences/secSpeed-up with mixed precisionMulti-gpu weak scaling with FP32Multi-gpu weak scaling with FP16
110-27.69--1.0
410-85.193--3.07
810-142.69--5.1

Note: The respective values for FP32 runs that use a batch size of 10 are not available due to out of memory errors that arise. Batch size of 10 is only available on using FP16.

To achieve these same results, follow the Quick Start Guide outlined above.

NVIDIA DGX-2 (16x V100 32G)

Our results were obtained by running the scripts/run_squad.sh training script in the TensorFlow 19.03-py3 NGC container on NVIDIA DGX-2 with 16x V100 32G GPUs. Performance numbers (in sentences per second) were averaged over an entire training epoch.

Number of GPUsBatch size per GPUFP32 sentences/secFP16 sentences/secSpeed-up with mixed precisionMulti-gpu weak scaling with FP32Multi-gpu weak scaling with FP16
148.8017.431.981.01.0
4433.2256.871.713.783.26
8464.46100.581.567.335.77
164117.83162.291.3813.399.31
Number of GPUsBatch size per GPUFP32 sentences/secFP16 sentences/secSpeed-up with mixed precisionMulti-gpu weak scaling with FP32Multi-gpu weak scaling with FP16
110-28.72--1.0
410-92.73--3.22
810-155.78--5.42
1610-228.75--7.96

Note: The respective values for FP32 runs that use a batch size of 10 are not available due to out of memory errors that arise. Batch size of 10 is only available on using FP16.

To achieve these same results, follow the Quick Start Guide outlined above.

Inference performance results

NVIDIA DGX-1 16G (1x V100 16G)

Our results were obtained by running the scripts/run_squad_inference.sh training script in the TensorFlow 19.03-py3 NGC container on NVIDIA DGX-1 with 1x V100 16G GPUs. Performance numbers (in sentences per second) were averaged over an entire training epoch.

Number of GPUsBatch size per GPUFP32 sentences/secFP16 sentences/secSpeedup
1841.04112.552.74

To achieve these same results, follow the Quick Start Guide outlined above.

NVIDIA DGX-1 32G (1x V100 32G)

Our results were obtained by running the scripts/run_squad_inference.sh training script in the TensorFlow 19.03-py3 NGC container on NVIDIA DGX-1 with 1x V100 32G GPUs. Performance numbers (in sentences per second) were averaged over an entire training epoch.

Number of GPUsBatch size per GPUFP32 sentences/secFP16 sentences/secSpeedup
1836.78118.543.22

To achieve these same results, follow the Quick Start Guide outlined above.

NVIDIA DGX-2 32G (1x V100 32G)

Our results were obtained by running the scripts/run_squad_inference.sh training script in the TensorFlow 19.03-py3 NGC container on NVIDIA DGX-2 with 1x V100 32G GPUs. Performance numbers (in sentences per second) were averaged over an entire training epoch.

Number of GPUsBatch size per GPUFP32 sentences/secFP16 sentences/secSpeedup
1833.95108.453.19

To achieve these same results, follow the Quick Start Guide outlined above.