LLM Federated Inference
LLM models without federated inference are centralised and unprotected — without federated inference, inference remains centralised. Four controls: distributed inference, model sharding, inference aggregation and privacy-preserving inference.
What is LLM Federated Inference? Simply Explained
LLM federated inference is like a distributed super-team for AI: distributed inference distributes inference across multiple devices with model and data parallelism. Model sharding splits large models across multiple GPUs with tensor and pipeline sharding. Inference aggregation combines results from multiple models with ensemble methods and voting. Privacy-preserving inference performs computations on encrypted data with homomorphic encryption or SMPC. Without security, attackers can compromise centralised inference, leak data, or conduct privacy violations.
↓ Jump to federated inference controls
4 Federated Inference Controls
Distribute LLM inference across multiple devices or servers. Use model parallelism and data parallelism for scalability.
# Moltbot distributed inference:
distributed_inference:
enabled: true
# Model parallelism:
model_parallelism:
enabled: true
# Split: model across devices
# Layers: distribute layers across GPUs
# Communication: gradient synchronization
# Framework: PyTorch, TensorFlow
# Data parallelism:
data_parallelism:
enabled: true
# Replicate: model across devices
# Batch: split batch across devices
# Aggregate: gradients across devices
# Framework: PyTorch DDP, TensorFlow MirroredStrategy
# Pipeline parallelism:
pipeline_parallelism:
enabled: true
# Split: model into pipeline stages
# Stages: each stage on different device
# Communication: intermediate activations
# Benefit: memory efficiencyShard LLM models across multiple devices for memory efficiency. Use tensor sharding and pipeline sharding.
# Moltbot model sharding:
model_sharding:
enabled: true
# Tensor sharding:
tensor_sharding:
enabled: true
# Split: tensor across devices
# Method: ZeRO, FSDP
# Memory: reduces memory per device
# Communication: all-to-all
# Pipeline sharding:
pipeline_sharding:
enabled: true
# Split: model into pipeline stages
# Stages: each stage on different device
# Benefit: memory efficiency
# Latency: pipeline parallelism
# Hybrid sharding:
hybrid_sharding:
enabled: true
# Combine: tensor + pipeline sharding
# Benefit: memory + compute efficiency
# Complexity: higher implementation complexityAggregate inference results from multiple models or devices. Use ensemble methods and voting.
# Moltbot inference aggregation:
inference_aggregation:
enabled: true
# Ensemble methods:
ensemble:
enabled: true
# Methods: bagging, boosting, stacking
# Benefit: improved accuracy
# Cost: increased inference time
# Voting:
voting:
enabled: true
# Methods: majority voting, weighted voting
# Use: for classification tasks
# Benefit: robustness to individual errors
# Averaging:
averaging:
enabled: true
# Methods: simple averaging, weighted averaging
# Use: for regression tasks
# Benefit: reduced variancePerform inference on encrypted data without decryption. Use homomorphic encryption or secure multi-party computation.
# Moltbot privacy-preserving inference:
privacy_preserving:
enabled: true
# Homomorphic encryption:
homomorphic_encryption:
enabled: true
# Encrypt: input data before inference
# Compute: on encrypted data
# Decrypt: only output
# Use: FHE or PHE
# Secure multi-party computation:
smpc:
enabled: true
# Split: input data across parties
# Compute: without revealing inputs
# Reveal: only final output
# Use: for collaborative inference
# Trusted execution:
tee:
enabled: true
# Use: TEE for secure inference
# Providers: AWS Nitro, Azure Confidential Computing
# Benefit: hardware-based isolationFrequently Asked Questions
What is the difference between model parallelism and data parallelism?
Model parallelism splits the model across devices. Each device holds a portion of the model, and the input is processed sequentially across devices. Data parallelism replicates the entire model across devices, and the input batch is split across devices. Model parallelism is useful for large models that don't fit on a single device. Data parallelism is useful for scaling throughput with larger batches. Pipeline parallelism combines both by splitting the model into stages across devices.
How does tensor sharding reduce memory usage?
Tensor sharding (e.g., ZeRO, FSDP) splits tensors across devices. Instead of each device holding a full copy of the model parameters, each device holds a shard. During computation, shards are gathered as needed. This reduces memory per device, allowing larger models to be trained or inferred on fewer devices. The trade-off is increased communication overhead for gathering and scattering shards.
How does ensemble inference improve accuracy?
Ensemble inference combines predictions from multiple models. By aggregating diverse models (different architectures, training data, hyperparameters), ensemble methods reduce variance and bias. Common aggregation methods: majority voting (classification), averaging (regression), stacking (learned meta-model). The benefit is improved accuracy, but the cost is increased inference time and resource consumption.
What are the trade-offs of privacy-preserving inference?
Privacy-preserving inference (homomorphic encryption, SMPC, TEE) provides strong privacy guarantees but has significant trade-offs: 1) Performance — homomorphic encryption is 100-1000x slower than plaintext computation. 2) Complexity — SMPC requires coordination across parties. 3) Cost — TEE requires specialised hardware. 4) Compatibility — not all operations are supported in encrypted domain. 5) Latency — communication overhead in SMPC. Choose the technique that matches your privacy and performance requirements.