Model Loading times for CUDA 11+PT1.7.1 > CUDA10.2+PT1.7.1
Based on investigations from @HamidShojanazeri :
https://docs.google.com/document/d/1kt6kg3ebVuc_rSsJwjQGo49EWx0Kiv0BUbt5K62lcsM/edit?usp=sharing
Looking at three profiles of the BERT model, we can see that PT1.7.1 cuda 11 took the longest time to load with ~3 seconds difference compared to PT1.6 cuda 10.2 and ~1 second compared to PT1.7.1 cuda 10.2 .
This could be an issue with PT.
Next steps : Create a simple inference example without Torchserve to validate & report to PyTorch team
@dhanainme @chauhang To better understand the difference between Cuda 11 vs 10.2 and their effect on the performance/ benchmark results of toechserve v0.3, we made a simple script that loads a BERT model and measures the time for following cases: 1. Copying input data from cpu to gpu, 2. Loading the model to gpu and make inference 3. Run 50 inferences to average the time of the inference. The test has been performed on P3.xlarge instance, with latest “trasnformers” version, with following environments, PT 1.6 cuda 10.2, PT 1.7.1 cuda 10.2, PT 1.7.1 cuda 11.0.
The observations show that load time for the model load to cuda + one inference/warmup is ~200ms higher in cuda 11 vs cuda 10.2. Also, the average inference time after the warmup for cuda 11 with PT 1.7.1 is ~ %30 higher compared (21ms) to cuda 10.2 PT 1.6.0 (16ms), and ~%10 higher compared with cuda 10.2 with PT 1.7.1 (19ms). This can impact the performance of Torchserve benchmark both for model latency and throughput benchmark tests which are dependent on inference time.
Model latency measures the inference time on the server side and throughput measures the number requests could be processed in a time unit. So, longer inference time in cuda 11 PT 1.7.1 could result in higher model latency and lower throughput as has been reported in benchmark reports for torchserve v0.3.
Also, the time for copying input tensors from cpu to gpu took ~100 ms in cuda 11 PT 1.7.1 longer compared to cuda 10.2 PT 1.6.0. Interestingly, this took ~200 ms longer in cuda 10.2 PT 1.7.1 compared to cuda 10.2 PT 1.6.0. This does not change the fact that cuda 11 PT1.7.1 being slower affected the benchmark results for torchserve v 0.3 but it may worth deeper investigation/discussion with the Pytorch team. The doc that aggregates the inputs can be found here, https://docs.google.com/document/d/1Cs9prq8vSnMUUijtMUPWRDqF-6tI8Ym1Hdks8-klZ8U/edit?usp=sharing .
The script used for the test and run logs are attached. Cuda_comparison.logs.pdf cuda_comparison.txt
TS 0.4 recommends torch 1.8 + cuda 10.2 since torch 1.7.1/1.8 are not stable on cuda 11.0. So remove this task from TS 0.4.