Overview
Simulations allow you to test your federated learning workflow locally before deploying to real datasites. Syft-Flwr simulates a multi-party FL environment using mock datasets and temporary client instances.Prerequisites
- A bootstrapped Syft-Flwr project (see Bootstrapping Projects)
- Mock datasets prepared for testing
- Python 3.9 or higher
Quick Start
Using the CLI
Interactive Mode
If you don’t provide dataset paths, the CLI will prompt you:Using Python API
How Simulations Work
1. Mock RDS Client Setup
Simulations create temporary RDS (Remote Data Store) clients for each participant:2. Encryption Bootstrap
By default, simulations use end-to-end encryption:To disable encryption for testing:
3. Concurrent Execution
Server and clients run concurrently using asyncio:Mock Dataset Configuration
Dataset Structure
Each mock dataset path should contain the data for one client:Accessing Datasets in Client Code
Clients access their dataset via theDATA_DIR environment variable:
Dataset Path Validation
Simulation validates all dataset paths before execution:Simulation Logs
Logs are saved to<project_dir>/simulation_logs/:
Viewing Logs
Running in Different Environments
- Command Line
- Python Script
- Jupyter Notebook
Complete Example
Here’s a full simulation workflow:Advanced Configuration
Skipping Module Validation
Useful for parallel test execution:Custom Temporary Directory
Simulations use/tmp by default. The directory is cleaned up automatically:
Troubleshooting
”Project directory does not exist”
Ensure the project is bootstrapped:“Mock dataset path does not exist”
Verify all dataset paths:Simulation Hangs
Check logs for errors:- Client code has infinite loop
- Server waiting for more clients than provided
- Dataset loading errors
”FileNotFoundError: Path .data/ does not exist”
EnsureDATA_DIR environment variable is set correctly by the simulation runner:
Next Steps
Multi-Client Setup
Deploy to real datasites
Offline Training
Asynchronous FL patterns