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

Architecture

┌─────────────────────────────────────────────────────────────┐
│                       GossipNode                            │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────┐  ┌──────────────┐  ┌───────────────────┐  │
│  │ PyTorchModel│  │RandomTopology│  │      FedAvg       │  │
│  │ (or TF)     │  │ (or Cyclon)  │  │  (Aggregation)    │  │
│  └─────────────┘  └──────────────┘  └───────────────────┘  │
├─────────────────────────────────────────────────────────────┤
│                    ModelAggregator                          │
│              (Train → Gossip → Aggregate)                   │
├─────────────────────────────────────────────────────────────┤
│                     IPv8 Network Layer                      │
│               (P2P, NAT Traversal, UDP)                     │
└─────────────────────────────────────────────────────────────┘

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.1.10.tar.gz (65.0 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.1.10-py3-none-any.whl (77.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for quinkgl-0.1.10.tar.gz
Algorithm Hash digest
SHA256 94b14c1de44982adf4dc065cbc9bb518cb9703c87d464e06556a6fb98f35749e
MD5 5cdb7332beea2bfa0d355e3741e210a9
BLAKE2b-256 83cc448157c3a28e35e55b4caaa5935a508f9f6c5b7c9dfdab088624405a9c06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quinkgl-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 77.5 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.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 991dd6cb71fb1641c462c5e21bd993036d7588ef5009c983900905efb0933056
MD5 7079ffe444f3d676fa465ee1b143c01a
BLAKE2b-256 13505dc09da7a07d7a10f9eb15b91c1c0a627420ce4e7638ae124726301f163f

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