swarmint

Learning without a center.

Decentralized, Byzantine-robust swarm learning.

Thousands of tiny models each learn from their own local data and gossip knowledge peer-to-peer over a real P2P network. No central server. No gradient sharing. No raw data ever leaves the device — and the swarm keeps converging even while malicious nodes try to poison it.

AGPL-3.0  ·  Python 3.10+  ·  v0.1 (research prototype)  ·  81 tests passing

Why swarmint

Federated learning that averages neural-net weights is fragile and usually needs a central coordinator. swarmint removes both: order-invariant prototype merging eliminates the averaging problem, and gossip over a DHT eliminates the coordinator.

No central serverPeers discover each other over a Kademlia DHT and gossip directly. Nothing to run, nothing to trust in the middle.
No gradient sharingNodes exchange bounded sets of labeled prototypes, not gradients or raw data. Merging is order-invariant, so there's no weight-averaging fragility.
Poison-resistantMerge-validation, corroboration, and reputation make label-flip attacks fail. Malicious nodes lose trust and get ignored.

It works on real data

Each node sees only a slice of the classes; gossip pools them so every node approaches full-task accuracy — validated on synthetic and two real datasets.

SettingSolo baselineSwarmNotes
Synthetic · 100 nodes · 5% malicious0.200.96stable, Byzantine-robust
Real digits · 10-class0.200.78 → 0.880.88 with a shared genesis embedding
Real faces · 40-class, few-shot0.050.5110× solo on a brutal dataset
Distributed inference · 30% liars0.200.79mixture-of-experts across peers

Centralized full-nearest-neighbor ceilings are 0.93 (digits) / 0.83 (faces) — the swarm reaches these while staying decentralized and poison-resistant.

What's inside

Gossip federation

Push-based prototype gossip with corroboration — each node learns classes it never saw locally, pooled from the swarm.

Byzantine trust

Reputation + merge-rollback + majority corroboration. Poisoned updates are rejected; attackers' trust collapses.

Real P2P stack

UDP transport, Kademlia DHT discovery, peer-exchange, Ed25519-signed messages with replay protection, and NAT hole-punching.

Distributed inference

Trust-weighted mixture-of-experts: a node answers queries about classes it never learned by consulting the swarm.

Tamper-evident history

Each node keeps a signed, append-only hash-chain of its model checkpoints — auditable and non-repudiable, no consensus required.

Multimodal & embeddings

Encoder-free late fusion across modalities, plus an optional shared genesis embedding that lifts accuracy toward centralized.

Quickstart

Runs on numpy alone. See gossip beat solo in one command.

# install (core is numpy-only; extras add real P2P + real-data validation)
git clone https://github.com/shaswata56/swarmint
cd swarmint && pip install -e ".[dev]"

# smallest end-to-end: specialists gossip into a full-task model
python examples/quickstart.py
#  each node sees only 2 of 6 classes  (solo ceiling ~ 0.33)
#  solo node (no gossip)  : 0.333
#  swarm node (gossip)    : 0.855

# real data, and real UDP + DHT across OS processes
python -m swarmint.sim.run_digits
python -m swarmint.sim.run_multiproc