Article complete

PyTorch Enables Llama 2 & 3 to Run on Smartphones with Zero Code

The update boosts performance for small batch size inference, achieving up to 1.94 times faster speeds compared to the original 

A stylized image of a torch with a flame, set against a yellow background, with a logo resembling a flame in red.

Key takeaways

  • Run Llama 2 and 3 models on smartphones without coding, boosting AI accessibility.
  • Achieve up to 1.94 times faster inference speeds with new Triton FP8 optimizations.
  • Utilize SplitK parallelisation for improved performance on small batch sizes.
  • Leverage CUDA graphs to reduce CPU overhead and enhance model efficiency.
  • Follow provided instructions to deploy Llama models on iOS and Android devices.

Takeaways drafted with AI from the article text.

Keeping up with the focus on delivering AI models to edge devices, the PyTorch team has made it possible to run Llama 2 and 3 models on smartphones without requiring any coding announced on 1st May. 

The researchers presented an optimised Triton FP8 GEMM (General Matrix-Matrix Multiply) kernel TK-GEMM that leverages SplitK parallelisation.

This enhancement boosts performance for small batch size inference, achieving up to 1.94 times faster speeds compared to the original Triton setup, 1.87 times faster than cuBLAS FP8, and 1.71 times faster than cuBLAS FP16 for Llama3-70B tasks on NVIDIA H100 GPUs.

The SplitK parallelisation means creating more work units along the k dimension, which breaks down tasks into smaller pieces and reduces delays, especially for matrices with smaller M values.

Additionally, leveraging CUDA graphs reduces CPU launch overhead, resulting in up to 6.4x speedup for a single attention layer in Llama3-70B models. These optimisations demonstrate significant performance gains and pave the way for further enhancements in FP8 inference.

With the ability to run Llama models on mobile devices, developers can now create apps that harness the power of these advanced language models without the need for extensive coding knowledge. Developers can create intelligent virtual assistants, personalised language learning apps, real-time translation tools, and much more.

The updates also come with instructions for running Llama 2 and 3 on both iOS and Android devices. 

The PyTorch team has utilised the new FP8 datatype, introduced jointly by Nvidia, Arm, and Intel, which serves as a successor to 16-bit floating point types. The FP8 data type consists of two formats: E4M3 and E5M2, which provide significant throughput improvements over their predecessors for Transformer networks.

They have also identified potential future optimisation paths, such as leveraging the TMA (Tensor Memory Accelerator) hardware unit and improving Tensor Core utilisation. These optimisations could lead to even greater performance gains in the future.

Published Updated

Spotted an error? Tell our editors. Read our editorial standards and corrections.

Selling to AI teams? Put your brand in front of the 5M+ people who read AIM every month. Plan a campaign

More in this story

Pytorch · 5 stories
  1. Facebook Releases Open-Source Library For 3D Deep Learning: PyTorch3D
  2. Highlights of the new PyTorch v1.12
  3. You are here: PyTorch Enables Llama 2 & 3 to Run on Smartphones with Zero Code
  4. PyTorch Releases torchtune for Easily Fine-Tuning LLMs
  5. PyTorch Config Change Reduces Docker Image Size by 78%
About the author

Contributor

All stories
Belamy · Daily

The day’s AI news, before your first meeting.