NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
GNMT v2 for PyTorch
Resource
NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
GNMT v2 for PyTorch

The GNMT v2 model is an improved version of the first Google's Neural Machine Translation System with a modified attention mechanism.

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 is launched on batches of text data, different batches have different sequence lengths (number of tokens in the longest sequence). Sequence length and batch efficiency (ratio of non-pad tokens to total number of tokens) affect performance of the training, therefore it's recommended to run the training on a large chunk of training dataset to get a stable and reliable average training performance. Ideally at least one full epoch of training should be launched to get a good estimate of training performance.

The following commands will launch one epoch of training:

To launch mixed precision training on 1, 4 or 8 GPUs, run:

python3 -m torch.distributed.launch --nproc_per_node=<#GPUs> train.py --seed 2 --train-global-batch-size 1024 --epochs 1 --math fp16

To launch mixed precision training on 16 GPUs, run:

python3 -m torch.distributed.launch --nproc_per_node=16 train.py --seed 2 --train-global-batch-size 2048 --epochs 1 --math fp16

Change --math fp16 to --math fp32 to launch single precision training (for NVIDIA Volta and NVIDIA Turing architectures) or to --math tf32 to launch TF32 training with Tensor Cores (for NVIDIA Ampere architecture).

After the training is completed, the train.py script prints a summary to standard output. Performance results are printed in the following format:

(...)
0: Performance: Epoch: 0	Training: 418926 Tok/s	Validation: 1430828 Tok/s
(...)

Training: 418926 Tok/s represents training throughput averaged over an entire training epoch and summed over all GPUs participating in the training.

Inference performance benchmark

The inference performance and accuracy benchmarks require a checkpoint from a fully trained model.

Command to launch the inference accuracy benchmark on NVIDIA Volta or on NVIDIA Turing architectures:

python3 translate.py \
  --model gnmt/model_best.pth \
  --input data/wmt16_de_en/newstest2014.en \
  --reference data/wmt16_de_en/newstest2014.de \
  --output /tmp/output \
  --math fp16 fp32 \
  --batch-size 128 \
  --beam-size 1 2 5 \
  --tables

Command to launch the inference accuracy benchmark on NVIDIA Ampere architecture:

python3 translate.py \
  --model gnmt/model_best.pth \
  --input data/wmt16_de_en/newstest2014.en \
  --reference data/wmt16_de_en/newstest2014.de \
  --output /tmp/output \
  --math fp16 tf32 \
  --batch-size 128 \
  --beam-size 1 2 5 \
  --tables

Command to launch the inference throughput and latency benchmarks on NVIDIA Volta or NVIDIA Turing architectures:

python3 translate.py \
  --model gnmt/model_best.pth \
  --input data/wmt16_de_en/newstest2014.en \
  --reference data/wmt16_de_en/newstest2014.de \
  --output /tmp/output \
  --math fp16 fp32 \
  --batch-size 1 2 4 8 32 128 512 \
  --repeat 1 1 1 1 2 8 16 \
  --beam-size 1 2 5 \
  --warmup 5 \
  --tables

Command to launch the inference throughput and latency benchmarks on NVIDIA Ampere architecture:

python3 translate.py \
  --model gnmt/model_best.pth \
  --input data/wmt16_de_en/newstest2014.en \
  --reference data/wmt16_de_en/newstest2014.de \
  --output /tmp/output \
  --math fp16 tf32 \
  --batch-size 1 2 4 8 32 128 512 \
  --repeat 1 1 1 1 2 8 16 \
  --beam-size 1 2 5 \
  --warmup 5 \
  --tables

Results

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

Training accuracy results

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

Our results were obtained by running the train.py script with the default batch size = 128 per GPU in the pytorch-20.06-py3 NGC container on NVIDIA DGX A100 with 8x A100 40GB GPUs.

Command to launch the training:

python3 -m torch.distributed.launch --nproc_per_node=<#GPUs> train.py --seed 2 --train-global-batch-size 1024 --math fp16

Change --math fp16 to --math tf32 to launch TF32 training with Tensor Cores.

GPUsBatch Size / GPUAccuracy - TF32 (BLEU)Accuracy - Mixed precision (BLEU)Time to Train - TF32 (minutes)Time to Train - Mixed precision (minutes)Time to Train Speedup (TF32 to Mixed precision)
812824.4624.6034.722.71.53

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

