---
title: "Distributed Inference and Fine-tuning of Large Language Models"
description: "Petals runs large language models across Internet-connected GPUs, using cached activations to recover from failures and keep text…"
canonical: "https://research.elamur.ai/free/en/papers/borzunov-2023-distributed-inference-fine-tuning-large/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/borzunov-2023-distributed-inference-fine-tuning-large/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2023](https://md.research.elamur.ai/free/en/papers/2023/) / Distributed Inference and Fine-tuning of Large Language Models Over The Internet

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

Paper · 2023 · Alexander Borzunov, Max Ryabinin, Artem Chumachenko et al.

**Authors:** Alexander Borzunov, [Max Ryabinin](https://md.research.elamur.ai/free/en/authors/max-ryabinin/), Artem Chumachenko, Dmitry Baranchuk, [Tim Dettmers](https://md.research.elamur.ai/free/en/authors/tim-dettmers/), [Younes Belkada](https://md.research.elamur.ai/free/en/authors/younes-belkada/), Pavel Samygin and [Colin Raffel](https://md.research.elamur.ai/free/en/authors/colin-raffel/) · **Year:** 2023 · **Venue:** NeurIPS 2023 · **Licence:** [arXiv — non-exclusive distribution license (arXiv OAI)](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

[**30** citations OpenAlex, 2026-10-14](https://openalex.org/works?filter=cites:W7133215307) · [NeurIPS 2023](https://openalex.org/S4363606243) · [licence](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

- [PDF](https://arxiv.org/pdf/2312.08361)
- [DOI 10.52202/075280-0540](https://doi.org/10.52202/075280-0540)
- [arXiv 2312.08361](https://arxiv.org/abs/2312.08361)
- [OpenAlex](https://openalex.org/W7133215307)

Citations: OpenAlex, 2026-10-14.

## Summary

Releasing the weights of a powerful text generator makes the software available, but running it can still require more accelerator memory than a research group has. The authors ask whether several groups can pool the GPUs they already own and generate text fast enough for someone waiting at a keyboard. Their answer is Petals, a decentralized system that divides a pretrained network into stages and runs each stage on a device that has room for it. The key observation is that a generation step can send a compact numerical representation of the current token over the Internet while leaving the much larger weights in place. In the workloads the paper examines, that can take less time than repeatedly loading the weights from local memory. The study concerns some of the largest openly released [large language models](https://md.research.elamur.ai/free/en/concepts/large-language-models/).

A device that leaves midway through an answer takes some of the generation state with it. Petals prepares for this by keeping complementary records. Each server stores the attention information its layers need to process subsequent tokens. The client records the inputs that those layers have already processed. If a server goes away, the client sends those inputs to a replacement that can rebuild the missing state. A separate procedure helps keep replacements available by directing servers towards the portions of the network with the least capacity. Together, these mechanisms let the system respond to a lost connection during one request and adjust to longer-lasting changes in the pool of devices.

The paper tests generation and parameter-efficient adaptation using [Llama 2](https://md.research.elamur.ai/free/en/papers/touvron-2023-llama-2-open-foundation-fine/) (70B) and [BLOOM](https://md.research.elamur.ai/free/en/papers/workshop-2022-bloom-176b-parameter-open-access/) (176B). It reports interactive generation up to 10× faster than parameter offloading, in which a local accelerator repeatedly loads weights from another tier of storage. The generation advantage also appears in a deployment spanning Europe and North America, where the servers differ in GPU capability. With many tokens processed together, the comparison depends more on network capacity. Offloading can be competitive for large batches on a slow or high-latency link. To support adaptation, Petals lets the client update a small set of trainable values while servers provide the forward and backward computations through the shared network. This design supports multiple users doing their own [fine-tuning](https://md.research.elamur.ai/free/en/concepts/fine-tuning/).

The experiments establish different things about different parts of the design. Injected failures test whether a request can continue after a pipeline stage loses its state. Controlled links show how generation and batch processing respond to bandwidth and delay. A simulation tests whether the server pool can maintain coverage as participants come and go. The Internet deployment tests whether these mechanisms can support a geographically dispersed installation in practice. A separate issue is trust. Remote servers process a client’s intermediate representations, and the authors identify the possibility that a server handling early layers can recover information about the input.

## Deep dive: Distributed Inference and Fine-tuning of Large Language Models Over The Internet

Petals runs large language models across Internet-connected GPUs, using cached activations to recover from failures and keep text generation responsive. · about 39 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### Open weights still need somewhere to run

A pretrained generator is useful to researchers in several ways. They can change a prompt and compare the responses, include examples in the input to show the desired behavior, or adapt the system on task-specific examples. These uses make access to trained weights valuable even to groups with no intention of repeating pretraining. The paper places that demand alongside earlier observations that text predictors improve as their scale increases. The useful checkpoints were becoming bigger at the same time that more researchers had reasons to run them. The authors relate this trend to prior work on [scaling laws](https://md.research.elamur.ai/free/en/concepts/scaling-laws/).

For a sense of the hardware requirement, the authors give the examples of OPT-175B and BLOOM-176B. They put the accelerator memory needed for inference with these checkpoints at over 350 GB and explain that updating the weights would require more. Accelerator memory is the working storage directly available to the GPU. An operation can fit within the computational capacity of a device while demanding more working storage than the device has. In this case, fitting the parameters is a prerequisite for using the accelerator’s arithmetic capacity effectively. The open release of a checkpoint such as [OPT](https://md.research.elamur.ai/free/en/papers/zhang-2022-opt-open-pre-trained-transformer/) therefore leaves a substantial practical barrier.

The paper is concerned with the cost of running an already trained network. Inference means using its existing weights to calculate an output. An interactive generation request first processes the user’s input and then repeatedly predicts a continuation. In-context learning uses the same prediction procedure, with examples supplied as part of the input. Fine-tuning involves a backward pass as well as a forward pass, because a loss on the task provides a signal for adjusting trainable values. These uses differ in where the work occurs and how long the user waits for each result. The earlier prompting work the authors discuss includes [Language Models are Few-Shot Learners](https://md.research.elamur.ai/free/en/papers/brown-2020-language-models-few-shot-learners/).

#### Splitting the work across accelerators

Prior distributed systems already divided neural network computations across devices. The general approach discussed in the paper, model parallelism, assigns different parameters and their associated computations to different accelerators. Intermediate numerical outputs, called activations, pass between devices so that the separate computations compose into one forward pass. Exactly where that division falls determines how frequently the devices must exchange data. This is why the topology of a machine or cluster matters as much as the sum of its GPU memory. The problem belongs to [GPU and parallel computing](https://md.research.elamur.ai/free/en/topics/gpu-parallel-computing/).

In tensor parallelism, devices divide the work inside a layer. A device might evaluate part of the layer’s neurons, for instance, and share its results so that all participants can go on to the next layer. The same general computation runs on each shard of the weights. That symmetry suits the communication mechanisms used in tightly connected systems. The cost is frequent coordination. If progress through every layer depends on an exchange among the participating devices, network delays recur at each layer. The paper traces this tradeoff through earlier work on [parallelizing convolutional networks](https://md.research.elamur.ai/free/en/papers/krizhevsky-2014-one-weird-trick-parallelizing-convolutional/).

Pipeline parallelism places whole layers together on each device. A server completes its assigned layers, then passes the resulting activations to the next server. During a backward pass, the gradient travels in the reverse direction. This placement creates fewer opportunities for cross-device communication within a forward pass. It also creates idle time if a stage finishes one piece of work and has to wait for its next input. Training systems address that with microbatches, which are subdivisions of a larger batch. Different stages can work on different microbatches at the same time. Some idle time remains as work enters and leaves the pipeline.

The authors describe cluster training systems that combine these approaches. Tensor parallelism can exploit the close connections within a multi-GPU machine, while a pipeline connects stages on separate machines. They also discuss earlier efforts to train with pooled or idle devices. Such work made decentralized computation a reasonable starting point. The new question was how to serve a live generation request when the participating devices could be far apart, vary in speed and disappear partway through processing. An example of the earlier cluster setting is [Megatron-LM](https://md.research.elamur.ai/free/en/papers/narayanan-2021-efficient-large-scale-language-model/).

#### Using cheaper storage on a single machine

Parameter offloading approaches the memory problem from the other direction. Most of the weights live in CPU RAM or on an SSD, and the accelerator receives the layers it is about to use. A device that can hold only a small portion of the network can still evaluate the whole thing if the rest fits in the cheaper storage. The limiting resource then becomes the rate at which weights can move to the accelerator and how much computation can be done with each set of weights before it is displaced. The paper discusses techniques that overlap a transfer with computation and, in some cases, distribute the storage for offloaded weights across devices.

Batch size changes the economics of that transfer. Loading a layer for many inputs lets those inputs share the cost of moving the weights. A system can achieve useful aggregate throughput this way even if any individual sequence takes a long time to finish. Interactive use puts the emphasis on the wait for the next token in an individual sequence. During generation, the next step depends on the token just selected. A local accelerator using offloading must repeatedly cycle through the network for a request that makes only a small amount of progress on each cycle. Larger batches help a different workload.

The design question is therefore about which objects to move, and when. Offloading moves parameters close to a local processor for each pass. A pipeline leaves those parameters on the processors that use them and sends intermediate activations between them. An Internet connection brings a delay every time the request crosses from one stage to the next. For a long answer, the same sequence of crossings happens repeatedly. The proposal depends on keeping each transmission small and making the useful work survive interruptions. Routing alone solves only the problem of finding devices that can currently run the required layers.

### The method, step by step

#### Follow a token through the pipeline

The network is a stack of blocks. Each block transforms a set of numerical representations and passes its output to the next block. The units used by Petals for placement are whole blocks from the architecture introduced in [Attention Is All You Need](https://md.research.elamur.ai/free/en/papers/vaswani-2017-attention-all-need/). A block typically combines attention, which lets positions draw on information at other positions, with feed-forward computation, normalization and a residual connection that carries information from the block’s input into its output. This organization provides a natural place to divide work between servers in a [transformer](https://md.research.elamur.ai/free/en/concepts/transformer/).

The client is the process controlled by the person making the request. It keeps the input and output embedding layers. The input side converts token IDs to numerical vectors, and the output side uses the final representations to score possible next tokens. In BLOOM-176B, these client-held layers account for less than 3% of the weights. The servers keep the block weights and run the intervening computations. Each server takes a consecutive span of blocks so that computations inside that span can proceed on the same device. A machine can participate as a client, a server, or both.

To begin a request, the client finds servers whose spans can cover the network in order. The path can depend on the client’s location and the devices available at the time. As the request proceeds, the first stage takes the embeddings supplied by the client. Each later stage takes the representation produced by the preceding stage. The final representation comes back to the client, which selects a token and starts the next generation step. The server arrangement can be changed during the request if part of that path becomes unavailable.

How Petals generates tokens and recovers a failed stage The steps in order.

The distinction between blocks and stages matters. A block is part of the network’s architecture. A stage is a group of consecutive blocks executed at a particular point in the current pipeline. A server can offer a longer interval than a given request needs, and the client can ask it to process a subinterval. When several adjacent blocks fit on one GPU, the server can execute them before handing anything to another machine. Increasing the number of blocks that fit locally therefore reduces the number of remote handoffs needed to cover the stack.

#### Understand what has to be repeated

A training pass can process a sequence as a group. In generation, the value of the next token is available only once the current prediction has gone through the network and the client has selected a continuation. Petals cannot turn this sequence of dependent predictions into an ordinary parallel batch. Its design instead reduces the cost of the work on each step. The paper first expresses the communication burden for processing a training sequence as follows.

```
O(n)
```

Here, O denotes the order of growth, and n is the number of layers in the paper’s model-parallel accounting. The expression describes communication rounds as the number of layers grows. All positions of a training sequence can move through a layer together. The notation leaves out constants and details such as how many layers are grouped on a given server.

```
O(n · t)
```

Here, n again denotes the number of layers, t is the number of tokens generated, and the centered dot means multiplication. O expresses the growth of the cost. As the generation length increases, the repeated trips through the network account for the factor t. The authors use the same order of growth to describe the repeated layer loading required by parameter offloading during generation. These are counts of repeated operations. Their elapsed time depends on what is transferred and on the cost of making each transfer.

Each layer also has to attend to information about previous tokens. Attention uses keys and values derived from earlier positions. The key participates in deciding which positions are relevant, and the value carries information that can contribute to the current result. At step t, the number of preceding positions is written as follows.

```
t − 1
```

The symbol t is the current step and the minus sign subtracts the current position from the count through that step. If keys and values for preceding positions are already on the GPU that produced them, the new step can use that saved state. Otherwise, the server has to obtain or reconstruct the information. A cache is the saved copy that makes the first route possible.

The storage burden is appreciable even for a single sequence. For the paper’s example of GPT-3 or OPT-175B, with 96 layers of 12,288 units each, the half-precision attention cache for a 2048-token sequence needs 9.6 GB of GPU memory. The authors consider moving such a cache to RAM or SSD and discuss the transfer penalty for bringing it back. They also consider rebuilding it from scratch each time. The following expression gives the standard attention scaling used in their explanation.

```
O(n²)
```

Here, n is the sequence length in the attention calculation, and the superscript squares n. O gives the order of growth. This local use of n differs from its role as a layer count in the communication formulas. The paper uses the quadratic attention calculation to explain why repeatedly processing a growing prefix becomes expensive.

```
O(t³)
```

Here, t is the eventual sequence length and the superscript cubes it. O describes the growth of the total computation time across generation when the prefix is recalculated at every step. Each successive pass has a larger sequence to process. The authors observe that recomputation can still make sense for short sequences if transferring a cache from slower local storage would take longer than rebuilding it. As the prefix grows, the added computation becomes harder to absorb.

Across an ordinary network boundary during cached generation, the payload is much smaller than the attention cache. The earlier keys and values stay where they will be used. Only the new representation has to move to the next stage. As an illustration of scale, the paper gives 24 KiB for one 12288-dimensional token embedding at 16-bit precision in GPT-3 or OPT-175B. Small payloads make a modest link usable, but each stage must still wait for the new representation to arrive. The route must account for delay as well as the number of bytes a link can carry.

#### Find a fast chain and keep it usable

A client keeps priority queues of servers that can run the stages it needs. It orders candidates using measured network latency and estimates how much computation each candidate would add to the path. Servers benchmark and report their own compute throughput. Clients probe candidate servers to learn the delay between themselves and those machines. When a server covers multiple consecutive blocks, the compute part of the estimate accounts for the number of blocks assigned to it. The paper’s description treats those estimates as costs for finding a route across the ordered stack.

Conceptually, a chain is a path through a graph. Progress through a server advances the request over the blocks that server can execute. A feasible route reaches the end from the beginning without skipping any required blocks, and the estimated cost of a route includes both processing and communication. The algorithmic overview describes a search over possible chains. The detailed routing discussion gives the implementation as D* Lite, a method for maintaining a shortest path as the underlying graph changes. The client keeps the search running in the background and can reuse it across calls.

That reuse matters when a server is removed from consideration. The known information about other candidates may still be adequate, so the client can update the path rather than planning it again from the start. A narrow stage might have a replacement that covers its whole span. A wider stage might require several replacements, each covering part of it. Either route has to preserve the same order of block computations. Routing decides where to continue. The separate cache mechanism provides the state a new route needs in order to continue from the right point.

#### Keep the state needed for a replacement

Petals maintains an attention cache on each server for the layers it runs. This is the ordinary per-layer record of keys and values used during generation. The client keeps a different record, consisting of earlier inputs to each pipeline stage. Those inputs capture what arrived at the boundary of the stage. They contain enough information for a replacement that holds the same weights to process the earlier positions and regenerate the corresponding keys and values. The client can thus recover a stage without keeping a copy of the attention cache of every layer.

Suppose a server leaves after a request has already produced part of its continuation. The preceding stages have still done useful work, and the later stages may still hold their caches. Once the client finds a replacement for the failed span, it sends the recorded inputs for that span and asks the replacement to rebuild its attention state. The same inputs reach the same layer computations in the original order. The request can then resume from its current position. The design aims to preserve the result that the original computation would have produced under the same choices of tokens.

The alternatives clarify the cost. With a server-side cache alone, losing an essential stage can force the request to start over. With a cache-less pipeline, every step sends and processes the full prefix, so there is little saved state to lose. The paper describes the resulting data movement as follows.

```
O(n · t²)
```

Here, n denotes the number of pipeline layers in the accounting, t denotes sequence length, and t² expresses the growth from repeatedly sending a prefix that gets longer as generation proceeds. The dot means multiplication, and O gives the order of growth of total data transferred. The expression concerns data volume. A round that carries the whole prefix transfers more than a round that carries just the latest token.

```
O(t)
```

For a failed server, O gives the order of growth of the data the client must send to restore state, and t is the length of the history already processed. The paper describes this restoration transfer as taking one communication round per failed server. Recalculation is confined to the affected stages, and a surviving stage can retain its existing cache. When there are no failures, the authors recover the cached pattern of O(n · t) communication: each step makes the ordinary trips through the pipeline with the latest activations. When all servers lose their caches after every step, the procedure effectively falls back to rebuilding the prefix.

The simplest communication layout would send every stage result back through the client before forwarding it to the next stage. That gives the client a copy for recovery, with an extra dependency on the path the active computation must follow. In the more efficient layout described in the paper, the server can send the output to the next stage and to the client in parallel. The client keeps its copy while the next stage can already be working. The receivers can compare checksums asynchronously to check that they received the same data. Agreement between checksums establishes consistency between the received representations. The computation that created them depends on the executing server.

#### Preserve several candidate continuations

A client can choose the next token greedily, by taking its preferred prediction at each step, or use a sampling policy that selects from the prediction distribution. Beam search adds another kind of state. It maintains several candidate continuations, extends them and selects a new group based on a scoring criterion. A candidate that advances into the new group may have started in a different position in the old group, and several surviving continuations may share a parent. The scores can be computed by the client, while each remote server still needs the correct past attention state for the sequences the client chooses.

```
[1, k]
```

Here, k is the number of candidate sequences the search maintains. The brackets describe the inclusive range of allowed indices, and 1 identifies the first position in the previous group. The client can send a list containing at most k indices from this range. The position of an entry in the list identifies the new candidate slot. The value of that entry identifies the old cache to use there. The server gathers cache entries according to those indices just before running the next inference step.

```
[2, 2, 1, 3, 2]
```

This is the index list printed in the paper’s example. Each occurrence of 2 selects the cache of the second old candidate. The entry 1 selects the first old cache, and 3 selects the third. Reading the positions of the list gives the destination slots in the new group. Repetition allows several candidates to keep the history of a common parent. The paper’s accompanying walkthrough assigns one of those slots inconsistently with the printed list. The general indexing rule gives an unambiguous interpretation of the list and explains how the same server operation can support different rules for ranking continuations.

#### Place servers where they can add capacity

Routing is a client decision made over the currently advertised server placements. Load balancing is a server decision about which blocks to hold in the first place. Good routing cannot reach a block that no participating server has loaded. It also cannot remove a throughput bottleneck when many requests need to pass through a poorly supplied part of the stack. The placement procedure estimates the compute and Internet throughput of each server in tokens per second and uses the lesser value as that server’s throughput estimate. The server measures and caches these estimates when first joining.

Servers advertise the blocks they hold and their measured throughput in a distributed hash table, a directory maintained across peers. An arriving server can use the directory to estimate the combined throughput available at every block. It also considers placements that peers are already in the process of loading. This makes a planned contribution visible to later arrivals before its weights are ready. An arriving server generally takes as many consecutive blocks as its GPU can hold, subject to any capacity the operator has reserved for other uses.

```
start = arg minᵢ₌₁,…,L−K+1 sorted([tᵢ, tᵢ₊₁, …, tᵢ₊K₋₁])
```

Here, start is the selected first block of the new server’s interval. L is the total number of blocks, K is how many the new server can host, and i indexes a candidate start. The candidates run from 1 to L−K+1 because an interval must end within the stack. Each t with a subscript is the total throughput already assigned or announced for the corresponding block. The square brackets collect the K throughput values in the interval. The ellipsis stands for the intervening blocks, and the subscript arithmetic advances through them. The sorted operation puts the values in ascending order. The arg min chooses the starting index with the smallest sorted list, comparing lists from the first entry onward and choosing the leftmost starting index on a tie.

The lowest entry in a candidate’s sorted list gets priority. If several candidates contain a block with the weakest coverage, the procedure can favor one that covers several such blocks. It then considers the next weakest entries. This follows from viewing aggregate pipeline throughput as constrained by the least well supplied block. A popular block with abundant throughput can process requests only as quickly as the rest of the stack permits them to proceed. Placement therefore looks for an interval in which another server can relieve the binding capacity constraint or cover a gap.

Servers also recheck their current placements as their peers come and go. A server that finds a better interval according to the assignment rule estimates what other servers would do after it moves. It goes ahead if the predicted improvement in total throughput reaches the paper’s rebalancing threshold.

```
p = 20%
```

Here, p is the required percentage improvement in predicted eventual throughput, the equals sign sets its experimental value, and the percent sign expresses that value relative to the current throughput. The threshold gives the swarm a reason to tolerate small imperfections in the placement. Moving a stage discards its attention caches and requires loading weights for the new span. Closing an uncovered interval or relieving a substantial bottleneck can justify that disruption. Continually moving layers for marginal projected gains would repeatedly impose it on ongoing requests.

#### Adapt the network with client-held parameters

Parameter-efficient fine-tuning updates a small part of the trainable state. Some methods select a subset of existing parameters. Others add trainable components, such as adapters or soft prompts. A soft prompt consists of learned vectors supplied to the network, so its values can be optimized on a task. An adapter adds a comparatively small trainable transformation to the pretrained computation. The paper draws on prior evidence that these methods can perform well without the memory requirements of updating the entire checkpoint. Relevant examples are [parameter-efficient transfer learning](https://md.research.elamur.ai/free/en/papers/houlsby-2019-parameter-efficient-transfer-learning-nlp/), [LoRA](https://md.research.elamur.ai/free/en/papers/hu-2021-lora-low-rank-adaptation-large/) and [prompt tuning](https://md.research.elamur.ai/free/en/papers/lester-2021-power-scale-parameter-efficient-prompt/).

In Petals, the server computes a forward result through its portion of the frozen network. The client computes a task loss and sends the necessary gradient back through the pipeline. A gradient describes how a change in a value would affect that loss. Each server uses its local weights to calculate the gradient with respect to the activations it received, then returns the result upstream. The client can use these returned gradients to update its own trainable parameters. A server receiving a learned prompt can process its vectors as part of the incoming activations. This division also lets different clients train different prompts through the same shared weights.

Training requests process batches. The method described for this workload can repeat an incomplete forward or backward request when a server fails. Unlike successive generated tokens, successive training requests do not rely on a persistent attention cache left over from the preceding request. A failed training pass can still waste time, especially for a large batch. The state that survives the retry is the client’s training state, including the trainable parameters it owns. The authors implement the client-facing adaptation mechanism so users can define custom components in PyTorch. Petals is the software implementation of the system.

#### Fit more blocks on each device

The authors distinguish having enough arithmetic power from having enough GPU memory. They estimate that an RTX 3070 has enough raw computation to perform a complete inference step for BLOOM-176B in less than a second. Their naive memory placement would require 44 RTX 3070 GPUs and 44 communication rounds. The constraint on the number of resident blocks means the arithmetic estimate alone says little about the end-to-end generation time. Compressing the weights lets each GPU host a longer span and reduces the number of network boundaries on a route.

For BLOOM, the implementation uses mixed matrix decomposition with 8-bit weights in the reported comparisons. The paper explains it as retaining about 0.1% of values as 16-bit outliers and handling the remaining 99.9% as regular 8-bit values. The outlier path keeps especially large values in higher precision while most of the weights take less memory. For Llama 2, the experiments use 4-bit NormalFloat, a quantization format from [QLoRA](https://md.research.elamur.ai/free/en/papers/dettmers-2023-qlora-efficient-finetuning-quantized-llms/).

The system separately compresses the activations transmitted between stages. Dynamic blockwise quantization groups the transmitted values and reduces the precision used to represent them. This targets the bytes on the wire, while weight quantization primarily targets resident GPU memory. During fine-tuning, half precision and gradient checkpointing further reduce memory demands. Gradient checkpointing retains selected intermediate results and recalculates others when required on the backward pass. The experiments use the same weight compression for Petals and its baselines for each checkpoint, so differences in that choice are held fixed in the comparisons.

### Experiments and results

#### Test recovery with predictable failures

The initial study isolates the recovery procedure with BLOOM at 7.1 billion parameters. The checkpoint contains 30 blocks with a hidden size of 4096, the width of its internal token representation. The principal workload is a single sequence of length 512. The benchmark times passage through the transformer blocks and leaves embeddings and output scores outside that measurement. Computation and communication use single precision. The workload is designed to expose the timing costs of the different retry strategies when a server loses its state.

The experiments use four pipeline stages with (8, 7, 8, 7) blocks, each on a GeForce 1080 Ti. The GPUs are in the same physical system, and the stages run in separate containers with virtual network interfaces. Communication bandwidth is unrestricted for this benchmark. A simulated failure occurs when an activation transfer to the next stage fails with a specified probability and pipeline state is reset. The paper averages 50 repetitions and reports that the adjusted standard deviation stays within 0.2% for these runs. This setup controls the failure mechanism independently of geography.

There are three generation strategies. Caching with restarts keeps ordinary attention caches and begins generation again when a failure destroys them. Cache-less inference sends past tokens through the network on each step and retries the current step if it fails. That baseline uses the pipeline implementation from Megatron-DeepSpeed. Petals retains the server attention caches and the client’s record of stage inputs so it can rebuild the affected part. The outcome is measured in sequential generation steps per second. A missing result means the run failed to finish within 1 hour. The extended plot uses zero speed for the same timeout.

Caching with restarts is fastest when there are no failures. The authors attribute the difference in that condition to the relative maturity of the implementations. Cache-less processing can be competitive at 128 tokens and slows substantially at 1024 tokens. Petals delivers usable performance across the tested conditions and has its clearest advantage when failures are more frequent. The appendix extends the injected failure probability to 5% and the tested sequence length to 2048 tokens. The pattern agrees with the recovery mechanism. The benefit grows when an interruption would otherwise discard more useful past work or when replaying the entire prefix on every step would be expensive.

#### Measure interactive and batched performance separately

The large-checkpoint comparisons use Llama 2 (70B) on 3 servers with a T4 per server. BLOOM (176B) runs in separate configurations on 3 servers with an A100 (80 GB) per server and on 10 servers with an RTX 3090 per server. The controlled experiments set the network bandwidth and delay in software. Bandwidth is given bidirectionally and latency as round-trip time, the delay measured over an outward and return trip. Llama 2 uses 4-bit NormalFloat across its comparisons, and BLOOM uses 8-bit matrix decomposition across its own.

For interactive inference, the benchmark uses batch size 1, so each step generates 1 token for an individual sequence. It reports generation steps per second as seen by the client. The other workload consists of forward passes on batches of 128-token sequences. The reported metric is tokens processed per second, which indicates how quickly the system can move a large amount of data through the network. Internally, large batches are divided into microbatches of 1024 tokens so that pipeline stages can overlap their work. Backward passes are timed in a separate study because the trainable state and other settings can change their cost.

The benchmarks also examine what happens when the people supplying machines want to use them at the same time. In that setup, each owner can run a client alongside a server. The co-located client uses 8 CPU cores and no GPU. The measurements average the sequential generation and parallel forward-pass rates available to each client. This addresses a practical comparison. A group could use its devices separately for offloading or pool those same resources for a shared pipeline. Each user’s speed under concurrent demand is the relevant quantity for that choice.

#### Compare offloading with pooled and local GPUs

The measured offloading baseline uses DeepSpeed to swap weights from CPU memory onto a single GPU. The baseline follows recommended settings and has pinned host memory enabled. The paper reports a 1.2–2× speedup from enabling pinning, which helps the transfer baseline. For BLOOM, the authors also estimate an ideal offloading ceiling using CPU RAM, PCIe 4.0 with 16 lanes, zero offloading latency and unlimited GPU performance. This ceiling isolates the time spent moving parameters under favorable assumptions.

```
(176 GB · 8) ÷ (256 Gbit/s) = 5.5 seconds
```

In this expression, 176 GB is the weight volume used by the estimate for 8-bit BLOOM with 176B parameters. The factor 8 converts the byte-based volume to bits for comparison with the link rate, and the centered dot denotes multiplication. The denominator, 256 Gbit/s, is the PCIe throughput assumed in the appendix. The division gives the minimum time to move the model’s weights under these assumptions, which the authors report as 5.5 seconds. The parentheses group the converted data volume and the transfer rate.

```
1 ÷ 5.5 ≈ 0.18 tokens/s
```

Here, 1 represents the token advanced by a sequential inference step, and 5.5 is the preceding transfer time in seconds. The division converts duration per step to a rate, and the approximate equality gives the reported best-case speed of 0.18 tokens/s. The ideal GPU does its computation without adding time to the bound. For interactive generation with repeated weight loading, a faster accelerator can remove compute overhead while the host-to-device transfer still sets this limit.

Earlier in the paper, the authors give a separate idealized transfer example for OPT-175B. Its assumption is 16-bit weights and a PCIe gen. 4 transfer rate of 31.5 GB/s with 16 lanes. The resulting floor is 11 seconds per single-token forward pass. The comparison below places the paper’s two analytical settings side by side. They use different checkpoints, precisions and link-rate assumptions, so the lower value describes the more favorable estimated setting overall.

Best-case transfer time for a single-token forward pass with RAM offloading on OPT-175B and BLOOM-176B The BLOOM setting has the lower transfer-time floor under the paper’s stated assumptions.

**The numbers**

| System or setting | seconds per forward pass |
| --- | --- |
| OPT-175B with 16-bit weights | 11 |
| BLOOM-176B with 8-bit weights (this paper) | 5.5 |

The measured result the authors emphasize is that Petals can run interactive generation up to 10× faster than offloading. In the large-checkpoint experiments, they describe an order-of-magnitude advantage against both measured offloading and the idealized ceiling. The same qualitative advantage holds when each GPU owner uses a client concurrently for single-batch inference. The paper thus compares the approach with actual single-device software and also asks how much a perfect implementation could recover if it were still required to stream the full checkpoint from RAM.

For parallel forward passes, the gap is more sensitive to the link. Offloading is competitive at 100 Mbit/s or under high latency, and the distributed system has higher batch throughput under more favorable network conditions. The authors report that sequential generation responds chiefly to latency across the tested settings, with bandwidth and sequence length having less influence. Batch processing responds to both bandwidth and latency. These outcomes fit the payloads. The interactive case sends an activation for the next token on the critical path. A forward pass for many sequences moves more activation data, making time spent transmitting the payload itself more important.

A separate baseline places BLOOM on 3× A100 (80 GB) GPUs inside a single server and uses NVLink with the DeepSpeed v0.7.7 pipeline implementation. The whole checkpoint fits in those GPUs. The authors use the setup as a reference for the performance available from that hardware when the devices are closely connected. It answers a different question from offloading. The local pipeline shows what becomes possible when all the necessary accelerator memory is already present in one machine. The offloading baseline shows what each user could do with a single GPU and enough host memory.

#### Run on heterogeneous and geographically dispersed devices

One controlled configuration simulates 12 heterogeneous servers by partitioning the A100 devices into virtual servers of different capacities. Of those, 9 servers hold 7 blocks each, one holds 3 blocks, and two hold 2 blocks each. The arrangement covers the 70 blocks required for that BLOOM configuration. Since the unequal capacities are imposed within the benchmark hardware, this setup tests whether the pipeline can put together stages of different sizes. It provides an intermediate case between equal-capacity configurations and a deployment where machines differ in more than how many blocks they can host.

The Internet experiment uses 14 servers across Europe and North America. The machines come from personal installations and university labs, and their links run at 100–1000 Mbit/s. The deployment mixes GPU types with different capacities, including RTX 3060 and RTX 3090 devices as well as A4000 and A5000 devices. Four of the servers are behind firewalls, and the authors use the libp2p Circuit Relay protocol to connect across those boundaries. The workload is BLOOM generation and batch processing on a network whose participating machines and connections resemble the resources the authors propose pooling.

The authors report that the real deployment is slower than the A100 configurations and attribute that to the slower hardware. Interactive generation still outperforms offloading with the computation distributed across continents. The experiment establishes that the method can work beyond a controlled network and a common server type. The controlled and real-world results are complementary. Changing network conditions in software helps interpret the influence of latency and bandwidth. A live deployment shows the joint effect of slower hardware, varied link capacities and geographical separation in one installation.

#### Time a complete training pass

The training appendix evaluates BLOOM-176B in the 3× A100, 1 Gbit/s setup and times forward and backward passes for two task forms. For binary sequence classification, the authors replace the token output layer with a trainable classification head and prepend trainable prompts. They use batches of 128-token sequences, compare prompt and prefix tuning, and vary the batch sizes between 8 and 32 and the prompt lengths between 16 and 4. Prefix tuning uses deeper prompts and adds more trainable parameters in the authors’ comparison. The paper specifies the computation and batch shapes rather than a named classification corpus or held-out task split for these throughput measurements. The purpose is to time [text classification](https://md.research.elamur.ai/free/en/concepts/text-classification/).

Prefix tuning takes longer, and longer prompts and smaller batches also reduce training speed in the reported settings. Moving the client calculations to a GPU gives no visible gain for classification. On that task, the client’s main matrix operation uses a narrow output: the head scores the classes rather than producing scores over a full token vocabulary. The same server stack can therefore support very different client costs depending on what the client asks the last hidden representation to predict.

The language modeling task retains the token output layer and explores the same prompt and batch settings. With a GPU on the client, its throughput is within 10% of the classification throughput. With a CPU-only client, language modeling performance is 5-10 times worse in the authors’ account. The paper explains this through the larger output computation, which scores the vocabulary across positions in the batch. It contrasts the shapes of the client-side multiplications, using the following dimensions for the classification example.

```
(2 × h) and (h × b)
```

Here, 2 is the number of output classes, h is the hidden dimension, and b is the batch size in the classification example. Each × separates the row and column dimensions of one matrix, and the parentheses group those dimensions. BLOOM-176B has a hidden dimension of 14,336 in the paper. The shared dimension h is what allows the matrices to be multiplied.

```
(d × h) and (h × b)
```

Here, d is the vocabulary size, given as 250,880 for BLOOM-176B, and h retains its meaning as the hidden dimension. The × signs and parentheses again identify matrix shapes. The language-modeling footnote uses b for the width of the second matrix in the comparison. Operationally, the authors describe projecting hidden states for all tokens in the batch, so the output calculation covers token positions as well as vocabulary entries. The paper characterizes the difference in arithmetic as follows.

```
≈ 10⁵ times as many FLOPS
```

The approximate sign marks the paper’s estimate, the superscript indicates a power of ten, and FLOPS here refers to the floating-point operations in the comparison. The reported estimate concerns the client-side output calculation against the classification case. The timing experiment makes the effect concrete. A client can be lightweight for classification even when the same frozen blocks feed a vocabulary-sized prediction workload that benefits substantially from a local GPU.

### What the ablations show

#### The usefulness of each cache depends on the failure condition

The recovery comparison isolates two costs that can be difficult to distinguish in an Internet deployment. One is the cost of carrying recovery state during a successful run. The other is the cost of recovering work after an interruption. The failure-free case favors the conventional restart implementation, whose cached state remains available throughout the run. As failures become more frequent, its advantage disappears because a restart repeats work that surviving stages had already performed. The cache-less system avoids losing a large remote cache, yet regularly pays to process old positions again. Petals spends extra effort keeping the option to reconstruct only what it loses.

Increasing the length of the generated sequence helps interpret that comparison. A short continuation can finish before retries or prefix recomputation become dominant. A longer one makes successful past computation more valuable. If a server fails late, a restart has more work to repeat. If the system recalculates the prefix at each step, the amount of repeated work grows as the sequence extends. The experiment therefore supports the specific value of collecting stage inputs at the client. That information becomes most valuable in the region where both dropping all state and continually rebuilding it are expensive.

The authors also report a qualitative test in which randomly selected servers are shut down during inference and fine-tuning. They check that the system produces correct outputs and gradients. The timing runs show the cost of simulated failures under repeated conditions. The shutdown test addresses whether the mechanisms can resume the work and deliver the expected computation. Together they distinguish two properties that a single speed measurement would obscure: remaining responsive after state loss, and rebuilding enough state to obtain the intended result.

#### Reassigning existing servers matters when capacity falls

The load-balancing study separates block assignment from actual GPU execution. The authors simulate 206 virtual participants, assigning throughput and capacity in blocks using the following distributions.

```
t ∼ 𝕌[0, 100]
```

Here, t is a simulated server’s throughput in tokens per second. The ∼ means that its value is drawn from a distribution. The symbol 𝕌 denotes a uniform distribution, and the brackets give the lower and upper values used in the experiment. This use of t represents server speed, distinct from its earlier use for sequence length.

```
b ∼ 𝕌[1, 10]
```

Here, b is the number of blocks a simulated server can hold. The ∼ and 𝕌 again indicate a draw from a uniform distribution, this time over the block capacities in the bracketed range. The simulated stack has 70 blocks, matching the block count used for BLOOM-176B in this experiment. The assigned capacities make it possible to test how the heuristic places servers with different amounts of available storage.

All approaches see the same availability schedule. The number of active peers follows a daily-style cycle, with roughly 100–110 at its peaks and 15–25 at its low points. Different subsets of the fleet are present at different peaks. One baseline assigns random contiguous intervals. Another uses informed placement when a server joins and leaves that assignment in place afterwards. The full algorithm also allows active servers to move based on a periodic check. As a reference, the authors estimate the best throughput obtainable if intervals could be assigned optimally every minute.

In this simulation, randomly assigning placements typically yields no throughput because there’s frequently a gap among the active placements. Assignment at arrival is useful while peers are joining. A new peer can observe a weak block and choose a span that covers it. That mechanism loses effectiveness when capacity is falling. Departures open gaps or leave bottlenecks, and there may be no fresh arrival to fix them. Periodic rebalancing allows the remaining servers to respond. It maintains pipeline coverage throughout the simulation and stays within the reported 10–15% range of the upper bound most of the time.

The paper separately examines how frequently servers move. It finds that higher thresholds give up some throughput at peaks while reducing layer changes relative to p = 1%. Frequent changes matter because each move invalidates the affected attention state. Even a placement that looks better by the aggregate throughput estimate can disrupt in-progress generation. The optimal reassignment benchmark would also require repeated weight loading as well as an expensive optimization procedure. Its role is to measure the gap to idealized capacity. The practical policy has to balance that capacity against disruption.

In another comparison, the authors exhaustively search possible assignments and compare them with the greedy procedure for throughputs they consider realistic. The greedy results typically reach 90-100% of the optimal throughput found by that search. This is a computational result for the tested assignments. The separate cycling simulation tests a different property, namely how much capacity the system retains while its population changes. A good static arrangement is useful at any particular moment. The ability to find another workable arrangement after departures is what keeps the stack available over time.

#### Compression and output computation affect different bottlenecks

The weight quantization checks compare zero-shot accuracy with 8-bit and 16-bit weights for BLOOM-176B and OPT-175B. The authors report little effect on accuracy across the major benchmarks they discuss. They also compare generation throughput at these precisions for BLOOM-176B on 8× A100 GPUs. At batch size 1 with 20 tokens, they report about 5% overhead from the quantized computation. For larger batches that overhead becomes negligible in their tests. These are measurements of the numerical representation and its compute cost, distinct from the effect of placing more compressed blocks on each machine in a distributed deployment.

The training comparisons help locate another bottleneck. Varying prompt type, prompt length and batch size changes the amount and shape of work passing through the shared pipeline. Comparing the CPU and GPU clients changes where the final computation runs. The classification task has little need for a GPU on the client, while the vocabulary projection in causal language modeling benefits from one. The contrast explains why batch forward throughput on the servers is only part of estimating training throughput. The choice of output head can move a limiting operation to the client even with an unchanged set of server-side blocks.

### Limitations

#### Limits identified by the authors

The authors identify input privacy as a limit of the public design. The server that receives an early representation may be able to use it to recover client data. The representation is the input to a computation the remote machine has agreed to perform, so that machine has access to it during a normal session. The paper suggests restricting sensitive work to trusted participants or forming an isolated network of organizations entitled to use the same data. It discusses secure multiparty computation and privacy-preserving hardware as possible extensions. The public deployment is evaluated here for performance and availability.

The authors also distinguish failures from incorrect computation. Losing a connection triggers a retry and possibly a cache rebuild. A server that replies with incorrect activations or gradients presents a different problem, because the pipeline may proceed using those values. The authors propose validators that could check servers and compare computed results, as well as checking outputs along disjoint chains. These proposals concern additional verification. The checksums in the communication procedure have a narrower role: they establish whether two recipients obtained matching activations sent by the same upstream stage.

Another stated concern is the balance of demand and supply. Participants can run clients without contributing a GPU. At some times, the people who want to use the service may outnumber the capacity volunteers are willing to provide. The authors sketch rewards for supplying server capacity, potentially redeemable for priority access. The benchmarks demonstrate sharing with a given supply of devices. How a volunteer community would sustain the capacity needed for its own workload is an operational and incentive question outside those experiments.

The paper also frames the scope of training around adaptation. In its full fine-tuning example, the estimated GPU memory needed to hold BLOOM-176B’s weights, gradients, and Adam optimizer state is nearly 3 TB. Holding the shared blocks fixed leaves the expensive pretrained state resident on the servers while users maintain small trainable components. This keeps independent training jobs compatible with a common network. It also places the training performance claims on the specific side of that design choice, where the shared large checkpoint is frozen.

#### What the experimental setup supports

The recovery mechanism assumes the failed blocks are available on other servers, or that the swarm can reassign enough remaining capacity to cover them. Rebuilding from client history restores missing state on a machine that can execute the necessary blocks. It still costs time and requires the replacement weights to be present. With too little memory across the active fleet, a complete path cannot be formed until capacity becomes available. The simulated load-balancing experiment therefore demonstrates recovery of coverage under its tested schedules and capacity assignments. A guarantee for arbitrary departures would have to account for whether a placement remains feasible at all.

The controlled failure experiments reset individual stages under a specified transfer-failure process. They use a smaller checkpoint on GPUs in one physical system, in a setting that isolates recovery behavior from ordinary Internet constraints. The Internet experiment adds realism on other dimensions, with varied GPUs and cross-continent connections. Its measurements describe one deployment. In an actual service, simultaneous departures, changes in link latency or the loss of several servers hosting the same interval could alter the availability of replacements. The paper’s tested failure rates and topology establish the conditions under which its measurements were made.

The different benchmark workloads also limit where the headline generation speed applies. Time between newly generated tokens depends on the sequential chain. Processing a batch or a long input has a different balance of compute, communication and client work. The reported large-batch comparisons show regimes where bandwidth matters enough for offloading to be competitive. The language-modeling appendix shows where a CPU client becomes a bottleneck. The interactive generation result is strongest evidence for workloads that need frequent responses from a large checkpoint and have a suitably provisioned path through the servers.

The adaptation experiments time passes for selected heads, prompts and batch sizes. Their evidence is about the resources and throughput required to execute those passes. Downstream task accuracy after adaptation, total time to reach a target accuracy and quality across possible datasets would require measurements of training outcomes. The separate quantization appendix studies zero-shot accuracy and inference overhead, which help assess the compressed weights used in the system. These measurements answer a different question from whether a particular adaptation will generalize after running it over the distributed pipeline.

Finally, the theoretical comparison is tied to the assumptions about where parameters reside and how they are transferred. The offloading ceiling accounts for repeatedly reading the checkpoint into a single GPU at a specified host-to-device rate. The local NVLink configuration shows that keeping the parameters resident can also be achieved inside a sufficiently large machine. The paper’s performance evidence supports a way to pool devices when such a machine is unavailable. The comparison of operating costs would depend on those resources, the available networking and how many clients use the system, quantities for which the paper reports performance settings rather than a general cost estimate.

### What came after

The later survey brings the paper into a broader discussion of efficient serving for generative systems. Petals gives that discussion a case in which a response depends on coordinating memory placement, communication and recovery. Its work on cache reconstruction is an inference algorithm, while its server placement and routing determine whether the algorithm can run at a practical speed. That combination connects the algorithm and systems perspectives named by [Towards Efficient Generative Large Language Model Serving](https://md.research.elamur.ai/free/en/papers/miao-2023-towards-efficient-generative-large-language/).

Later work on adapters takes up another part of the design space. Petals keeps shared pretrained blocks frozen and puts the trainable state for an individual task on the client. This makes an adapter a distinct object that users can maintain separately from the large checkpoint. K-Merge studies online, continual merging of adapters for on-device large language models. Its topic is how to combine those smaller task-specific components over time, whereas Petals uses their separation to let clients adapt a common set of remote blocks independently. The related work is [K-Merge](https://md.research.elamur.ai/free/en/papers/shenaj-2026-k-merge-online-continual-merging/).

A later privacy study takes up the intermediate representations themselves. Petals uses them to keep traffic small and to supply a replacement stage with the history it needs. The same representations are visible to the peers executing the remote computations. The authors flag the possibility of recovering client data from early inputs. The later paper focuses that concern on attribute inference, the question of whether information about an attribute of the input can be inferred from the intermediate state sent during distributed execution. It addresses the privacy side of a design choice that the original performance experiments treat as a means of moving computation between devices. [Privacy Risks of Intermediate Representations](https://md.research.elamur.ai/free/en/papers/lyu-2026-privacy-risks-intermediate-representations-attribute/)

## Cite

Cite as Alexander Borzunov, Max Ryabinin, Artem Chumachenko, Dmitry Baranchuk, Tim Dettmers, Younes Belkada, Pavel Samygin and Colin Raffel. 2023. Distributed Inference and Fine-tuning of Large Language Models Over The Internet. NeurIPS 2023.

The paper itself, not this page. BibTeX from the library's record of the work. [arXiv 2312.08361](https://arxiv.org/abs/2312.08361)

```bibtex
@inproceedings{borzunov2023distributed,
  title = {{Distributed Inference and Fine-tuning of Large Language Models Over The Internet}},
  author = {Alexander Borzunov, Max Ryabinin, Artem Chumachenko, Dmitry Baranchuk, Tim Dettmers, Younes Belkada, Pavel Samygin and Colin Raffel},
  booktitle = {NeurIPS 2023},
  year = {2023},
  doi = {10.52202/075280-0540},
  eprint = {2312.08361},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.52202/075280-0540}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
