# lpd-epfl/byzfl architecture

> Architecture diagram of the GitHub repository lpd-epfl/byzfl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lpd-epfl/byzfl
- Repository: https://github.com/lpd-epfl/byzfl

## Overview

ByzFL is a Python library for robust federated learning, combining standalone aggregation and attack algorithms with a simulation framework and benchmarking capability. The principal workflow distributes training data, computes honest-client gradients, creates Byzantine updates, and applies configured robust aggregation to update and evaluate a global model. Benchmarking is documented as a separate capability. Unsampled benchmark internals and some framework wiring are represented at subsystem level; edges rely on README statements or the cited source excerpts.

Main entry points: [`byzfl/fed_framework/client.py`](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/client.py) (Honest client), [`byzfl/fed_framework/server.py`](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/server.py) (Federated server), [`byzfl/fed_framework/model_base_interface.py`](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/model_base_interface.py) (Model interface), [`byzfl/utils/misc.py`](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/utils/misc.py) (Array utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_algorithms["Robust algorithms"]
  node_aggregators["Robust aggregators<br/>[aggregators.py]"]
  node_preaggregators["Pre-aggregators<br/>[preaggregators.py]"]
  node_attacks["Byzantine attacks<br/>[attacks.py]"]
end

subgraph group_simulation["Federated simulation"]
  node_data["Data distribution"]
  node_client["Honest client<br/>[client.py]"]
  node_byzclient["Byzantine client"]
  node_server["Federated server<br/>[server.py]"]
  node_robust["Robust aggregation"]
end

subgraph group_models["Models and utilities"]
  node_modelspec["Model definitions<br/>[models.py]"]
  node_modelbase["Model interface"]
  node_conversion["Parameter conversion<br/>[conversion.py]"]
  node_misc["Array utilities<br/>[misc.py]"]
  node_torchtools["Torch operations<br/>[torch_tools.py]"]
end

subgraph group_evaluation["Benchmarking"]
  node_benchmark["Adversarial benchmarks"]
end

subgraph group_actors["Participants"]
end

node_user(("Experimenter"))

node_user -->|"configures data"| node_data
node_data -->|"splits training data"| node_client
node_user -->|"configures clients"| node_client
node_client -->|"submits gradients"| node_server
node_user -->|"configures attack"| node_byzclient
node_byzclient -->|"applies attack"| node_attacks
node_byzclient -->|"supplies faulty updates"| node_server
node_server -->|"aggregates updates"| node_robust
node_robust -->|"uses aggregator"| node_aggregators
node_robust -->|"uses preprocessing"| node_preaggregators
node_server -->|"inherits model interface"| node_modelbase
node_client -->|"inherits model interface"| node_modelbase
node_modelbase -->|"instantiates model"| node_modelspec
node_modelbase -->|"flattens parameters"| node_conversion
node_client -->|"flattens gradients"| node_conversion
node_aggregators -->|"normalizes vectors"| node_misc
node_preaggregators -->|"normalizes vectors"| node_misc
node_attacks -->|"normalizes vectors"| node_misc
node_misc -->|"dispatches torch ops"| node_torchtools
node_user -->|"runs evaluations"| node_benchmark
node_server -->|"reports accuracy"| node_user

click node_data "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/data_distributor.py"
click node_client "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/client.py"
click node_byzclient "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/byzantine_client.py"
click node_server "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/server.py"
click node_robust "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/robust_aggregator.py"
click node_modelspec "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/models.py"
click node_modelbase "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/model_base_interface.py"
click node_conversion "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/utils/conversion.py"
click node_misc "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/utils/misc.py"
click node_torchtools "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/utils/torch_tools.py"
click node_aggregators "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/aggregators/aggregators.py"
click node_preaggregators "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/aggregators/preaggregators.py"
click node_attacks "https://github.com/lpd-epfl/byzfl/blob/main/byzfl/attacks/attacks.py"
click node_benchmark "https://github.com/lpd-epfl/byzfl/tree/main/byzfl/benchmark"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_aggregators,node_preaggregators,node_attacks toneBlue
class node_data,node_client,node_byzclient,node_server,node_robust toneAmber
class node_modelspec,node_modelbase,node_conversion,node_misc,node_torchtools toneMint
class node_benchmark toneRose
class node_user toneIndigo
```

## Components

### Robust algorithms

- [Robust aggregators](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/aggregators/aggregators.py): `byzfl/aggregators/aggregators.py`
- [Pre-aggregators](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/aggregators/preaggregators.py): `byzfl/aggregators/preaggregators.py`
- [Byzantine attacks](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/attacks/attacks.py): `byzfl/attacks/attacks.py`

### Federated simulation

- [Data distribution](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/data_distributor.py): `byzfl/fed_framework/data_distributor.py`
- [Honest client](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/client.py): `byzfl/fed_framework/client.py`
- [Byzantine client](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/byzantine_client.py): `byzfl/fed_framework/byzantine_client.py`
- [Federated server](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/server.py): `byzfl/fed_framework/server.py`
- [Robust aggregation](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/robust_aggregator.py): `byzfl/fed_framework/robust_aggregator.py`

### Models and utilities

- [Model definitions](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/models.py): `byzfl/fed_framework/models.py`
- [Model interface](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/fed_framework/model_base_interface.py): `byzfl/fed_framework/model_base_interface.py`
- [Parameter conversion](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/utils/conversion.py): `byzfl/utils/conversion.py`
- [Array utilities](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/utils/misc.py): `byzfl/utils/misc.py`
- [Torch operations](https://github.com/lpd-epfl/byzfl/blob/main/byzfl/utils/torch_tools.py): `byzfl/utils/torch_tools.py`

### Benchmarking

- [Adversarial benchmarks](https://github.com/lpd-epfl/byzfl/tree/main/byzfl/benchmark): `byzfl/benchmark`

### Other components

- **Experimenter**

## Connections

- Experimenter → Data distribution: configures data (evidence: `README.md`)
- Data distribution → Honest client: splits training data (evidence: `README.md`)
- Experimenter → Honest client: configures clients (evidence: `README.md`)
- Honest client → Federated server: submits gradients (evidence: `README.md`)
- Experimenter → Byzantine client: configures attack (evidence: `README.md`)
- Byzantine client → Byzantine attacks: applies attack (evidence: `byzfl/fed_framework/byzantine_client.py`)
- Byzantine client → Federated server: supplies faulty updates (evidence: `README.md`)
- Federated server → Robust aggregation: aggregates updates (evidence: `byzfl/fed_framework/server.py`)
- Robust aggregation → Robust aggregators: uses aggregator (evidence: `byzfl/fed_framework/robust_aggregator.py`)
- Robust aggregation → Pre-aggregators: uses preprocessing (evidence: `byzfl/fed_framework/robust_aggregator.py`)
- Federated server → Model interface: inherits model interface (evidence: `byzfl/fed_framework/server.py`)
- Honest client → Model interface: inherits model interface (evidence: `byzfl/fed_framework/client.py`)
- Model interface → Model definitions: instantiates model (evidence: `byzfl/fed_framework/model_base_interface.py`)
- Model interface → Parameter conversion: flattens parameters (evidence: `byzfl/fed_framework/model_base_interface.py`)
- Honest client → Parameter conversion: flattens gradients (evidence: `byzfl/fed_framework/client.py`)
- Robust aggregators → Array utilities: normalizes vectors (evidence: `byzfl/aggregators/aggregators.py`)
- Pre-aggregators → Array utilities: normalizes vectors (evidence: `byzfl/aggregators/preaggregators.py`)
- Byzantine attacks → Array utilities: normalizes vectors (evidence: `byzfl/attacks/attacks.py`)
- Array utilities → Torch operations: dispatches torch ops (evidence: `byzfl/utils/misc.py`)
- Experimenter → Adversarial benchmarks: runs evaluations (evidence: `README.md`)
- Federated server → Experimenter: reports accuracy (evidence: `README.md`)
