← Latest papers
💻 computer science

Towards Distributed Inference of LLMs on a P2P Network

This paper proposes a decentralized, prefix-cache-aware routing scheme for peer-to-peer LLM serving that leverages local radix trees and asynchronous peer metadata to route requests to nodes with the longest matching prefixes, thereby reducing inference latency without requiring centralized coordination or KV-cache transfers.

Original authors: Shabari S Nair, Krishanu Saini

Published 2026-06-17
📖 5 min read🧠 Deep dive

Original authors: Shabari S Nair, Krishanu Saini

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are running a massive library of knowledge (a Large Language Model) that helps people write stories, answer questions, and solve problems. Every time someone asks a question, the library has to "think" through the first part of the request before it can start giving an answer. This "thinking" phase is slow and uses a lot of energy.

However, often many people ask questions that start with the exact same words—like "Here is a story about a cat..." or "Translate this sentence to French." In a smart library, once the "thinking" for those opening words is done, the library saves that work in a temporary notebook (called a KV Cache) so it doesn't have to re-do it for the next person. This is called Prefix Caching.

The Problem: The "One Library" Bottleneck

In a traditional setup, you might have one giant library building with many shelves (nodes). If a new person walks in, a central manager decides which shelf to send them to.

  • The Issue: If the manager sends a person to Shelf A, but the "thinking" for their question was saved on Shelf B, Shelf A has to start from scratch. The manager has to constantly check every single shelf to see where the notes are. If the manager gets too busy or breaks down, the whole library slows down.
  • The Alternative: Some libraries try to copy the notes from Shelf B to Shelf A instantly. But these notes can be huge (like moving entire bookshelves), and it takes too much time and bandwidth to move them around, especially if the shelves are far apart.

The Solution: A Peer-to-Peer "Gossip" Network

This paper proposes a new way to run the library: No central manager. Instead, every shelf (node) is its own librarian, and they all talk to each other directly.

Here is how it works, using a simple analogy:

1. The "Radix Tree" (The Librarian's Mental Map)
Every librarian keeps a mental map (a Radix Tree) of the questions they have recently answered and the notes they have saved.

  • Example: Librarian Alice knows she has the notes for "How to bake a cake." Librarian Bob knows he has the notes for "How to fix a bike."

2. The "Gossip" (Anti-Entropy)
Instead of a central boss telling everyone what's happening, the librarians gossip. Every few seconds, they whisper a quick summary to their neighbors: "Hey, I just saved notes on 'baking'."

  • They don't send the heavy notes (the actual data); they just send a tiny list of what topics they have covered.
  • This happens in the background, so it doesn't slow down the actual work.

3. Making the Decision (Routing)
When a new customer walks in with a request like "How to bake a chocolate cake," the librarian who first sees them checks their mental map.

  • They ask: "Who else has the notes on 'baking'?"
  • If they hear from a neighbor that Bob has the notes on "baking," they send the customer to Bob. Bob can skip the "thinking" part and go straight to the answer.
  • If the librarian's map is slightly old (stale) and they send the customer to the wrong person, it's not a disaster. The wrong person just has to start the "thinking" from scratch. The answer is still correct; it just took a tiny bit longer. Correctness is never lost, only speed.

4. Handling the Crowd (Hotspots)
What if everyone wants to know about "baking"? Bob becomes the "Baking Specialist" and gets overwhelmed.

  • The system has a safety valve: If Bob gets too busy, he whispers, "I'm full!" to the other librarians.
  • The other librarians then stop sending baking requests to Bob for a little while, letting him catch up, and send the new requests to someone else who will have to do the "thinking" from scratch.

What the Experiments Showed

The researchers tested this idea in a computer simulation with four "librarians" using a dataset of general knowledge questions (MMLU).

  • Fast Networks Win: If the librarians can gossip quickly (low network delay), this system is much faster than having no routing at all. It saves a lot of time by reusing the "thinking" work.
  • Slow Networks Lose: If the gossip takes too long (high network delay), the time spent sending the request to the right person is longer than just doing the work yourself.
  • Specialization: The system naturally creates "specialists." If a topic is popular, one node will eventually hoard all the notes for it, becoming super fast at that specific topic. However, if the notes get too big, the system automatically kicks out old notes to make room, causing the "specialist" to change over time.

The Bottom Line

This paper suggests that for distributed AI systems, we don't need a heavy, central boss or expensive data transfers. Instead, we can use a decentralized, gossip-based system where nodes share lightweight maps of what they know.

  • Pros: It's resilient (if one node breaks, the others keep working), it scales well, and it avoids moving huge amounts of data.
  • Cons: It only works well if the network is fast and the questions have a lot of repetition (like many people asking similar things). If the network is slow or the questions are all unique, the system doesn't gain much speed.

In short: It's like a group of friends sharing a playlist. Instead of one person managing the whole list, everyone tells the others what songs they have. If you want a song, you ask the friend who has it. If they don't have it, you just play it yourself. It's messy, but it works great when everyone is listening to the same hits.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →