PyTorch 2.0 Boosts ML Inference on Arm Processors: AWS, Arm & Meta Collaboration Unveils Major Performance Gains
The latest generation of CPUs with built-in specialized instructions has enabled significant performance improvement in machine learning (ML) inference. This advancement results from the collaboration of industry giants AWS, Arm, and Meta, coming together to optimize the performance of PyTorch 2.0 on Arm-based processors.
With the optimization of PyTorch 2.0 on Arm-based processors, AWS Graviton-based instance inference performance has seen a remarkable increase. The performance has improved up to 3.5 times for Resnet50, and up to 1.4 times for BERT, as compared to the previous PyTorch release. In addition, the use of AWS Graviton3-based Amazon Elastic Cloud Compute C7g instances for PyTorch inference on Torch Hub Resnet50 and multiple Hugging Face models has resulted in cost savings of up to 50% and improved latency.
- GEMM kernels
To enhance the performance of PyTorch 2.0, support for Arm Compute Library (ACL) GEMM kernels via OneDNN backend is introduced. With the ACL library, SIMD hardware utilization is improved, and end-to-end inference latencies are reduced.
- bfloat16 support
Efficient deployment of various models is achieved through bfloat16 support in Graviton3. The performance is up to two times faster, as compared to the already existing fp32 model inference, which was without bfloat16 fast math support.
- Primitive caching
For efficient computation, conv, matmul, and inner product operators have implemented primitive caching. This results in the reduction of redundant GEMM kernel initialization and tensor allocation overhead.
How to Take Advantage of the Optimizations
To fully leverage these optimizations, users can deploy AWS Deep Learning Containers (DLCs) on Amazon Elastic Compute Cloud (Amazon EC2) C7g instances or Amazon SageMaker. Using AWS DLCs is easy, as they include optimized builds of PyTorch along with other pre-configured deep learning frameworks.
To begin using AWS DLCs, follow these simple steps:
- Choose an appropriate EC2 C7g instance type or Amazon SageMaker instance according to your elemental requirements.
- Select the latest version of the PyTorch Deep Learning Container compatible with C7g instances.
- Launch the container and start using PyTorch 2.0 optimized for performance on Arm-based processors.
- AWS, Arm, and Meta’s collaboration has optimized PyTorch 2.0 performance for Arm-based processors.
- Increased performance with AWS Graviton-based instance inference for PyTorch 2.0: Up to 3.5 times for Resnet50 and up to 1.4 times for BERT.
- PyTorch inference costs are reduced up to 50% with AWS Graviton3-based Amazon Elastic Cloud Compute C7g instances.
- Improved latency of inference in recent instances.
- The optimization process focuses on GEMM kernels, bfloat16 support, and primitive caching.
- Users can access these optimizations by employing AWS Deep Learning Containers (DLCs) on Amazon EC2 C7g instances or Amazon SageMaker.
To sum up, this innovative collaboration between AWS, Arm, and Meta has led to tremendous performance gains in PyTorch 2.0 for Arm-based processors. With substantial cost savings and improved latency, these optimizations are set to revolutionize the ML inference landscape, providing significant benefits to developers and end-users alike.
*The information this blog provides is for general informational purposes only and is not intended as financial or professional advice. The information may not reflect current developments and may be changed or updated without notice. Any opinions expressed on this blog are the author’s own and do not necessarily reflect the views of the author’s employer or any other organization. You should not act or rely on any information contained in this blog without first seeking the advice of a professional. No representation or warranty, express or implied, is made as to the accuracy or completeness of the information contained in this blog. The author and affiliated parties assume no liability for any errors or omissions.