NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
ELECTRA for TensorFlow2
Resource
NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
ELECTRA for TensorFlow2

ELECTRA is method of pre-training language representations which outperforms existing techniques on a wide array of NLP tasks.

The performance measurements in this document were conducted at the time of publication and may not reflect the performance achieved from NVIDIA's latest software release. For the most up-to-date performance measurements, go to NVIDIA Data Center Deep Learning Product Performance.

Benchmarking

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

Training performance benchmark

Training performance benchmarks for both pre-training phases can be obtained by running scripts/benchmark_pretraining.sh. Default parameters are set to run a few training steps for a converging NVIDIA DGX A100 system.

To benchmark training performance with other parameters, run:

bash scripts/benchmark_pretraining.sh <train_batch_size_p1> <amp|tf32|fp32> <xla|no_xla> <num_gpus> <accumulate_gradients=true|false> <gradient_accumulation_steps_p1> <train_batch_size_p2> <gradient_accumulation_steps_p2> <base> 

An example call used to generate throughput numbers:

bash scripts/benchmark_pretraining.sh 88 amp xla 8 true 2 12 4 base

Training performance benchmarks for fine-tuning can be obtained by running scripts/benchmark_squad.sh. The required parameters can be passed through the command-line as described in Training process. The performance information is printed after 200 training iterations.

To benchmark the training performance on a specific batch size, run:

bash scripts/benchmark_squad.sh train <num_gpus> <batch size> <infer_batch_size> <amp|tf32|fp32> <SQuAD version> <path to SQuAD dataset> <results directory> <checkpoint_to_load> <cache_Dir>

An example call used to generate throughput numbers:

bash scripts/benchmark_squad.sh train 8 16

Inference performance benchmark

Inference performance benchmarks fine-tuning can be obtained by running scripts/benchmark_squad.sh. The required parameters can be passed through the command-line as described in Inference process. This script runs one epoch by default on the SQuAD v1.1 dataset and extracts the average performance for the given configuration.

To benchmark the training performance on a specific batch size, run: bash scripts/benchmark_squad.sh train <num_gpus> <batch size> <infer_batch_size> <amp|fp32> <SQuAD version> <path to SQuAD dataset> <results directory> <checkpoint_to_load> <cache_Dir>

An example call used to generate throughput numbers: bash scripts/benchmark_squad.sh eval 8 256

Results

The following sections provide details on how we achieved our performance and accuracy in training and inference. All results are on ELECTRA-base model and on SQuAD v1.1 dataset with a sequence length of 384 unless otherwise mentioned.

Training accuracy results

Pre-training loss curves

Pretraining Loss Curves

Phase 1 is shown by the blue curve and Phase 2 by the grey. Y axis stands for the total loss and x axis for the total steps trained.

Pre-training loss results
DGX SystemGPUsBatch size / GPU (Phase 1 and Phase 2)Accumulation steps (Phase 1 and Phase 2)Final Loss - TF32/FP32Final Loss - mixed precisionTime to train(hours) - TF32/FP32Time to train(hours) - mixed precisionTime to train speedup (TF32/FP32 to mixed precision)
48 x DGX A1008176 and 241 and 38.6868.681.611.1261.43
24 x DGX-2H16176 and 241 and 38.728.675.581.743.20
1 x DGX A1008176 and 2448 and 144--54.8430.471.8
1 x DGX-1 16G888 and 1296 and 288--241.865.13.71
1 x DGX-2 32G16176 and 2424 and 72--109.9729.083.78

In the above table, FP32 and TF32 runs were made at half the batch per GPU and twice the gradient accumulation steps of a run with mixed precision in order to not run out of memory.

The SQuAD fine-tuning scripts by default train on Google's ELECTRA++ base pretrained checkpoint which uses around 10x training dataset (dataset used by XLNet authors) and greater than 5x training steps compared to the training recipe in scripts/run_pretraining.sh. The latter trains and achieves state-of-the-art accuracy on Wikipedia and BookCorpus datasets only.

Fine-tuning accuracy: NVIDIA DGX A100 (8x A100 40GB)

Our results were obtained by running the scripts/run_squad.sh training script in the tensorflow:20.07-tf2-py3 NGC container on NVIDIA DGX A100 (8x A100 40GB) GPUs.

ELECTRA BASE++

