# Accelerating PyTorch distributed fine-tuning with Intel technologies

huggingface.co · Julien Simon · Nov 19, 2021

**Type:** Tutorial

## Summary

Transfer learning makes CPU-based clusters a viable, cost-effective option for shorter deep learning fine-tuning jobs. To accelerate PyTorch workloads, clusters can leverage Intel Ice Lake architecture featuring AVX-512 and Vector Neural Network Instructions alongside specialized software optimizations. Implementing the Intel Extension for PyTorch and the oneAPI Collective Communications Library (oneCCL) addresses communication bottlenecks across distributed nodes. In demonstrated tests fine-tuning transformer models on GLUE tasks across Amazon EC2 c6i.16xlarge instances, two-node jobs delivered roughly a 1.7x speedup, while four-node setups achieved a 3x speedup. These performance libraries and multi-node configurations maintain consistent scaling across both smaller datasets like MRPC and larger benchmarks like QQP.

## Context

State-of-the-art deep learning models often take a long time to train, but transfer learning involves shorter fine-tuning jobs where CPU clusters can control time and cost compared to traditional GPU training.

## Approach / What changed

Provision a multi-node cluster of Intel Ice Lake CPU instances, install Intel oneAPI toolkits alongside the Intel Extension for PyTorch and oneCCL, adapt training scripts for distributed CCL execution, and run distributed jobs using mpirun.

## Takeaways

- Intel Ice Lake and Cascade Lake CPUs accelerate deep learning operations via hardware features like AVX-512 and Vector Neural Network Instructions (VNNI).
- The Intel oneAPI Collective Communications Library (oneCCL) provides optimized implementations of deep learning communication patterns like all-reduce to reduce networking bottlenecks.
- Scaling distilbert-base-uncased fine-tuning across two and four Intel Xeon nodes produced consistent speedups of approximately 1.7x and 3x on both MRPC and QQP GLUE benchmarks.

**Tags:** [AWS](https://yomu.fyi/topic/aws), [LLMs](https://yomu.fyi/topic/llm), [Machine Learning](https://yomu.fyi/topic/machine-learning), [Performance](https://yomu.fyi/topic/performance), [Python](https://yomu.fyi/topic/python)

[Read original post](https://huggingface.co/blog/accelerating-pytorch)
