This repo contains a complete, runnable reference implementation of a DCS-style federated learning simulator:
- DDQL (Double DQN) chooses the action (K, λ) each round
- K = number of selected clients
- λ = trade-off between trust and latency in the scoring function
- Trust score updated via EMA from a lightweight local “quality” proxy
- Latency prediction via EMA
- Stable projection + kNN anomaly filtering
- Uses IncrementalPCA when feasible; otherwise falls back to a fixed random projection
This is intentionally a demo-friendly simulator: it models device heterogeneity, dropouts, and a malicious label-flip attack, while keeping runtime reasonable.
- We recommend running in a fresh virtual environment with Python 3.x to improve compatibility across package versions and reproducibility.
- The repo uses a src/ layout (e.g., src/dcs/), so you must add src to PYTHONPATH. Such as: !PYTHONPATH=$PWD python -u scripts/run_demo.py --config configs/default.yaml
pip install -r requirements.txt
# Run the main demo (DCS vs FedAvg vs ScoreOnly) + bar charts
python scripts/run_demo.py --config configs/default.yaml
# Run hyperparameter sensitivity sweeps (bars generated from runs, not copied from tables)
python scripts/run_sensitivity.py --config configs/default.yaml --out outputs/sensitivityOutputs (CSVs + PNGs) go to outputs/ by default.
In Colab, you can:
- Upload this repository as a zip OR
git cloneit. - Run:
!pip -q install -r requirements.txt
!python scripts/run_demo.py --config configs/default.yamlEdit configs/default.yaml:
DATASET: mnist # mnist | fashion_mnist | cifar10Notes:
mnistandfashion_mnistare faster.cifar10is slower due to a larger CNN.
You can also reduce runtime by setting:
MAX_TRAIN_SAMPLES: 20000
MAX_TEST_SAMPLES: 5000
ROUNDS: 10All hyperparameters live in configs/default.yaml.
NUM_CLIENTS,NUM_EDGESROUNDS,LOCAL_EPOCHS,BATCH_SIZELR,MOMENTUM
DIRICHLET_ALPHA(α)
K_MIN,K_MAX,K_STEPLAM_GRID(λ values DDQL can choose)
TRUST_ALPHA(EMA factor)LAT_EMA(EMA factor)
PCA_RANKANN_NEIGHBORSCONTAMINATION
DDQL_GAMMA(discount γ)DDQL_EPS_*,DDQL_TAU,DDQL_LR
scripts/run_sensitivity.py runs short experiments across grids and produces bar charts like:
- α (Dirichlet non-IID)
- γ (DDQL discount)
ANN_NEIGHBORS- λ-grid sweep (fixed scoring mode)
These bars come from measured runs with the same simulator.
src/dcs/– core simulator and algorithmsscripts/run_demo.py– DCS vs baselines + bar chartsscripts/run_sensitivity.py– hyperparameter sweeps + bar chartsconfigs/default.yaml– editable config