This repository contains the experimental prototype for DFL-C, a decentralized federated learning framework for studying model consistency and Byzantine resilience in collaborative learning settings.
The code supports multi-worker training, IID and non-IID data partitioning, several Byzantine attack modes, multiple aggregation baselines, and CIFAR-10 experiments with LeNet and ResNet models.
.
├── manager.py
├── worker.py
├── cifar-10_download.py
├── f-mnist_download.py
└── README.md
manager.py launches multiple worker processes and collects their outputs.
worker.py implements local training, data partitioning, model exchange, aggregation, attack simulation, checkpointing, and evaluation.
cifar-10_download.py downloads CIFAR-10 and saves the train/test splits as serialized PyTorch TensorDataset files.
f-mnist_download.py prepares Fashion-MNIST in the same format. The current worker.py accepts CIFAR-10 only, so Fashion-MNIST support requires adapting load_dataset_by_tag().
The current worker implementation is GPU-only and exits if CUDA is unavailable.
Recommended environment:
Python 3
PyTorch
torchvision
NumPy
CUDA-capable NVIDIA GPU
torchvision is required by the dataset preparation scripts. The worker itself loads preprocessed .pt datasets.
Example installation:
pip install torch torchvision numpyUse a PyTorch build compatible with your CUDA installation.
Prepare CIFAR-10 before running the experiment:
python3 cifar-10_download.pyThis generates:
processed_train_data_CIFAR-10.pt
processed_test_data_CIFAR-10.pt
The files must be placed in the repository root because worker.py loads them from the current working directory.
Fashion-MNIST can be downloaded with:
python3 f-mnist_download.pywhich generates:
processed_train_data_f-MNIST.pt
processed_test_data_f-MNIST.pt
The current worker does not yet load these Fashion-MNIST files.
The easiest way to run the prototype is through manager.py:
python3 manager.pyThe default manager configuration currently runs:
model: ResNet-18
workers: 10
rounds: 10
dataset: CIFAR-10
partition: IID
consensus mode: acs
Byzantine modes: nobyzantine, label_flipping
aggregation modes: average, flare
Experiment configurations can be changed directly in the loops near the bottom of manager.py.
Each worker can also be started manually:
python3 worker.py \
<model_name> \
<worker_id> \
<worker_list_csv> \
<rounds> \
<dataset_tag> \
<iid> \
<aggregation_method> \
<byzantine> \
<acs>Example:
python3 worker.py r18 0 0,1,2,3 10 CIFAR-10 iid average nobyzantine acsworker.py currently supports:
lenet5
lenetn
r18
r34
r50
r101
r152
The ResNet implementations are adapted for 32x32 CIFAR-10 inputs.
Supported values include:
iid
non-IID-6
For iid, each worker receives a contiguous shard of the dataset.
For non-IID-6, each worker deterministically selects six classes and samples its local shard from those classes.
During training, the worker uses a progressive data schedule. In round r of R, approximately r/R of that worker's local partition is used.
The current code provides:
average
multi_krum
flare
trust
average performs standard parameter averaging.
multi_krum applies a Multi-Krum-style distance-based selection before averaging.
flare is the lightweight trust-weighting baseline implemented in this repository. It evaluates one-batch loss changes, smooths them with an exponential moving average, and converts them into aggregation weights. This option should not be interpreted as a complete reproduction of the original FLARE PLR/MMD algorithm.
trust computes a gradient-direction similarity score relative to a locally constructed reference and uses the resulting scores for weighted aggregation.
The code contains support for:
nobyzantine
label_flipping
backdoor
gaussian
scaling
model_replace
label_flipping shifts labels by one class for malicious workers.
backdoor poisons a subset of local samples with a small trigger and maps them to target class 0.
gaussian, scaling, and model_replace directly manipulate model parameters.
In the current prototype, workers with IDs above approximately the first two thirds of the configured worker list are treated as malicious.
The command-line interface accepts:
acs
t-acs
The current release uses a local experimental abstraction for these modes. Worker communication is emulated through filesystem queues, and the t-acs branch filters the received model set according to the prototype's configured worker-ID rule.
This code therefore reproduces selected learning-side and aggregation experiments. It is not a standalone network implementation of the complete asynchronous common subset protocol described in the DFL-C paper.
Each worker writes its files under:
./log/<worker_id>/
including:
log.txt
checkpoint.pth
queue/
The manager also creates one experiment-level log file such as:
log_r18_10_CIFAR-10_iid_average_nobyzantine_acs.txt
Worker logs report local training loss, local accuracy, aggregation results, and backdoor attack success rate when applicable.
Workers are launched as independent Python processes. Model exchange is currently implemented through shared filesystem queues under ./log/<worker_id>/queue.
All workers should therefore run from the same working directory or from an environment that provides a consistent shared filesystem.
The implementation is intended as a research prototype for controlled experiments rather than a production distributed-learning runtime.
CuDNN benchmarking is disabled and deterministic CuDNN execution is enabled in worker.py.
The non-IID partition uses deterministic NumPy seeds derived from worker rank.
The local data order used by the progressive training schedule is also deterministically shuffled using a worker-specific seed.
For the flare and trust aggregation modes, the current code passes the worker's test loader as the shared auxiliary loader. For strict experimental separation, replace this with a dedicated held-out auxiliary dataset before using these modes in new evaluations.
Model-Consistent Byzantine-Resilient Decentralized Federated Learning for Collaborative Missions
Yue Li, Sudip Bhujel, Cameron Lira, Ning Wang, and Yang Xiao.
If you use this repository in academic work, please cite the DFL-C paper.
@inproceedings{dflc2026,
title = {Model-Consistent Byzantine-Resilient Decentralized Federated Learning for Collaborative Missions},
author = {Li, Yue and Bhujel, Sudip and Lira, Cameron and Wang, Ning and Xiao, Yang},
booktitle = {IEEE Conference on Communications and Network Security (CNS)},
year = {2026}
}This repository is released as research code. Before extending the system to new datasets, larger deployments, or real network environments, review the current assumptions in worker.py, especially the CUDA requirement, shared-filesystem communication, worker-ID-based Byzantine assignment, and experimental ACS abstraction.