avatar

Pavel Vasilev

Student, Yandex School of Data Analysis
Ural Federal University
vasilievpavel4@gmail.com


InferD: Distributed LLM Inference Engine

Project Type: Engineering / Distributed Systems
Code: GitHub Repository (branch: defence)


1. Overview & Inspiration

InferD is a framework for distributed inference of Large Language Models (LLMs) across a decentralized network of consumer-grade GPUs. Instead of requiring one massive server to hold the entire model, the model is split into pieces (stages), and different nodes in the network execute different parts of the computation graph.

Origins of Ideas

The project synthesizes concepts from two key research areas:


2. Core Architecture

The system operates as a Peer-to-Peer (P2P) network. There is no central master server controlling the inference.

The Role of DHT (Distributed Hash Table)

We use a Kademlia DHT as the backbone for service discovery and state synchronization. Unlike centralized databases, the DHT is replicated across all participants.

What exactly is stored in the DHT? In InferD, the DHT stores the Routing Table, which maps Stage IDs to Node Addresses and their current Load:

{
  "stage_0": [
    {"node_id": "A", "ip": "192.168.1.5", "load": 0.2, "capacity": 10},
    {"node_id": "B", "ip": "192.168.1.6", "load": 0.8, "capacity": 12}
  ],
  "stage_1": [ ... ]
}

3. How Inference Works (Pathfinding)

When a user sends a prompt, the request traverses the network “hop-by-hop”.

  1. Client Request: The client sends text to a node hosting Stage 0 (Embedding).
  2. Forward Pass & Pathfinding:
    • Node A computes its layers.
    • It now needs to send the hidden states to Stage 1.
    • Greedy Routing: Node A queries the DHT for all nodes hosting Stage 1. It compares their load metrics and selects the least loaded peer (greedy heuristic).
    • Note: We prepared a D Lite algorithm for more complex latency-aware routing, but the active implementation uses this robust greedy approach.*
  3. Transmission: Tensors are serialized (Base64) and sent via stateless HTTP RPC.
  4. Completion: This repeats until the final stage (LM Head) generates the token and returns it.

4. Dynamic Load Balancing

One of the main features of InferD is its ability to adapt to network conditions.

The Problem: In a decentralized network, some stages might become bottlenecks (e.g., 10 nodes host Stage 1, but only 1 node hosts Stage 2).

The Solution (Balancer): Each node runs a background Balancer process that periodically checks the global load distribution via DHT.


5. Implementation Details


< Back to Home


Powered by Jekyll and Minimal Light theme.