Skip to main content

Data Scientist: Bootstrapping with syft-flwr

Learn how to convert existing Flower projects to use SyftBox's file sync network with minimal code changes.

Bootstrapping is the process of wrapping a standard Flower application in the syft-flwr communication layer. This allows the ServerApp (the aggregator) and the ClientApp (running on Data Owner sites) to exchange model weights through SyftBox instead of direct gRPC connections. By bootstrapping, you enable your project to utilize SyftBox's file sync network for secure, distributed communication with minimal code changes.

1. Using the syft_flwr bootstrap Command

The syft-flwr CLI provides a utility to automate the conversion process.

  • Initialization: Navigate to your Flower project directory and run:
syft-flwr bootstrap .

  • Function: This command scans your existing pyproject.toml and directory structure to identify the ClientApp and ServerApp entry points.
  • Automation: It automatically adds the necessary syft-flwr dependencies and modifies the federation configuration to target the SyftBox file sync protocol.

2. Configuring Aggregator and Datasites

Once bootstrapped, you must define where the training will take place within your pyproject.toml.

  • Aggregator Node: Specify the email or UID of the SyftBox node that will act as the central server.
  • Target Datasites: List the participating Data Owner emails. These are the nodes where your ClientApp will be sent for execution.
  • Federation Section: Update the [tool.flwr.federations] section to include a syftbox profile instead of a local simulation.

3. Updating pyproject.toml

The bootstrap process makes key additions to your configuration file:

  • [tool.flwr.app.components]: Points to your server_app and client_app objects.
  • [tool.flwr.app.config]: Holds the hyperparameters (rounds, learning rate) that will be synced across the network.
  • Dependencies: Ensures syft-flwr is listed in the dependencies array so it is installed on the remote Data Owner's sandbox.

4. Adding syft-flwr Dependencies

Your project requires specific libraries to handle the SyftBox transport layer:

  • Core Library: Ensure syft-flwr is installed in your local environment.
  • Compatibility: The bootstrapping tool ensures that the version of flwr in your project is compatible with the version of syft-flwr being used.

5. Project Configuration Options

You can further customize how your project behaves on the SyftBox network:

  • Privacy Budget: Configure Differential Privacy (DP) parameters directly in the toml file if supported by your strategy.
  • Job Metadata: Add a project description and motivation. This is vital because Data Owners will see this info when reviewing your job proposal.
  • Resource Limits: Optionally request specific hardware (e.g., GPU access) if the Data Owner allows it.

Next Step: With your project bootstrapped, you are ready to move to Submitting FL Jobs to push your code to the Data Owners for approval.