Skip to main content

A decentralized gossip learning framework for P2P edge intelligence

Project description

QuinkGL: Gossip Learning Framework

PyPI version Python 3.9+ License: MIT

QuinkGL is a decentralized, peer-to-peer (P2P) machine learning framework designed to enable edge intelligence through Gossip Learning algorithms. Unlike traditional Federated Learning, which relies on a central server for aggregation, QuinkGL distributes the training and aggregation process across all participating nodes.

Key Features

  • Decentralized Architecture – No central parameter server required
  • Gossip Learning – Random walk and gossip-based aggregation for model convergence
  • IPv8 Networking – Native P2P communication with NAT traversal (UDP hole punching)
  • Scalability – Handles dynamic networks with node churn
  • Framework-Agnostic – Supports PyTorch and TensorFlow models
  • Built-in Data Splitting – IID and Non-IID data distribution utilities

Installation

pip install quinkgl

For development:

git clone https://github.com/aliseyhann/QuinkGL-Gossip-Learning-Framework.git
cd QuinkGL-Gossip-Learning-Framework
pip install -e .

Quick Start

import asyncio
import torch.nn as nn
from quinkgl import (
    GossipNode,
    PyTorchModel,
    RandomTopology,
    FedAvg,
    TrainingConfig,
    DatasetLoader,
    FederatedDataSplitter
)

# 1. Define your model
class SimpleNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(784, 128)
        self.fc2 = nn.Linear(128, 10)
        self.relu = nn.ReLU()
    
    def forward(self, x):
        x = x.view(x.size(0), -1)
        return self.fc2(self.relu(self.fc1(x)))

# 2. Wrap the model
model = PyTorchModel(SimpleNet(), device="cpu")

# 3. Create the gossip node
node = GossipNode(
    node_id="alice",
    domain="mnist-vision",
    model=model,
    topology=RandomTopology(),
    aggregation=FedAvg(weight_by="data_size"),
    training_config=TrainingConfig(epochs=1, batch_size=32)
)

# 4. Load and split data
loader = DatasetLoader()
(X, y), info = loader.load_iris()

splitter = FederatedDataSplitter(seed=42)
splits = splitter.create_iid_split(X, y, num_nodes=5)
my_data = splits[0]  # This node's data partition

# 5. Run gossip learning
async def main():
    await node.start()
    await node.run_continuous(data=my_data)

asyncio.run(main())

Public API

Core

Class Description
GossipNode Main P2P gossip learning node with IPv8 networking

Models

Class Description
PyTorchModel Wrapper for PyTorch nn.Module
TensorFlowModel Wrapper for TensorFlow/Keras models
TrainingConfig Training configuration (epochs, batch_size, lr)
TrainingResult Training result with metrics

Topology

Class Description
RandomTopology Random peer selection strategy
CyclonTopology Scalable peer sampling (Cyclon algorithm)
PeerInfo Peer information dataclass

Aggregation

Class Description
FedAvg Federated Averaging aggregation
ModelAggregator Manages train→gossip→aggregate cycle
ModelUpdate Peer model update dataclass

Data

Class Description
DatasetLoader Load common datasets (CIFAR-10, Iris, etc.)
FederatedDataSplitter Create IID/Non-IID data splits

MCP Monitoring (Optional)

Class Description
MetricsCollector Collect metrics from GossipNodes
MCPServer MCP server for AI assistant integration

MCP Integration

QuinkGL includes built-in support for MCP (Model Context Protocol), enabling AI assistants to monitor your experiments:

from quinkgl import GossipNode, MetricsCollector, MCPServer

# Create your gossip node
node = GossipNode(node_id="alice", ...)

# Attach MCP monitoring
collector = MetricsCollector()
collector.attach(node)

# Start MCP server (for AI assistant access)
server = MCPServer(collector)
await server.start()

Available MCP Tools:

  • get_nodes – List all monitored nodes
  • get_training_progress – Training status per node
  • get_accuracy_history – Accuracy over rounds
  • get_model_exchanges – Model send/receive records
  • analyze_convergence – Network convergence analysis

See MCP Integration Guide for full documentation.

Architecture

┌─────────────────────────────────────────────────────────────┐
│                       GossipNode                            │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────┐  ┌──────────────┐  ┌───────────────────┐  │
│  │ PyTorchModel│  │RandomTopology│  │      FedAvg       │  │
│  │ (or TF)     │  │ (or Cyclon)  │  │  (Aggregation)    │  │
│  └─────────────┘  └──────────────┘  └───────────────────┘  │
├─────────────────────────────────────────────────────────────┤
│                    ModelAggregator                          │
│              (Train → Gossip → Aggregate)                   │
├─────────────────────────────────────────────────────────────┤
│                     IPv8 Network Layer                      │
│               (P2P, NAT Traversal, UDP)                     │
└─────────────────────────────────────────────────────────────┘
         │
         │ (Optional MCP Monitoring)
         ▼
┌─────────────────────────────────────────────────────────────┐
│  MetricsCollector ──► MCPServer ──► AI Assistant (Claude)   │
└─────────────────────────────────────────────────────────────┘

License

MIT License © 2025, 28 December - Ali Seyhan, Baki Turhan

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quinkgl-0.2.0.tar.gz (73.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quinkgl-0.2.0-py3-none-any.whl (87.2 kB view details)

Uploaded Python 3

File details

Details for the file quinkgl-0.2.0.tar.gz.

File metadata

  • Download URL: quinkgl-0.2.0.tar.gz
  • Upload date:
  • Size: 73.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for quinkgl-0.2.0.tar.gz
Algorithm Hash digest
SHA256 27f8242d419c4a9db0c8b54d2ab1c3ad9080016f3fe9d3f4e078a9942e9c43c3
MD5 550f544820cbb6c1486fba23a0cd1fdf
BLAKE2b-256 7b62222b58430df0bd32c9c765df4b338e84a49ce09a2049c1e88f77eb258194

See more details on using hashes here.

File details

Details for the file quinkgl-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: quinkgl-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 87.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for quinkgl-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef93e67874995a37c182bcf2874e824cb5d250d4650a170365b01acecd8cf073
MD5 995735e513df430d5723494daeddcbcf
BLAKE2b-256 b22ca755d6516b064caaa397c702573216c0ac582c4e7db316e279c73698704a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page