Skip to main content

flypse-logo

PyPI - Version PyPI - Python Version pre-commit codecov pre-commit.ci status

FLYPSE is a Python library for experimenting with federated learning on the cloud–edge continuum. Write what each participant does, connect the participants in any topology, place them on an infrastructure, and study how learning behaves as data, devices and links differ and change.

FLYPSE is designed for researchers and developers evaluating federated protocols under realistic systems: synchronous or asynchronous, centralised, hierarchical or decentralised. It builds on ECLYPSE, which places and emulates the participants.

Key features

  • Write the protocol, not a plugin: a participant is an entity with a step, which sends and receives models. There is no round loop, no role and no barrier in the core: rounds, deadlines, buffers and gossip are what the entities do.
  • Connect any topology: build federations as stars, trees, rings or custom graphs, and let entities ask who their parent, children and neighbours are.
  • Pay for communication: each message really takes as long as its size costs over the latency, bandwidth and processing time of every hop of its route.
  • Model heterogeneity: split data with label or quantity skew, and change devices and links while the federation runs.
  • Bring any model: models of any framework are exchanged as flat numpy vectors, with versions that tell where each one comes from.
  • Compose strategies: select, screen, weigh, aggregate and optimise with functions and small classes on those vectors, from federated averaging to Byzantine-robust and personalised aggregation.
  • Inspect results: entities report and evaluate whatever they need, and a seed makes the data, the system and the entities reproducible.

Federation and infrastructure

FLYPSE keeps two graphs apart, so that either can change without the other:

  • The federation says who takes part and who talks to whom. Its nodes are entities, and its edges are their connections.
  • The infrastructure says where they run. Its nodes are devices, and its edges are links with a latency and a bandwidth.

A placement maps the first onto the second: one device per entity ("mirror", the default), all on one device ("singleton"), or any infrastructure and placement strategy. Entities then run as services on Ray actors, with real code and real messages, and no container or root access.

Delays are modelled, not shaped: FLYPSE waits for the cost of each message, in real time. Messages do not compete for bandwidth, and packet loss and transport protocols are outside the model.

Installation

FLYPSE is available on PyPI and requires Python >=3.11,<3.15. Install it with pip:

pip install flypse

Or add it to a uv project:

uv add flypse

We strongly suggest a virtual environment. See the installation guide for environment setup.

Quickstart

Save this as quickstart.py. Three clients estimate the mean of a dataset split among them: each moves the global estimate towards the mean of its own data, and the server averages their estimates, weighted by their number of samples.

import numpy as np

from flypse.data import UniformDataset
from flypse.federation import Entity, FederatedModel, get_star
from flypse.process import FederatedProcess
from flypse.strategies import aggregation, weighting


class MeanModel(FederatedModel):
    """A model whose only parameter is an estimate of the mean."""

    def _read_parameters(self):
        yield "mean", self.model["mean"]

    def _write_parameter(self, name, value):
        self.model[name] = value


class Client(Entity):
    """Moves the global estimate towards the mean of its own data."""

    def __init__(self, entity_id):
        super().__init__(entity_id)
        self.model = MeanModel({"mean": np.zeros(1)})

    async def step(self):
        estimate = self.model.get_parameters()
        local_mean = np.mean(list(self.data))
        record = self.model.update_version(
            estimate + 0.5 * (local_mean - estimate), "local"
        )
        await self.send("server", record, n_samples=len(self.data))
        message = await self.receive()
        self.model.load_version(message.record)


class Server(Entity):
    """Averages the estimates of the clients, weighted by their data size."""

    def __init__(self, entity_id):
        super().__init__(entity_id, with_data=False)
        self.model = MeanModel({"mean": np.zeros(1)})

    async def step(self):
        messages = [await self.receive() for _ in await self.get_neighbors()]
        weights = weighting.normalise(weighting.by_samples(messages))
        average = aggregation.mean([m.record.parameters for m in messages], weights)
        record = self.model.update_version(average, "global")
        self.report(round=record.version[0], estimate=average[0])
        await self.bcast(record)


