A distributed privacy-preserving machine learning framework implemented with PyTorch and MPI.
Split learning partitions a neural network across multiple machines: each client node holds the initial layers and processes its own raw data locally, sending only intermediate activations (the "split layer" output) to the server. The server holds the deeper layers, computes the loss, and sends gradients back. Raw data never leaves the client.
This repo implements split learning on FashionMNIST and compares it against standard centralized training.
Client 1 ──┐
Client 2 ──┼──→ [split layer tensors] ──→ Server (deeper layers + loss)
Client N ──┘ ←── [gradients] ──────────────────────────────────
Model split (LeNet-style CNN):
- Client: Conv2d(1→6) → ReLU → MaxPool2d
- Server: Conv2d(6→16) → ReLU → MaxPool2d → FC(256→120) → FC(120→84) → FC(84→10)
Nodes communicate via tagged MPI messages:
| Tag | Direction | Purpose |
|---|---|---|
tensor_and_labels |
Client → Server | Split layer activations + labels |
gradients |
Server → Client | Backpropagated gradients |
worker_done / epoch_done |
Client ↔ Server | Epoch synchronization |
Comienzo |
Client → Client | Barrier sync (ring coordination) |
training_complete |
Server → Client | Signal end of training |
Clients form a coordination ring — each waits for a signal from its predecessor before starting the next iteration, ensuring all nodes progress through epochs in lockstep.
Requirements: Python 3, PyTorch, torchvision, MPI (mpirun)
pip install -r requirements.txtConfigure your nodes in hostfile.txt (one IP per line):
192.168.1.1
192.168.1.2
192.168.1.3
Split learning (distributed):
mpirun -np 3 -hostfile ~/Split_Learning/hostfile.txt python ~/Split_Learning/split_learning.pyRegular (centralized) baseline:
python regular_learning.py --epochs 10 --batch_size 64 --learning_rate 0.01| Flag | Default | Description |
|---|---|---|
--batch_size |
64 | Training batch size |
--test_batch_size |
1000 | Test batch size |
--epochs |
10 | Number of epochs |
--learning_rate |
0.01 | SGD learning rate |
--log_steps |
50 | Logging frequency (batches) |
Plots saved to ~/Split_Learning/plots/:
test_loss_reg.pdf— test loss curvetest_acc_reg.pdf— test accuracy curve
- Split Learning for Health — Vepakomma et al., MIT
- FashionMNIST