GPUsBatch size / GPUAccuracy / F1 - FP32Accuracy / F1 - mixed precisionTime to train - TF32 (sec)Time to train - mixed precision (sec)Time to train speedup (FP32 to mixed precision)
13287.19 / 92.8587.19 / 92.8416997492.27
83286.84 / 92.5786.83 / 92.562632011.30
Fine-tuning accuracy: NVIDIA DGX-1 (8x V100 16GB)

Our results were obtained by running the scripts/run_squad.sh training script in the tensorflow:20.07-tf2-py3 NGC container on NVIDIA DGX-1 with (8x V100 16GB) GPUs.

ELECTRA BASE++

GPUsBatch size / GPU (FP32 : mixed precision)Accuracy / F1 - FP32Accuracy / F1 - mixed precisionTime to train - FP32 (sec)Time to train - mixed precision (sec)Time to train speedup (FP32 to mixed precision)
18 : 1687.36 / 92.8287.32 / 92.74513613783.73
88 : 1687.02 / 92.7387.02 / 92.727303342.18

ELECTRA BASE checkpoint Wikipedia and BookCorpus

GPUsSQuAD versionBatch size / GPU (FP32 : mixed precision)Accuracy / F1 - FP32Accuracy / F1 - mixed precisionTime to train - FP32 (sec)Time to train - mixed precision (sec)Time to train speedup (FP32 to mixed precision)
8v1.18 : 1685.00 / 90.9485.04 / 90.96513613783.73
8v2.08 : 1680.517 / 83.3680.523 / 83.437303342.18
Fine-tuning accuracy: NVIDIA DGX-2 (16x V100 32GB)

Our results were obtained by running the scripts/run_squad.sh training script in the tensorflow:20.07-tf2-py3 NGC container on NVIDIA DGX-2 (16x V100 32G) GPUs.

ELECTRA BASE++

GPUsBatch size / GPUAccuracy / F1 - FP32Accuracy / F1 - mixed precisionTime to train - FP32 (sec)Time to train - mixed precision (sec)Time to train speedup (FP32 to mixed precision)
13287.14 / 92.6986.95 / 92.69447811623.85
163286.95 / 90.5886.93 / 92.483332291.45
Training stability test
Pre-training stability test: NVIDIA DGX A100 (8x A100 40GB)

ELECTRA BASE Wikipedia and BookCorpus

Training stability with 48 x DGX A100, TF32 computations and loss reported after Phase 2:

Accuracy MetricSeed 1Seed 2Seed 3Seed 4Seed 5MeanStandard Deviation
Final Loss8.728.698.718.78.688.70.015
Fine-tuning stability test: NVIDIA DGX-1 (8x V100 16GB)

ELECTRA BASE++

Training stability with 8 GPUs, FP16 computations, batch size of 16 on SQuAD v1.1:

Accuracy MetricSeed 1Seed 2Seed 3Seed 4Seed 5MeanStandard Deviation
Exact Match %86.9986.8186.9587.1087.2687.020.17
f1 %92.792.6692.6592.6192.9792.720.14

Training stability with 8 GPUs, FP16 computations, batch size of 16 on SQuAD v2.0:

Accuracy MetricSeed 1Seed 2Seed 3Seed 4Seed 5MeanStandard Deviation
Exact Match %83.0082.8483.1182.7082.9482.910.15
f1 %85.6385.4885.6985.3185.5785.540.15

Training performance results

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

Our results were obtained by running the scripts/benchmark_squad.sh training script in the tensorflow:20.07-tf2-py3 NGC container on NVIDIA DGX A100 (8x A100 40GB) GPUs. Performance numbers (in items/images per second) were averaged over an entire training epoch.

Pre-training NVIDIA DGX A100 (8x A100 40GB)
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
188 and 176768 and 3841285339551.791.001.00
888 and 17696 and 48128420275121.797.887.87
112 and 242304 and 1152512901711.901.001.00
812 and 24288 and 14451271613471.887.967.88
Fine-tuning NVIDIA DGX A100 (8x A100 40GB)
GPUsBatch size / GPUSequence lengthThroughput - TF32 (sequences/sec)Throughput - mixed precision (sequences/sec)Throughput speedup (TF32 - mixed precision)Weak scaling - TF32Weak scaling - mixed precision
1323841073172.961.001.00
83238482822212.687.747.00
Training performance: NVIDIA DGX-1 (8x V100 16GB)

Our results were obtained by running the scripts/benchmark_squad.sh training scripts in the tensorflow:20.07-tf2-py3 NGC container on NVIDIA DGX-1 with (8x V100 16GB) GPUs. Performance numbers (in sequences per second) were averaged over an entire training epoch.