federation = get_star(Server("server"), [Client(f"client_{i}") for i in range(3)])
data = UniformDataset(list(range(100)))

process = FederatedProcess(federation, data, step_every_ms=100.0, seed=0)
process.run(seconds=5)

last = process.reported[-1]
print("Rounds:", last["round"])
print("Estimate:", round(last["estimate"], 2))

Run it:

python quickstart.py

After the runtime logs, the last two lines show the result:

Rounds: 380
Estimate: 49.5

The clients hold the integers from 0 to 99, so the estimate converges to their mean, 49.5. The number of rounds depends on the speed of your machine.

Nothing above mentions the network. To put one client behind a slow link, describe the infrastructure and pass it to the same process:

from flypse.system import SystemConfig, get_mirror, get_mirror_strategy

infrastructure = get_mirror(federation, seed=0)
infrastructure.edges["client_0", "server"]["latency"] = 500.0  # ms
system = SystemConfig(infrastructure, get_mirror_strategy(federation))

process = FederatedProcess(federation, data, system, step_every_ms=100.0, seed=0)

The server waits for every client, so one slow uplink holds back the whole federation: the same 5 seconds now fit about 9 rounds.

To adapt this experiment, replace the step of the server with one that has a deadline, connect the entities with get_tree or get_ring, or split the data with DirichletDataset. Continue with your first federation and inspecting results.

Strategies

Each module of flypse.strategies is one decision of a federated round. Strategies are called by an entity in its step, on plain numpy vectors, so they combine freely.

Module Decides Examples
selection whom to engage uniform, poisson, proportional, clustered
screening which contributions to use krum, bulyan, dnc, nnm, cosine_bipartition
weighting how much each counts by_samples, polynomial_staleness, metropolis_hastings, pfedgraph
aggregation how they are combined mean, trimmed_mean, geometric_median, centered_clipping
optimization how the model moves SGD, Adam, Yogi, Adagrad, fedexp

Examples

Follow these examples in order, or choose the scenario closest to your experiment:

Runnable source is available in examples/. Run one from the root of the repository, e.g. python -m examples.fedavg.main.

Documentation

Contributing

See CONTRIBUTING.md for development setup, tests, documentation checks, and pull request guidelines.

Publication

If you use FLYPSE in your work, please cite it with the metadata in CITATION.cff. ECLYPSE, which FLYPSE builds on, is described and assessed in:

Jacopo Massa, Valerio De Caro, Stefano Forti, Patrizio Dazzi, Davide Bacciu, Antonio Brogi
ECLYPSE: a Python Framework for Simulation and Emulation of the Cloud-Edge Continuum,
Journal of Software: Evolution and Process, 2026.

@article{massa2026eclypse,
  title     = {{ECLYPSE: A Python Framework for Simulation and Emulation of the Cloud-Edge Continuum}},
  author    = {Massa, Jacopo and De Caro, Valerio and Forti, Stefano and Dazzi, Patrizio and Bacciu, Davide and Brogi, Antonio},
  journal   = {Journal of Software: Evolution and Process},
  volume    = {38},
  number    = {1},
  pages     = {e70081},
  year      = {2026},
  month     = {1},
  doi       = {10.1002/smr.70081},
}

License

FLYPSE is released under the MIT License.

Maintainers

FLYPSE is maintained by Valerio De Caro and Jacopo Massa.

Contact Us

If you want to get in touch with us, drop us an e-mail!

Metadata

Release files for flypse 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for flypse 0.2.0
File Interpreter ABI Platform Actions
flypse-0.2.0-py3-none-any.whl Python 3 none any Details for flypse-0.2.0-py3-none-any.whl

Release files / flypse-0.2.0-py3-none-any.whl

Download URL flypse-0.2.0-py3-none-any.whl
Size 67.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
469be064fb679a652c37b9fd9b6452ff119deaa27608316c40ddaea9b7d5df8b
BLAKE2b-256 checksum
How to use checksums
327419d3ffcb8b56fbd4e6e990327a7e667a3734ab67f8a899af3cc6ae4b8869
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for flypse 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page