Distributed Inference and Fine-tuning of Large Language Models Over The Internet

Alexander Borzunov, Max Ryabinin, Artem Chumachenko, Dmitry Baranchuk, Tim Dettmers, Younes Belkada, Pavel Samygin, Colin Raffel

Abstract

As large language models (LLMs) scale beyond 50 billion parameters, the hardware requirements for inference and fine-tuning have become prohibitive for most researchers. This paper introduces PETALS, a decentralized system designed to run massive models like BLOOM-176B and Llama 2-70B by pooling consumer-grade GPU resources over the internet. By implementing novel fault-tolerant routing and load-balancing algorithms, PETALS achieves inference speeds up to 10x faster than traditional local RAM offloading, providing a viable pathway for collaborative, large-scale AI research.

Introduction

The democratization of Large Language Models (LLMs) is currently bottlenecked by Video RAM (VRAM). Models such as BLOOM (176B) or Llama 2 (70B) require hundreds of gigabytes of VRAM just to load their weights, necessitating expensive multi-node GPU clusters. For researchers without access to such infrastructure, the standard fallback is "parameter offloading"—storing model weights in system RAM or SSDs and swapping them into the GPU layer-by-layer.

However, offloading is inefficient for interactive tasks. Because autoregressive generation requires a full model pass for every single token, the system is constantly bottlenecked by the relatively slow transfer speeds of the PCIe bus or SSD. This paper proposes a different approach: instead of swapping weights from local storage, why not pool idle consumer GPUs across the internet and pass intermediate activations between them? PETALS addresses the challenges of this decentralized approach, specifically focusing on high latency and the inherent unreliability of volunteer nodes.

Methodology: The PETALS Architecture

PETALS utilizes a decentralized pipeline parallelism framework. The model is partitioned into blocks, which are distributed across a network of volunteer servers. A client initiates a request by passing their input through this chain of servers. To maintain performance and stability in a volatile internet environment, the system introduces several key technical innovations:

1. Fault-Tolerant Dual Caching

Standard LLM inference relies on caching past attention keys and values (KV cache) on the GPU. In a decentralized setup, if a server hosting a specific layer disconnects, its local KV cache is lost, typically causing the entire inference process to fail. PETALS implements a dual cache system: while servers maintain the standard KV cache, the client also caches the intermediate activations sent to each pipeline stage. If a node failure is detected, the client dynamically reroutes to a new server and provides the necessary cached activations to instantly reconstruct the lost attention state.

2. Shortest Path Routing and Load Balancing

To combat the latency of the public internet, PETALS employs a lifelong pathfinding algorithm (D* Lite). Clients continuously monitor network latency and server compute speeds in the background, ensuring that data is always routed through the most efficient available chain of GPUs. Furthermore, servers use a greedy load-balancing algorithm to decide which model layers to host. By monitoring the network for bottlenecks (layers with the fewest hosts), servers can automatically swap to hosting underrepresented layers, maximizing total system throughput.

3. Decoupled Fine-Tuning

For fine-tuning, PETALS supports Parameter-Efficient Fine-Tuning (PEFT) techniques like LoRA or soft prompts. The architecture is designed such that the client holds the small, trainable weights, while the volunteer servers only perform forward and backward passes on the frozen base model. This keeps the servers "stateless" regarding the specific task, allowing a single server to support multiple users simultaneously without memory bloat.

Evaluation and Results

The authors evaluated PETALS using a geo-distributed setup spanning Europe and North America, utilizing a heterogeneous mix of consumer GPUs (e.g., RTX 3060, 2080Ti, A4000). To ensure that the 8-bit quantization required to fit layers on consumer hardware did not degrade performance, the system was tested on zero-shot benchmarks including HellaSwag, LAMBADA, and WinoGrande.

Key Findings

  • Throughput: PETALS achieved speeds of 1 to 2 tokens per second for BLOOM-176B and Llama 2-70B over standard internet connections (100 Mbit/s to 1 Gbit/s).
  • Efficiency: This distributed approach proved to be approximately 10x faster than the theoretical best-case scenario for local CPU RAM offloading.
  • Resilience: In simulations with a 5% mid-generation server failure rate, the fault-tolerant dual caching algorithm maintained high throughput, whereas traditional methods failed to complete the generation.

Discussion and Limitations

While PETALS significantly lowers the barrier to entry for LLM research, it introduces unique challenges regarding privacy and security. Because servers process intermediate activations, there is a theoretical risk that sensitive client data could be reverse-engineered from these embeddings. Currently, users with sensitive data must limit their routing to trusted nodes.

Additionally, the system is vulnerable to malicious nodes that might return incorrect outputs to corrupt inference or gradients. Future work aims to implement validator nodes to identify and ban malicious actors, as well as exploring secure multi-party computation and incentive structures (such as reward points) to ensure a stable supply of GPU resources.

Conclusion

PETALS demonstrates that the public internet can serve as a viable backbone for running the world's largest language models. By prioritizing network communication over local disk swapping and implementing robust fault tolerance, the system enables researchers to run 100B+ parameter models with performance that rivals or exceeds local high-end workstations.

Summary updated

BibTeX
@inproceedings{borzunov2023distributed,
  author = {Alexander Borzunov and Max Ryabinin and Artem Chumachenko and Dmitry Baranchuk and Tim Dettmers and Younes Belkada and Pavel Samygin and Colin Raffel},
  title = {{Distributed Inference and Fine-tuning of Large Language Models Over The Internet}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=XmN7ZNbUAe},
}
Figure