Overview
Unlike traditional federated learning systems that require persistent network connections, Syft-Flwr uses file-based messaging where participants communicate by writing and reading files in shared directories. This enables:- Offline-first operation: Participants don’t need to be online simultaneously
- Network resilience: Communication survives network disruptions
- Audit trails: Every message is a file with timestamps
- Simple debugging: Inspect message contents directly
Directory Structure
Syft-Flwr organizes messages in a hierarchical folder structure:Folder Naming Convention
Pattern:syft_outbox_inbox_{sender}_to_{recipient}
- sender: Email of the message sender
- recipient: Email of the message recipient
server_to_client: Server sends requests, client reads themclient_to_server: Client sends responses, server reads them
Path Components
- app_name: Unique identifier for the FL application (e.g.,
[email protected]_my_fl_app_1234567890) - endpoint: RPC endpoint, typically
messagesfor FL communication - uuid: Unique message identifier
- extension:
.requestfor outgoing messages,.responsefor replies
Message Flow
Server → Client Request
Implementation: Server Side
src/syft_flwr/fl_orchestrator/syft_grid.py:199
Implementation: RPC Layer (SyftBox)
src/syft_flwr/rpc/syft_rpc.py:26
Implementation: RPC Layer (P2P)
src/syft_flwr/rpc/p2p_file_rpc.py:38
Implementation: Client Side
src/syft_flwr/events/p2p_fle_events.py:179
Response Polling
The server polls for responses using future IDs:src/syft_flwr/fl_orchestrator/syft_grid.py:229
The timeout and poll interval can be configured via environment variables:
SYFT_FLWR_MSG_TIMEOUT: Maximum wait time for responses (default: 120s)SYFT_FLWR_POLL_INTERVAL: Sleep between polls (default: 3s)
File Synchronization
SyftBox Transport
Files are synchronized by the SyftBox daemon:- Local files in
~/.syftbox/datasites/ - Watchdog detects new files instantly
- No network delay for local testing
- Real deployment uses SyftBox server sync
P2P Transport
Files are synchronized via Google Drive API:- Direct API calls to Drive storage
- No local files - everything in the cloud
- Cross-device sync automatic via Google
- Network latency depends on Drive API response time
Message Lifecycle
Advantages of File-Based Communication
1. Offline Operation
Participants don’t need simultaneous connectivity:2. Fault Tolerance
Network disruptions don’t lose messages:3. Debugging
Inspect messages directly:4. Audit Trail
Every message is logged:5. Testability
Simulate scenarios by manually creating files:Limitations and Considerations
Polling Overhead
P2P transport requires periodic polling:- Shorter interval = faster response, more API calls
- Longer interval = slower response, fewer API calls
File System Limits
Large models may hit file size limits:Cleanup
Old messages should be cleaned up:Best Practices
1. Set Appropriate Timeouts
2. Handle Missing Responses
3. Monitor File System Usage
Next Steps
Transport Layers
Deep dive into SyftBox vs P2P implementations
Privacy Model
Understand encryption and data flow