You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FEDSIM - A Flexible and Lightweight Federated Learning Simulation Framework
FEDSIM is a visualization-first platform for simulating, benchmarking, and analyzing federated learning systems under adversarial conditions. It provides a Streamlit dashboard for interactive exploration and a Python scripting API for reproducible experiments. Built for FL researchers, FEDSIM enables systematic comparison of aggregation strategies, attack models, and defense mechanisms, it is meant to be customizable and lightweight.
Features
Dashboard
Live training visualization — Loss and accuracy curves updated in real-time
Client activity grid — Per-client, per-round status heatmap with six states: benign, attacked, malicious idle, not selected, excluded (caught), excluded (false positive)
Trust-based with cosine-similarity server reference
Yes
FedProx
custom:FedProx
Proximal regularization (Li et al. 2020)
Attacks
Attack
Key
Type
Key Parameters
Label Flipping
label_flipping
Data
—
Gaussian Noise
gaussian_noise
Data
snr_db
Token Replacement
token_replacement
Data
replace_fraction
Weight Spiking
weight_spiking
Model
spike_fraction, magnitude
Gradient Scaling
gradient_scaling
Model
scale_factor
Byzantine Perturbation
byzantine_perturbation
Model
perturbation_scale
Writing Plugins
Custom Strategy
# Save as custom/strategies/my_strategy.pyfromfl_coreimportFedAvg, FitRes, NDArraysNAME="My Strategy"DESCRIPTION="A custom aggregation strategy"PARAMS= {
"beta": {"type": "float", "default": 0.1, "min": 0.0, "max": 1.0,
"label": "Trimming Parameter"},
}
defbuild(initial_parameters, num_clients, num_malicious=0, **kwargs):
beta=kwargs.pop("beta", PARAMS["beta"]["default"])
returnMyStrategy(beta=beta, initial_parameters=initial_parameters, **kwargs)
# Optional: override client training (like FedProx)deftrain_step(model, batch, optimizer, device, **kwargs):
"""Called per batch instead of the default training loop."""images, labels=batchimages, labels=images.to(device), labels.to(device)
optimizer.zero_grad()
loss=torch.nn.functional.cross_entropy(model(images), labels)
loss.backward()
optimizer.step()
return {"loss": loss.item()}
Custom Dataset
# Save as custom/datasets/my_dataset.pyNAME="My Dataset"NUM_CLASSES=10INPUT_CHANNELS=3IMAGE_SIZE=32TASK_TYPE="image_classification"defload(**kwargs):
train_dataset= ... # torch.utils.data.Datasettest_dataset= ...
returntrain_dataset, test_dataset
Custom Model
# Save as custom/models/my_model.pyimporttorch.nnasnnNAME="My Model"COMPATIBLE_TASKS= ["image_classification"]
defbuild(dataset_info, **kwargs):
num_classes=dataset_info["num_classes"]
returnMyNet(num_classes)
Scripting API
Experiment
fromapiimportExperimentexp=Experiment("My Study")
exp.add_run("run_name", SimulationConfig(...))
results=exp.run(checkpoint_path="results/my_study.json")
# Access resultsresults.final_accuracy("run_name") # Last accuracy (first strategy)results.final_accuracy("run_name", strategy_idx=1) # Second strategyresults.names# All run namesresults.items() # Iterate (name, results) pairs# Save/loadexp.save("results/my_study.json")
loaded=Experiment.load("results/my_study.json")
# Export configs for dashboard executionexp.export_configs("results/my_configs.json")
# Then upload to dashboard via Load Experiment in the sidebar
Report
fromapiimportReportreport=Report("My Report Title")
report.add_text("Introduction", "Description of the experiment...")
report.add_convergence_plot(results, ["run1", "run2"], title="Convergence")
report.add_accuracy_table(results)
report.add_heatmap(data, row_labels, col_labels, title="Heatmap")
report.save_pdf("my_report.pdf")
GPU Acceleration
When a CUDA GPU is available, three acceleration options appear in the dashboard sidebar:
Option
Config Field
Speedup
How It Works
Mixed Precision
use_amp=True
~1.5x
Float16 forward/backward via tensor cores
torch.compile
compile_model=True
~1.2x
Graph compilation (graceful fallback if unavailable)
Pin Memory
pin_memory=True
~1.05x
Pinned host memory for async CPU-GPU transfers
Built-in Datasets
Dataset
Key
Classes
Size
Type
MNIST
mnist
10
60K/10K
Grayscale 28x28
CIFAR-10
cifar10
10
50K/10K
RGB 32x32
CIFAR-100
cifar100
100
50K/10K
RGB 32x32
Fashion-MNIST
fashion_mnist
10
60K/10K
Grayscale 28x28
SVHN
svhn
10
73K/26K
RGB 32x32
FEMNIST
femnist
62
731K/82K
Grayscale 28x28
PathMNIST
pathmnist
9
89K/7K
RGB 28x28
DermaMNIST
dermamnist
7
7K/2K
RGB 28x28
BloodMNIST
bloodmnist
8
11K/3K
RGB 28x28
OrganAMNIST
organamnist
11
34K/8K
Grayscale 28x28
Plugin datasets: AG News (text, 4-class), California Housing (regression), WikiText-2 (language modeling)
About
FEDSIM is a visualization-first platform for simulating, benchmarking, and analyzing federated learning systems under adversarial conditions.