This repository contains the official implementation of Lancelot, a compute-efficient Byzantine-robust federated learning system with fully homomorphic encryption, as published in Nature Machine Intelligence.
Lancelot addresses two critical challenges in federated learning:
- Byzantine Robustness: Defending against malicious clients that may send corrupted model updates
- Privacy Protection: Using fully homomorphic encryption to protect client data and model updates
The system leverages GPU acceleration through the CAHEL library for efficient homomorphic computations.
- [2025-08-28] π₯ Paper accepted by Nature Machine Intelligence
- [2025-08-20] π₯ Code Ocean capsule verified
- [2025-08-15] π₯ Added end-to-end execution script (
run.sh) - [2025-08-10] π₯ GPU acceleration optimizations
Lancelot/
βββ cahel-main/ # HomoMul GPU Accelerator (CAHEL library)
β βββ include/ # Header files for CAHEL
β βββ src/ # Core CAHEL implementation
β βββ python/ # Python bindings
β βββ examples/ # CAHEL usage examples
βββ lancelot-main-GPU/ # Main Lancelot implementation
βββ main.py # Training entry point
βββ src/ # Core aggregation and update logic
βββ utils/ # Utilities (options, datasets, attacks, etc.)
βββ run_lancelot.sh # Execution script
- Hardware: NVIDIA GPU with β₯24GB RAM (e.g., RTX 4090, Tesla V100)
- Software:
- CMake β₯ 3.25.0
- GCC β₯ 9.4.0
- CUDA Toolkit
- Python 3.8+
- Conda (recommended)
# Clone the repository
git clone https://github.com/siyang-jiang/Lancelot.git
cd Lancelot
# Run the complete setup and training pipeline
bash run.shrun.sh (line 32):
- For RTX 4090:
DCMAKE_CUDA_ARCHITECTURES=89 - For Tesla T4:
DCMAKE_CUDA_ARCHITECTURES=75 - For Tesla V100:
DCMAKE_CUDA_ARCHITECTURES=70
# Update Ubuntu and install dependencies
sudo apt-get update
sudo apt-get install -y software-properties-common lsb-release
sudo apt-get clean all
# Add CMake repository
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main'
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo apt-key add -
sudo apt-get update
# Install CMake
sudo dpkg --configure -a
sudo apt install cmakecd cahel-main
# Deactivate conda if active
conda deactivate
# Configure and build
cmake -S. -Bbuild -DCMAKE_CUDA_ARCHITECTURES=89 # Adjust for your GPU
cmake --build build -j8cd build
conda activate your_environment # Activate your preferred environment
# Install conda-build if not available
conda install conda-build
# Link the built library
conda develop libcd ../lancelot-main-GPU
pip install torch torchvision tqdm tensorboard numpycd lancelot-main-GPU
bash run_lancelot.shpython main.py \
--dataset CIFAR10 \
--num_clients 10 \
--c_frac 0.2 \
--global_ep 100 \
--method krum \
--cipher_open 1| Parameter | Description | Default |
|---|---|---|
--dataset |
Dataset (CIFAR10, MNIST, FaMNIST) | CIFAR10 |
--num_clients |
Number of federated clients | 4 |
--c_frac |
Fraction of compromised clients | 0.0 |
--method |
Aggregation method (krum, trimmed_mean) | krum |
--cipher_open |
Enable homomorphic encryption | 0 |
--global_ep |
Number of communication rounds | 100 |
--lr |
Learning rate | 0.001 |
- Untargeted attacks: Random noise injection
- Targeted attacks: Model poisoning with specific objectives
- Data poisoning: Corrupted training data
- Krum: Robust aggregation based on geometric median
- Trimmed Mean: Outlier removal and averaging
- Homomorphic Encryption: Privacy-preserving computation
The system provides detailed timing analysis:
- Local training time
- Encryption/decryption overhead
- Aggregation computation time
- End-to-end communication rounds
Results are logged and can be visualized using TensorBoard:
tensorboard --logdir runs/If you use Lancelot in your research, please cite:
@article{jiang2025towards,
title={Towards compute-efficient Byzantine-robust federated learning with fully homomorphic encryption},
author={Jiang, Siyang and Yang, Hao and Xie, Qipeng and Ma, Chuan and Wang, Sen and Liu, Zhe and Xiang, Tao and Xing, Guoliang},
journal={Nature Machine Intelligence},
pages={1--12},
year={2025},
publisher={Nature Publishing Group UK London}
}We welcome contributions! Please see our contribution guidelines for details.
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Email: Contact the authors for research collaboration
- Code Ocean: Verified capsule available (link coming soon)
- CAHEL library for GPU-accelerated homomorphic encryption
- OpenFHE library for comparison benchmarks
- The federated learning research community