Metadata-Version: 2.1
Name: byzfl
Version: 0.0.4
Summary: ByzFL Library
Home-page: https://github.com/LPD-EPFL/byzfl
Author: Geovani Rizk
Author-email: geovani.rizk@epfl.ch
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: torch>=2.2.0
Requires-Dist: torchvision>=0.17.0
Requires-Dist: numpy>=1.26.4
Requires-Dist: matplotlib>=3.8.3
Requires-Dist: scipy>=1.12.0

# ByzFL Documentation

Welcome to the **official documentation of ByzFL**, developed by [DCL](http://dcl.epfl.ch) at [EPFL](http://epfl.ch) and [WIDE](https://team.inria.fr/wide/) at [INRIA Rennes](https://www.inria.fr/fr/centre-inria-universite-rennes)!

---

## What is ByzFL?

ByzFL is a **Python library for Byzantine-resilient Federated Learning**. It is fully compatible with both [PyTorch](http://pytorch.org) tensors and [NumPy](http://numpy.org) arrays, making it versatile for a wide range of machine learning workflows.

### Key Features

1. **Robust Aggregators and Pre-Aggregators**: 
   - Aggregate gradients robustly while mitigating the impact of Byzantine participants.
2. **Byzantine Attacks**: 
   - Simulate and evaluate different attack strategies to test resilience.
3. **Machine Learning Pipelines**: 
   - Train and benchmark robust aggregation schemes and attack implementations seamlessly.

---

## Installation

Install the ByzFL library using pip:

```bash
pip install byzfl
```

After installation, the library is ready to use. Here’s a quick example of how to use the `Trmean` robust aggregator and the `SignFlipping` Byzantine attack:

---

## Quick Start Example

```python
import byzfl
import numpy as np

# Number of Byzantine participants
f = 1

# Honest vectors
honest_vectors = np.array([[1., 2., 3.],
                           [4., 5., 6.],
                           [7., 8., 9.]])

# Initialize and apply the attack
attack = byzfl.SignFlipping()
byz_vector = attack(honest_vectors)

# Create f identical attack vectors
byz_vectors = np.tile(byz_vector, (f, 1))

# Concatenate honest and Byzantine vectors
all_vectors = np.concatenate((honest_vectors, byz_vectors), axis=0)

# Initialize and perform robust aggregation
aggregate = byzfl.Trmean(f=f)
result = aggregate(all_vectors)
print("Aggregated result:", result)
```

**Output:**

```
Aggregated result: [2.5 3.5 4.5]
```

---

## Learn More

Explore the key components of ByzFL:

- [Aggregators](https://byzfl.epfl.ch/aggregators/index.html)  
  Learn about robust aggregation methods.
- [Attacks](https://byzfl.epfl.ch/attacks/index.html)  
  Discover Byzantine attack implementations.
- [Pipeline](https://byzfl.epfl.ch/pipeline/index.html)  
  Build and benchmark your models.

---

## License

ByzFL is open-source and distributed under the [MIT License](https://github.com/LPD-EPFL/byzfl/blob/main/LICENSE.txt).

Contributions are welcome!
