Flower App (PyTorch) 🧪¶

View on GitHub

🧪 = This example covers experimental features that might change in future versions of Flower Please consult the regular PyTorch code examples (quickstart, advanced) to learn how to use Flower with PyTorch.

The following steps describe how to start a long-running Flower server (SuperLink) and then run a Flower App (consisting of a ClientApp and a ServerApp).

Preconditions¶

Let’s assume the following project structure:

$ tree .
.
├── client.py           # <-- contains `ClientApp`
├── server.py           # <-- contains `ServerApp`
├── server_workflow.py  # <-- contains `ServerApp` with workflow
├── server_custom.py    # <-- contains `ServerApp` with custom main function
├── task.py             # <-- task-specific code (model, data)
└── requirements.txt    # <-- dependencies

Install dependencies¶

pip install -r requirements.txt

Run a simulation¶

flower-simulation --server-app server:app --client-app client:app --num-supernodes 2

Run a deployment¶

Start the long-running Flower client (SuperNode)¶

In a new terminal window, start the first long-running Flower client:

flower-client-app client:app --insecure

In yet another new terminal window, start the second long-running Flower client:

flower-client-app client:app --insecure

Run the Flower App¶

With both the long-running server (SuperLink) and two clients (SuperNode) up and running, we can now run the actual Flower App:

flower-server-app server:app --insecure

Or, to try the workflow example, run:

flower-server-app server_workflow:app --insecure

Or, to try the custom server function example, run:

flower-server-app server_custom:app --insecure