Training accuracy: NVIDIA DGX-1 (8x V100 16GB)

Our results were obtained by running the train.py script with the default batch size = 128 per GPU in the pytorch-20.06-py3 NGC container on NVIDIA DGX-1 with 8x V100 16GB GPUs.

Command to launch the training:

python3 -m torch.distributed.launch --nproc_per_node=<#GPUs> train.py --seed 2 --train-global-batch-size 1024 --math fp16

Change --math fp16 to --math fp32 to launch single precision training.

GPUsBatch Size / GPUAccuracy - FP32 (BLEU)Accuracy - Mixed precision (BLEU)Time to Train - FP32 (minutes)Time to Train - Mixed precision (minutes)Time to Train Speedup (FP32 to Mixed precision)
112824.4124.42810.0224.03.62
412824.4024.33218.269.53.14
812824.4524.38112.038.62.90

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

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

Our results were obtained by running the train.py script with the default batch size = 128 per GPU in the pytorch-20.06-py3 NGC container on NVIDIA DGX-2H with 16x V100 32GB GPUs.

To launch mixed precision training on 16 GPUs, run:

python3 -m torch.distributed.launch --nproc_per_node=16 train.py --seed 2 --train-global-batch-size 2048 --math fp16

Change --math fp16 to --math fp32 to launch single precision training.

GPUsBatch Size / GPUAccuracy - FP32 (BLEU)Accuracy - Mixed precision (BLEU)Time to Train - FP32 (minutes)Time to Train - Mixed precision (minutes)Time to Train Speedup (FP32 to Mixed precision)
1612824.4124.3852.119.42.69

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

TrainingLoss

Training stability test

The GNMT v2 model was trained for 6 epochs, starting from 32 different initial random seeds. After each training epoch, the model was evaluated on the test dataset and the BLEU score was recorded. The training was performed in the pytorch-20.06-py3 Docker container on NVIDIA DGX A100 with 8x A100 40GB GPUs. The following table summarizes the results of the stability test.

In the following table, the BLEU scores after each training epoch for different initial random seeds are displayed.

EpochAverageStandard deviationMinimumMaximumMedian
119.9590.23819.41020.39019.970
221.7720.29320.96022.28021.820
322.4350.26421.74022.87022.465
423.1670.16622.87023.62023.195
524.2330.14923.82024.53024.235
624.4160.13124.14024.66024.390

Training throughput results

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

Our results were obtained by running the train.py training script in the pytorch-20.06-py3 NGC container on NVIDIA DGX A100 with 8x A100 40GB GPUs. Throughput performance numbers (in tokens per second) were averaged over an entire training epoch.

GPUsBatch size / GPUThroughput - TF32 (tok/s)Throughput - Mixed precision (tok/s)Throughput speedup (TF32 to Mixed precision)Strong Scaling - TF32Strong Scaling - Mixed precision
1128832141409091.6931.0001.000
41282785764631441.6633.3483.287
81285199528220241.5816.2485.834

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

Training throughput: NVIDIA DGX-1 (8x V100 16GB)

Our results were obtained by running the train.py training script in the pytorch-20.06-py3 NGC container on NVIDIA DGX-1 with 8x V100 16GB GPUs. Throughput performance numbers (in tokens per second) were averaged over an entire training epoch.

GPUsBatch size / GPUThroughput - FP32 (tok/s)Throughput - Mixed precision (tok/s)Throughput speedup (FP32 to Mixed precision)Strong Scaling - FP32Strong Scaling - Mixed precision
112821860764383.4971.0001.000
4128802242491683.1063.6703.260
81281541684478322.9057.0535.859

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

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

Our results were obtained by running the train.py training script in the pytorch-20.06-py3 NGC container on NVIDIA DGX-2H with 16x V100 32GB GPUs. Throughput performance numbers (in tokens per second) were averaged over an entire training epoch.

GPUsBatch size / GPUThroughput - FP32 (tok/s)Throughput - Mixed precision (tok/s)Throughput speedup (FP32 to Mixed precision)Strong Scaling - FP32Strong Scaling - Mixed precision
112825583878293.4331.0001.000
4128914002906403.1803.5733.309
81281766165220082.9566.9045.943
1612835179210108802.87413.75111.510

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

Inference accuracy results

Inference accuracy: NVIDIA A100 40GB