Pre-training NVIDIA DGX-1 (8x V100 16GB)
GPUsBatch size / GPU (FP32 and FP16)Accumulation steps (FP32 and FP16)Sequence lengthThroughput - FP32(sequences/sec)Throughput - mixed precision(sequences/sec)Throughput speedup (FP32 - mixed precision)Weak scaling - FP32Weak scaling - mixed precision
140 and 881689 and 7681281164443.831.001.00
840 and 88211 and 9612892034753.777.937.83
16 and 124608 and 230451224843.501.001.00
86 and 12576 and 2885121906563.457.927.81
Fine-tuning NVIDIA DGX-1 (8x V100 16GB)
GPUsBatch size / GPU (FP32 : mixed precision)Sequence lengthThroughput - FP32 (sequences/sec)Throughput - mixed precision (sequences/sec)Throughput speedup (FP32 - mixed precision)Weak scaling - FP32Weak scaling - mixed precision
18 : 16384351544.41.001.00
88 : 1638426810513.927.666.82

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

Training performance: NVIDIA DGX-2 (16x V100 32GB)

Our results were obtained by running the scripts/benchmark_squad.sh training scripts in the tensorflow:20.07-tf2-py3 NGC container on NVIDIA DGX-2 with (16x V100 32G) GPUs. Performance numbers (in sequences per second) were averaged over an entire training epoch.

Pre-training NVIDIA DGX-2 (16x V100 32GB)
GPUsBatch size / GPU (FP32 and FP16)Accumulation steps (FP32 and FP16)Sequence lengthThroughput - FP32(sequences/sec)Throughput - mixed precision(sequences/sec)Throughput speedup (FP32 - mixed precision)Weak scaling - FP32Weak scaling - mixed precision
188 and 176768 and 3841281285003.911.001.00
888 and 17696 and 48128101139163.877.907.83
1688 and 17648 and 24128201877733.8515.7715.55
112 and 242304 and 115251227963.551.001.00
812 and 24288 and 1445122137543.547.897.85
1612 and 24144 and 7251242615063.5415.7815.69
Fine-tuning NVIDIA DGX-2 (16x V100 32GB)
GPUsBatch size / GPUSequence lengthThroughput - FP32 (sequences/sec)Throughput - mixed precision (sequences/sec)Throughput speedup (FP32 - mixed precision)Weak scaling - FP32Weak scaling - mixed precision
116384401844.61.001.00
81638431112894.147.777.00
161638462625944.1415.6514.09

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

Inference performance results

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

Our results were obtained by running the scripts/benchmark_squad.sh inferencing benchmarking script in the tensorflow:20.07-tf2-py3 NGC container on NVIDIA DGX A100 (1x A100 40GB) GPU.

Fine-tuning inference on NVIDIA DGX A100 (1x A100 40GB)

FP16

Batch sizeSequence lengthThroughput Avg (sequences/sec)Latency Avg (ms)Latency 90% (ms)Latency 95% (ms)Latency 99% (ms)
13841666.0355.9956.0136.029
256384886276.26274.53275.276275.946
512384886526.5525.014525.788525.788

TF32

Batch sizeSequence lengthThroughput Avg (sequences/sec)Latency Avg (ms)Latency 90% (ms)Latency 95% (ms)Latency 99% (ms)
13841228.2288.1718.1988.221
256384342729.293727.990728.505729.027
5123843501429.3141427.7191428.5501428.550
Inference performance: NVIDIA T4

Our results were obtained by running the scripts/benchmark_squad.sh script in the tensorflow:20.07-tf2-py3 NGC container on NVIDIA Tesla T4 (1x T4 16GB) GPU.

Fine-tuning inference on NVIDIA T4

FP16

Batch sizeSequence lengthThroughput Avg (sequences/sec)Latency Avg (ms)Latency 90% (ms)Latency 95% (ms)Latency 99% (ms)
13845817.41317.29517.34917.395
128384185677.298675.211675.674676.269
2563841691451.3961445.0701447.6541450.141

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

NVIDIA uses cookies to improve your experience on our web site. We and our third-party partners also use cookies and other tools to collect and record information you provide as well as information about your interactions with our websites for performance improvement, analytics, and to assist in marketing efforts. By clicking "Accept All", you consent to our use of cookies and other tools as described in our Cookie Policy. You can manage your cookie settings by clicking on "Manage Settings." By continuing to use this site or by clicking one of the buttons below, you agree to our Terms of Service (which contains important waivers). Please see our Privacy Policy for more information on our privacy practices.