How arsalanyavari/fl-wireless works
Project type and purpose
• This is a research-oriented Python implementation of a federated-learning (FL) framework over wireless channels, based on the IEEE paper “A Joint Learning and Communications Framework for Federated Learning over Wireless Networks.”
• It includes three main concerns: (a) FL simulation (train.py + log.py), (b) configuration management (config.py / config.toml), (c) result visualization (codes_draw_paper_plots/*.py).
File structure
• Top level:
– train.py: entry point for running simulations
– config.py & config.toml: programmatic and TOML-based config definitions
– log.py: logging utilities for metrics and events
– codes_draw_paper_plots/: scripts to load logs and produce paper-style plots (MNIST, LR experiments)
– data/MNIST/raw/: raw data files for local client datasets
• No explicit “src” or “backend/frontend” split—this is a single-process simulation engine.
README for technical stack
• Pure Python (3.8–3.10), managed by Poetry (preferred) or venv + requirements.txt
• Dependencies (likely numpy, torch or TensorFlow, toml, matplotlib)
• No external microservices—everything runs locally.
Break down the system into components and relationships
a. Main components:
1. Configuration Module
– config.py (defines Config classes)
– config.toml (user-editable parameters: number of clients, wireless channel settings, learning rates, dataset paths)
2. Data Storage
– data/MNIST/raw: local dataset shards for each simulated client
3. FL Simulation Engine (train.py orchestrates everything)
– Data Loader (reads MNIST, partitions among clients)
– Client Agents (perform local training loops)
– Wireless Channel Simulator (applies channel effects, SNR, path loss per round)
– Aggregation Server (averages client updates)
4. Logging Subsystem (log.py)
– Collects metrics per round: loss, accuracy, channel metrics
– Writes to disk or memory buffers
5. Plotting Utilities (codes_draw_paper_plots/*.py)
– Read log outputs
– Generate training curves (MNIST, logistic regression) for paper figures
6. Dependency/Environment Manager
– Poetry or venv + requirements.txt
b. Relationships & interactions:
• Configuration → FL Simulation Engine (train.py reads config)
• Data Storage → Data Loader → Client Agents
• Client Agents ↔ Wireless Channel Simulator → Aggregation Server
• Aggregation Server → updated global model → Client Agents (next round)
• FL Simulation Engine → Logging Subsystem → log files
• Plotting Utilities → read log files → output figures
• Poetry/venv → installs dependencies → supports all other modules
c. Architectural patterns/design principles:
• Layered architecture: Configuration → Core Simulation → Logging → Visualization
• Separation of concerns: simulation logic decoupled from plotting
• Extensibility points: channel model, client count, dataset type—all passed via config
d. Key technologies:
• Python 3.8–3.10
• toml or Python dataclasses for config
• numpy/torch (implicit ML backend)
• matplotlib or similar for plotting
• Poetry / virtualenv for dependency management
Summary of essential elements
• Clearly label: Config, Data Storage, FL Engine (with its internal blocks), Logger, Plotter, Environment Manager
• “round-trip” of federated updates through the wireless channel to the server and back