Our results were obtained by running the translate.py script in the pytorch-20.06-py3 NGC Docker container with NVIDIA A100 40GB GPU. Full command to launch the inference accuracy benchmark was provided in the Inference performance benchmark section.

Batch SizeBeam SizeAccuracy - TF32 (BLEU)Accuracy - FP16 (BLEU)
128123.0723.07
128223.8123.81
128524.4124.43
Inference accuracy: NVIDIA Tesla V100 16GB

Our results were obtained by running the translate.py script in the pytorch-20.06-py3 NGC Docker container with NVIDIA Tesla V100 16GB GPU. Full command to launch the inference accuracy benchmark was provided in the Inference performance benchmark section.

Batch SizeBeam SizeAccuracy - FP32 (BLEU)Accuracy - FP16 (BLEU)
128123.0723.07
128223.8123.79
128524.4024.43
Inference accuracy: NVIDIA T4

Our results were obtained by running the translate.py script in the pytorch-20.06-py3 NGC Docker container with NVIDIA Tesla T4. Full command to launch the inference accuracy benchmark was provided in the Inference performance benchmark section.

Batch SizeBeam SizeAccuracy - FP32 (BLEU)Accuracy - FP16 (BLEU)
128123.0723.08
128223.8123.80
128524.4024.39

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

Inference throughput results

Tables presented in this section show the average inference throughput (columns Avg (tok/s)) and inference throughput for various confidence intervals (columns N% (ms), where N denotes the confidence interval). Inference throughput is measured in tokens per second. Speedups reported in FP16 subsections are relative to FP32 (for NVIDIA Volta and NVIDIA Turing) and relative to TF32 (for NVIDIA Ampere) numbers for corresponding configuration.

Inference throughput: NVIDIA A100 40GB

Our results were obtained by running the translate.py script in the pytorch-20.06-py3 NGC Docker container with NVIDIA A100 40GB. Full command to launch the inference throughput benchmark was provided in the Inference performance benchmark section.

FP16

Batch SizeBeam SizeAvg (tok/s)Speedup90% (tok/s)Speedup95% (tok/s)Speedup99% (tok/s)Speedup
111291.61.0311195.71.0291165.81.0291104.71.030
12882.71.019803.41.015769.21.015696.71.017
15848.31.042753.01.037715.01.043636.41.033
212060.51.0341700.81.0321621.81.0321487.41.022
221445.71.0261197.61.0241132.51.0231043.71.033
251402.31.0631152.41.0561100.51.053992.91.053
413465.61.0462838.31.0402672.71.0432392.81.043
422425.41.0412002.51.0281898.31.0331690.21.028
452364.41.0751930.01.0671822.01.0651626.11.058
816151.11.0995078.01.0874786.51.0964206.91.090
824241.91.0753494.11.0663293.61.0662970.91.064
854117.71.1183430.91.1033224.51.1042833.51.110
32118830.41.14716210.01.15215563.91.13813973.21.135
32212698.21.13310812.31.11410256.11.1459330.21.101
32511802.61.3559998.81.3189671.61.3299058.41.335
128153394.51.35048867.61.34246898.51.41440670.61.305
128234876.41.48331687.41.49130025.41.50527677.11.421
128528201.31.98625660.51.99724306.01.96723326.22.007
5121119675.31.904112400.51.971109694.81.927108781.31.919
512274514.72.12669578.92.20969348.12.21069253.72.212
512547003.22.76043348.22.89343080.32.88442878.42.881
Inference throughput: NVIDIA T4

Our results were obtained by running the translate.py script in the pytorch-20.06-py3 NGC Docker container with NVIDIA T4. Full command to launch the inference throughput benchmark was provided in the Inference performance benchmark section.

FP16

