Mesh & Federated Network
PiSovereign can connect with other PiSovereign instances on your local network to share computing power and collectively improve AI quality — all while keeping your data private.
Two Features, One Network
The mesh network provides two complementary capabilities:
| Feature | What It Does | Privacy |
|---|---|---|
| Mesh Inference | Borrow a peer’s GPU/NPU when yours is busy or overheating | Your query goes to the peer encrypted; only the response comes back |
| Federated Learning | Share model improvements (LoRA weight deltas) between peers | Differential privacy noise added before sharing — peers can’t recover your data |
Both features share the same peer discovery and trust infrastructure.
Setting Up
1. Enable the Features
In config.toml on each PiSovereign instance:
[mesh]
enabled = true
discovery = "mdns" # Automatic LAN discovery
serve_inference = true # Allow peers to use your compute
max_concurrent_peer_requests = 2
request_timeout_secs = 60
[federated_learning]
enabled = true
sync_after_n_samples = 5 # Sync after every 5 training samples
max_peers = 10
noise_epsilon = 1.0 # Differential privacy noise level
aggregation_method = "fedavg"
2. Pair Your Instances
Peers must be manually approved — there is no automatic trust. Two methods:
Shared Secret (Recommended)
- On Instance A: Generate a pairing code from Settings → Network → Generate Pairing Code
- On Instance B: Enter the code in Settings → Network → Add Peer
- Both instances confirm the pairing
QR Code
- On Instance A: Display QR code from Settings → Network
- On Instance B: Scan the QR code (if the device has a camera)
3. Verify Connection
After pairing, the Settings → Network page shows connected peers with:
- Peer name and IP address
- Connection status (🟢 Connected / 🔴 Offline)
- Available models on the peer
- Last sync timestamp (for federated learning)
How Mesh Inference Works
When you send a message and your local Ollama is busy, overloaded, or throttled due to heat:
Your Query
│
▼
Local Ollama ──(busy/hot)──► Peer Ollama ──(unavailable)──► Cached Response
│ │ │
▼ ▼ ▼
Response Response Degraded Response
(normal) (⚡ Mesh-assisted) (from template)
The fallback chain:
- Local Ollama — always tried first
- Peer Ollama — lowest-latency peer with the requested model, E2E encrypted
- Cached response — from semantic cache if a similar query was answered before
- Template response — generic acknowledgment (“I’m currently limited, but here’s what I know…”)
What Gets Sent to Peers
- Your query text (encrypted with the peer’s public key)
- The requested model name
- Nothing else — no conversation history, no memories, no user profile
How Federated Learning Works
After your PiSovereign collects 5 new training samples (from your feedback — thumbs up/down, corrections):
- Local training: LoRA adapter weights are updated locally
- Privacy noise: Laplace noise (ε = 1.0) is added to the weight deltas
- Encrypted sync: Noisy deltas are encrypted and sent to each trusted peer
- FedAvg aggregation: Each peer averages the received deltas with their own
- Privacy budget: The sync operation consumes ε from your formal privacy budget
What gets shared:
- LoRA weight deltas (small numeric arrays) with differential privacy noise
- Not shared: Your conversations, memories, personal data, or training samples
Think of it like this: You’re sharing “the AI got a bit better at this type of question” without sharing what the question was.
Discovery
mDNS (Default)
PiSovereign uses multicast DNS (mDNS/Avahi) for zero-configuration discovery on the local network. This means:
- LAN only — peers must be on the same network segment
- No internet required — everything stays local
- Automatic — new instances appear in the peer list without manual IP entry
Requirements
- mDNS/Avahi must be available (installed by default on most Linux distributions and Raspberry Pi OS)
- UDP port 5353 must not be blocked by local firewall
- Devices must be on the same subnet
Security
| Layer | Protection |
|---|---|
| Discovery | mDNS on LAN only — not routable over the internet |
| Trust | Manual peer approval with shared secret — no automatic trust |
| Transport | mTLS (mutual TLS) — both sides verify certificates |
| Payload | Per-request encryption with peer’s public key |
| Privacy | Differential privacy noise on all federated weight updates |
| Budget | Federated syncs consume privacy budget (ε) — stops when exhausted |
Troubleshooting
Peers Not Discovered
- Verify both instances are on the same subnet
- Check that
mesh.enabled = truein both config files - Test mDNS:
avahi-browse -ashould show PiSovereign services - Check firewall: UDP 5353 must be open
Mesh Inference Slow
- Check peer’s thermal state — it may be throttling
- Verify the peer has the requested model downloaded
- Try increasing
request_timeout_secs - Check network latency:
ping <peer-ip>
Federated Sync Not Working
- Verify
federated_learning.enabled = trueon both peers - Check privacy budget — syncs pause when budget is exhausted
- Ensure at least
sync_after_n_samplestraining samples have been collected - Check logs:
docker logs pisovereign 2>&1 | grep federated
See Also
- Features Overview — High-level feature summary
- Innovation Features — Technical deep-dive (#30: Federated Learning, #31: Mesh Network)
- Privacy Budget — How federated syncs consume privacy budget
- Sovereign Intelligence Engine — Signal bus integration