Skip to main content
Syft-Flwr provides a flexible transport layer that enables federated learning across different communication backends. The transport abstraction allows seamless switching between local SyftBox installations and P2P cloud-based synchronization.

Architecture

The transport layer consists of three core abstractions:
  1. Client Protocol (SyftFlwrClient) - Unified interface for accessing datasite information
  2. RPC Protocol (SyftFlwrRpc) - Message sending and response retrieval
  3. Events Protocol (SyftFlwrEvents) - Asynchronous message handling and processing
Each abstraction has multiple implementations that work together to support different deployment scenarios.

Transport Modes

SyftBox Transport (Default)

Best for: Local development, on-premise deployments, high-security scenarios
from syft_flwr import bootstrap

bootstrap(
    flwr_project_dir="./my_fl_project",
    aggregator="[email protected]",
    datasites=["[email protected]", "[email protected]"],
    transport="syftbox"  # Uses local SyftBox client
)
Features:
  • Full RPC/crypto/event stack via syft_core.Client
  • End-to-end encryption with X3DH key exchange
  • Filesystem-based message routing
  • Watchdog file monitoring for real-time events
  • Futures database for response tracking
Components:
  • Client: SyftCoreClient (wraps syft_core.Client)
  • RPC: SyftRpc (uses syft_rpc library)
  • Events: SyftEvents (uses syft_event library)

P2P Transport

Best for: Cloud deployments, Google Colab, environments without local SyftBox
from syft_flwr import bootstrap

bootstrap(
    flwr_project_dir="./my_fl_project",
    aggregator="[email protected]",
    datasites=["[email protected]", "[email protected]"],
    transport="p2p"  # Uses Google Drive sync
)
Features:
  • Direct Google Drive API integration via GDriveFileIO
  • File-based message passing (.request and .response files)
  • No local filesystem dependencies
  • Polling-based event handling
  • Access control via Google Drive permissions
Components:
  • Client: SyftP2PClient (lightweight, email-based)
  • RPC: P2PFileRpc (file-based messaging)
  • Events: P2PFileEvents (polling-based)

Factory Functions

Syft-Flwr automatically detects the appropriate transport implementation:
from syft_flwr.client import create_client

# Auto-detect from environment or config
client = create_client()

# Explicit transport selection
client = create_client(transport="syftbox")
client = create_client(transport="p2p", email="[email protected]")

# From project directory (reads pyproject.toml)
client = create_client(project_dir="./my_fl_project")

Transport Detection Order

When no transport is specified, Syft-Flwr uses this detection order:
  1. Explicit transport parameter - Highest priority
  2. Project config - Read from pyproject.toml [tool.syft_flwr] section
  3. Local SyftBox - Check for syft_core config file
  4. Error - Cannot auto-detect, must specify transport

Configuration

Transport configuration is stored in pyproject.toml:
[tool.syft_flwr]
transport = "syftbox"  # or "p2p"
aggregator = "[email protected]"
datasites = ["[email protected]", "[email protected]"]
app_name = "my_fl_app_1234567890"

Encryption Support

TransportEncryptionMethod
SyftBox✅ SupportedX3DH + AES-256-GCM via syft_crypto
P2P⚠️ PlannedCurrently relies on Google Drive access control
To disable encryption in SyftBox mode:
export SYFT_FLWR_ENCRYPTION_ENABLED=false

Next Steps

SyftBox Transport

Learn about the traditional SyftBox client with full RPC/crypto stack

P2P Transport

Explore cloud-based P2P synchronization for Colab and remote deployments

Build docs developers (and LLMs) love