Batch SizeBeam SizeAvg (tok/s)Speedup90% (tok/s)Speedup95% (tok/s)Speedup99% (tok/s)Speedup
111133.81.2661059.11.2531036.61.251989.51.242
12793.91.169728.31.165698.11.163637.11.157
15766.81.343685.61.335649.31.335584.11.318
211759.81.2331461.61.2391402.31.2421302.11.242
221313.31.1861088.71.1851031.61.180953.21.178
251257.21.3011034.11.316990.31.313886.31.265
412974.01.2612440.31.2552294.61.2572087.71.261
422204.71.3201826.31.2831718.91.2601548.41.260
452106.11.3401727.81.3451625.71.3531467.71.346
815076.61.4234207.91.3673904.41.3603475.31.355
823761.71.3113108.11.2852931.61.3002628.71.300
853578.21.6602998.21.6142812.11.6092447.61.523
32114637.81.63612702.51.64412070.31.63411036.91.647
32210627.31.8189198.31.8188431.61.7258000.01.773
3258205.72.5987117.62.4766825.22.4976293.22.437
128133800.52.75530824.52.81627685.22.66126580.92.694
128220829.42.79518665.22.77817372.12.63916820.52.821
128511753.93.30910658.13.27310308.73.2059630.73.328
512144474.63.32740108.13.39439816.63.37839708.03.381
512226057.93.29523197.33.29423019.83.28422951.43.284
512512161.53.42810777.53.41810733.13.41410710.53.420

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

Inference latency results

Tables presented in this section show the average inference latency (columns Avg (ms)) and inference latency for various confidence intervals (columns N% (ms), where N denotes the confidence interval). Inference latency is measured in milliseconds. Speedups reported in FP16 subsections are relative to FP32 (for NVIDIA Volta and NVIDIA Turing) and relative to TF32 (for NVIDIA Ampere) numbers for corresponding configuration.

Inference latency: NVIDIA A100 40GB

Our results were obtained by running the translate.py script in the pytorch-20.06-py3 NGC Docker container with NVIDIA A100 40GB. Full command to launch the inference latency benchmark was provided in the Inference performance benchmark section.

FP16

Batch SizeBeam SizeAvg (ms)Speedup90% (ms)Speedup95% (ms)Speedup99% (ms)Speedup
1144.691.03274.041.03584.611.03499.141.042
1264.761.020105.181.018118.921.019139.421.023
1567.061.043107.561.049121.821.054143.851.054
2156.571.03485.591.03792.551.038107.591.046
2280.221.027119.221.027128.431.030150.061.028
2582.541.063121.371.067132.351.069156.341.059
4167.291.04792.691.048100.081.056112.631.064
4295.861.041129.831.040139.481.044162.341.045
4598.341.075133.831.076142.701.068168.301.075
8175.601.09997.871.103104.131.099117.401.102
82109.381.074137.711.079147.691.069168.791.065
85112.711.116143.501.104153.171.118172.601.113
32198.401.146117.021.153123.421.150129.011.128
322145.871.133171.711.159184.011.127188.641.141
325156.821.357189.101.374194.951.392196.651.419
1281137.971.350150.041.348151.521.349154.521.434
1282211.581.484232.961.490237.461.505239.861.567
1285261.441.990288.542.017291.632.052298.732.136
5121245.931.906262.511.998264.241.999265.232.000
5122395.612.129428.542.219431.582.224433.862.227
5125627.212.767691.722.878696.012.895702.132.887
Inference latency: NVIDIA T4

Our results were obtained by running the translate.py script in the pytorch-20.06-py3 NGC Docker container with NVIDIA T4. Full command to launch the inference latency benchmark was provided in the Inference performance benchmark section.

FP16

Batch SizeBeam SizeAvg (ms)Speedup90% (ms)Speedup95% (ms)Speedup99% (ms)Speedup
1151.081.26184.821.25497.451.251114.61.257
1272.051.168117.411.165132.331.170155.81.174
1574.201.345119.451.352135.071.354160.31.354
2166.311.232100.901.232108.521.235126.91.238
2288.351.185131.471.188141.461.185164.71.191
2592.121.305136.301.310148.661.309174.81.320
4178.541.260108.531.256117.191.259133.71.259
42105.541.315142.741.317154.361.307178.71.303
45110.431.351150.621.388161.611.397191.21.427
8191.651.418117.921.421126.601.405144.01.411
82123.391.315156.001.337167.341.347193.41.340
85129.691.666165.011.705178.181.723200.31.765
321126.531.641153.231.689159.581.692167.01.700
322174.371.822209.041.899219.591.877228.61.878
325226.152.598277.382.636290.272.648299.42.664
1281218.292.755238.942.826243.182.843267.12.828
1282354.832.796396.632.832410.532.803433.22.866
1285628.323.311699.573.353723.983.323771.03.337
5121663.073.330748.623.388753.203.388758.03.378
51221134.043.2951297.853.2831302.253.3041306.93.308
51252428.823.4282771.723.4152801.323.4272817.63.422

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