pub struct RpcBackend { /* private fields */ }Expand description
RPC backend for distributed inference across multiple machines
Implementations§
Source§impl RpcBackend
impl RpcBackend
Sourcepub fn init(endpoint: &str, device: u32) -> Result<Self, RpcError>
pub fn init(endpoint: &str, device: u32) -> Result<Self, RpcError>
Initialize a new RPC backend for the given endpoint and remote device.
§Arguments
endpoint- The RPC server endpoint (e.g., “127.0.0.1:50052”)device- Index of the device to use on the remote server. A single endpoint can expose several devices; pass0for the first.
§Errors
Returns RpcError::StringConversion if endpoint contains an interior
NUL, or RpcError::InitializationFailed if llama.cpp could not reach
the endpoint or the device index is out of range.
§Example
use llama_cpp_4::rpc::RpcBackend;
let backend = RpcBackend::init("127.0.0.1:50052", 0)?;Sourcepub fn buffer_type(&self) -> Option<NonNull<ggml_backend_buffer_type>>
pub fn buffer_type(&self) -> Option<NonNull<ggml_backend_buffer_type>>
Get the buffer type for this RPC backend
Sourcepub fn get_device_memory(&self) -> Result<(usize, usize), RpcError>
pub fn get_device_memory(&self) -> Result<(usize, usize), RpcError>
Query the available memory on the remote device
Returns (free_memory, total_memory) in bytes.
§Errors
Returns RpcError::MemoryQueryFailed when the server reports a total
of zero, which is how an unreachable endpoint surfaces here.
Sourcepub fn as_ptr(&self) -> NonNull<ggml_backend>
pub fn as_ptr(&self) -> NonNull<ggml_backend>
Get the raw backend pointer for FFI calls.
The pointer is owned by this RpcBackend and is freed on drop; do not
free it, and do not use it after this value goes out of scope.