Skip to main content
The RPC backend lets a client machine offload tensor operations to one or more remote servers. Each server exposes a local ggml backend (CPU, CUDA, Metal, etc.) over a TCP socket. The client treats the remote device exactly like any other backend — the scheduler, buffer types, and graph compute API are identical.

Use cases

  • Offload inference to a remote machine with a powerful GPU
  • Distribute a large model across multiple machines when it does not fit in the memory of a single node
  • Run heterogeneous clusters where different nodes have different hardware

Protocol version

The RPC protocol is versioned. Client and server must use compatible versions:
The patch version increments with each change to GGML_OP_COUNT. Keep client and server binaries in sync.

Build

Enable the RPC backend on both the server and client machines:

Starting a server

A server hosts one or more local backends and listens on a TCP endpoint. Start one with ggml_backend_rpc_start_server:
The RPC server has no authentication. Only expose it on trusted networks or behind a firewall. Do not bind to a public interface in production without additional network security controls.

Connecting a client

On the client, initialise an RPC backend pointing at the server’s endpoint:
You can also use the registry API to register a remote server and then use the standard device enumeration:

Querying remote memory

Before allocating buffers, check available memory on the remote device:

Multi-server setup

You can connect to several servers and use them together via the scheduler. The limit is GGML_RPC_MAX_SERVERS (16) connections per process.
The scheduler distributes graph nodes across all connected servers based on where the weights live and which operations each backend supports.

Buffer type

To allocate tensors in the remote device’s memory, use the RPC buffer type:

API summary