---
title: "Accelerating PyTorch distributed fine-tuning with Intel technologies"
description: "Fine-tuning transformer models can be distributed across a cluster of Intel Ice Lake Xeon CPU servers using the Intel Extension for PyTorch and the oneCCL communication backend, making CPU clusters a cost-effective option for shorter transfer-learning jobs."
url: "https://swe.quest/articles/accelerating-pytorch-distributed-fine-tuning-with-intel-technologies-6164e2f4281509af"
canonical: "https://huggingface.co/blog/accelerating-pytorch"
source: "Hugging Face"
published: "2021-11-19"
difficulty: "medium"
kind: "How-to"
reading_minutes: 9
tags: ["model-training","hardware","performance","python","cloud"]
---

# Accelerating PyTorch distributed fine-tuning with Intel technologies

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2021-11-19, 9 min read, How-to. Original: [https://huggingface.co/blog/accelerating-pytorch](https://huggingface.co/blog/accelerating-pytorch)

## Summary

Fine-tuning transformer models can be distributed across a cluster of Intel Ice Lake Xeon CPU servers using the Intel Extension for PyTorch and the oneCCL communication backend, making CPU clusters a cost-effective option for shorter transfer-learning jobs. The walkthrough builds a 4-node EC2 c6i.16xlarge cluster, installs oneAPI toolkits, PyTorch 1.9, IPEX and torch-ccl, sets oneCCL environment variables, patches run\_glue.py for rank handling, and launches jobs with mpirun. Fine-tuning on GLUE MRPC drops from 7m46s on one node to 4m39s on two (1.7x) and 2m36s on four (3x). The larger QQP task shows similar scaling, from 11h22m to 3h51m on four nodes (2.95x).

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)

## Prerequisites

- PyTorch training basics ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))
- distributed data-parallel training ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))
- MPI basics
- Hugging Face Transformers

## Keywords

PyTorch, oneCCL, Intel Extension for PyTorch, Intel Xeon Ice Lake, BERT, GLUE, Hugging Face Transformers, Amazon EC2

## Related posts

- [Accelerating PyTorch Transformers with Intel Sapphire Rapids - part 2](https://swe.quest/articles/accelerating-pytorch-transformers-with-intel-sapphire-rapids-part-2-c41ef6f6c233e349.md): Hugging Face · 2023-02-06 · Medium · 6 min read · Inference & serving, Hardware, Performance engineering, Python
  Intel Sapphire Rapids CPUs with AMX instructions, combined with Hugging Face Optimum Intel running in bfloat16 with JIT compilation, cut p99 inference latency for DistilBERT, BERT and RoBERTa text classification by roughly 3x compared with vanilla Transformers on Ice Lake.
- [Fine-tuning Stable Diffusion models on Intel CPUs](https://swe.quest/articles/fine-tuning-stable-diffusion-models-on-intel-cpus-a7b97eec2af1f8ba.md): Hugging Face · 2023-07-14 · Medium · 7 min read · Model training, Hardware, Inference & serving, Computer vision
  Stable Diffusion v1.5 can be fine-tuned with textual inversion on a four-node Intel Sapphire Rapids Xeon cluster, using AMX acceleration via Intel Extension for PyTorch, oneCCL for distributed communication, and Accelerate launched under mpirun with 16 tasks.
- [TorchNeuron: running HF models on AWS Trainium is easier than ever](https://swe.quest/articles/torchneuron-running-hf-models-on-aws-trainium-is-easier-than-ever-99ae731bb5ca0252.md): Hugging Face · 2026-10-19 · Medium · 7 min read · Hardware, Model training, Inference & serving, Python
  TorchNeuron is a PyTorch plugin that exposes AWS Trainium as a native \`neuron\` device with eager execution, \`torch.compile\`, and native distributed APIs (DTensor, FSDP2, TP), replacing the PyTorch XLA–based path that required lazy tensors and static graphs.
- [From PyTorch DDP to Accelerate to Trainer, mastery of distributed training with ease](https://swe.quest/articles/from-pytorch-ddp-to-accelerate-to-trainer-mastery-of-distributed-training-with-8ad821e28b1383c4.md): Hugging Face · 2022-10-21 · Medium · 9 min read · Model training, Python, Machine learning
  Converting a basic PyTorch MNIST training script to multi-GPU Distributed Data Parallel training is shown at three levels of abstraction.
- [Introducing 🤗 Accelerate](https://swe.quest/articles/introducing-accelerate-aaf88192c9f162b5.md): Hugging Face · 2021-04-16 · Medium · 7 min read · Model training, Python, Machine learning
  🤗 Accelerate lets PyTorch users keep their own training loops while running the same script on CPU, single or multi-GPU, multi-node, TPU, and with mixed precision, by adding about five lines: an Accelerator object, accelerator.prepare() for model/optimizer/dataloader, and accelerator.backward(). prepare() wraps the model in the right container such as DistributedDataParallel, wraps the optimizer for mixed precision, and shards any sampler's indices per process using synchronized RNGs instead of requiring DistributedSampler.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
