Accelerating PyTorch distributed fine-tuning with Intel technologies
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).
Related posts
- Accelerating PyTorch Transformers with Intel Sapphire Rapids - part 2
Hugging Face mediumAdeptIntel 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. The benchmark uses EC2 c6i.16xlarge and r7iz.16xlarge-metal instances, short (16-token) and long (128-token) inputs, single and batch-of-8 predictions, and libtcmalloc. Optimum needs only a small wrapper around the existing pipeline code, and the results show single-digit millisecond latency on long sequences without a GPU.
- Fine-tuning Stable Diffusion models on Intel CPUs
Hugging Face mediumAdeptStable 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. With only five example images and bf16 mixed precision, 200 training steps take about five minutes; 3,000 steps take about an hour. The walkthrough covers environment setup, the IPEX patch to the diffusers script, oneCCL/tcmalloc environment variables, per-node troubleshooting, and exporting the result to OpenVINO via Optimum Intel for sub-5-second CPU inference.
- TorchNeuron: running HF models on AWS Trainium is easier than ever
Hugging Face mediumAdeptTorchNeuron 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. As a result, Transformers, Diffusers, Accelerate, PEFT and TRL run directly on Trainium, and Hugging Face now recommends them over Optimum Neuron; 89% of the top 100 text-generation architectures work out of the box versus 46% before. Examples cover tensor-parallel generation with a static KV cache, TRL SFT with a TP×FSDP grid via `DistributedConfig`, and TP for Diffusers image pipelines. Practical caveats include keeping shapes static (padding to multiples of 128, disabling Dynamo automatic dynamic shapes) and disabling async weight loading; it enters public beta Oct. 20, 2026.
- From PyTorch DDP to Accelerate to Trainer, mastery of distributed training with ease
Hugging Face mediumAdeptConverting a basic PyTorch MNIST training script to multi-GPU Distributed Data Parallel training is shown at three levels of abstraction. The first is native torch.distributed with process-group setup, a DDP wrapper and the torchrun launcher. The second is Hugging Face Accelerate's Accelerator.prepare, which keeps the loop nearly unchanged, runs on single GPU, multi-GPU or TPU, and shards batches through custom samplers so only one copy of the dataset sits in memory. The third is the Transformers Trainer, which needs only a custom collate function and compute_loss override, and any of these can be launched from Jupyter via notebook_launcher.
- Introducing 🤗 Accelerate
Hugging Face mediumAdept🤗 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. Distributed evaluation uses accelerator.gather plus truncation of padded batches. An `accelerate config` / `accelerate launch` CLI replaces torch.distributed.launch arguments and can target SageMaker.