How quinkgl/quinkgl-framework works
Purpose and entry points
QuinkGL is a Python 3.10+ decentralized federated-learning framework: peers train locally, exchange model updates over P2P gossip, and merge without a parameter server. Primary entry points are the quinkgl CLI, especially lifecycle execution in src/quinkgl/cli/__main__.py and src/quinkgl/cli/run_cmd.py, and the programmatic production node in src/quinkgl/network/gossip_node.py. LearningNode provides the network-neutral core facade at src/quinkgl/core/learning_node.py.
Swarm identity and admission boundary
A schema-versioned .qgl manifest declares model architecture, aggregation, topology, privacy, and collaboration policy. Its canonical bytes/hash form the swarm compatibility boundary; optional Ed25519 signing establishes publisher identity. CLI creation/verification feeds runtime startup. Key modules: src/quinkgl/manifest/schema.py, src/quinkgl/manifest/bytes_codec.py, src/quinkgl/manifest/signing.py.
Runtime lifecycle and round control
run builds a deterministic plan, initializes peer services, and manages cancellation/resume/status concerns. The gossip round executor coordinates local training, candidate selection, update receipt, aggregation, evaluation, and persistence, keeping orchestration separate from transport and strategy implementations. Paths: src/quinkgl/cli/run_lifecycle.py, src/quinkgl/cli/run_plan.py, src/quinkgl/gossip/round_executor.py.
Model training and update construction
Framework adapters isolate PyTorch, TensorFlow, and custom model behavior behind model/trainer abstractions. Local weights or deltas pass through an ordered serialization pipeline—codec, compression/sparsification/quantization, and error-feedback residual handling—before network transfer. Paths: src/quinkgl/models/base.py, src/quinkgl/models/trainers/pytorch.py, src/quinkgl/serialization/stages.py.
Peer selection, privacy, and aggregation
Topology implementations select exchange peers, including random/Cyclon graph methods and affinity-driven selection. Privacy-transformed data fingerprints support affinity without distributing raw data. Received updates are held/validated and combined through pluggable standard, non-IID, async, and Byzantine-resilient strategies. Paths: src/quinkgl/topology/affinity.py, src/quinkgl/fingerprint/computer.py, src/quinkgl/aggregation/strategies.py.
P2P transport and fallback boundary
The network layer owns discovery, IPv8 gossip-community integration, manifest exchange, TOFU trust, and supervised node lifecycle. Model payloads are serialized and transferred as authenticated chunks with explicit incoming/outgoing state. IPv8/UDP NAT traversal is primary; gRPC-generated tunnel components provide fallback routing when direct connectivity fails. Paths: src/quinkgl/network/transport_supervisor.py, src/quinkgl/network/chunk_transfer.py, src/quinkgl/network/fallback/tunnel_server.py.
Durability and observability
Checkpoint/model storage preserves local model and round state behind async/backend abstractions, enabling restart and recovery. Runtime events have a stable contract and feed terminal rendering or telemetry. The telemetry package includes client transport plus server-side API, enrollment, ingest/read/WebSocket routers, state projection, retention, and token handling. Paths: src/quinkgl/storage/model_store.py, src/quinkgl/observability/event_contract.py, src/quinkgl/telemetry/server.py.
Deployment shape
Peers run as independent Python processes; Docker Compose supports local multi-node swarms and scale scenarios. Material optional runtimes are PyTorch or TensorFlow; networking depends on IPv8 and fallback tunnel/protobuf definitions in protos/gossip.proto and protos/tunnel.proto. Deployment artifacts: docker/Dockerfile, docker/docker-compose.yml.
Main entry points: round_executor.py Gossip round executor · run_lifecycle.py Run lifecycle · transport_supervisor.py Transport supervisor · schema.py .qgl manifest
Components 22
Control Plane
CLI, manifest, and round orchestration.
- quinkgl CLI
src/quinkgl/cli/__main__.py - Run lifecycle
src/quinkgl/cli/run_lifecycle.py - Deterministic run plan
src/quinkgl/cli/run_plan.py - .qgl manifest · Canonical schema bytes and hash define compatibility.
src/quinkgl/manifest/schema.py - Manifest codec
src/quinkgl/manifest/bytes_codec.py - Manifest signing
src/quinkgl/manifest/signing.py - LearningNode · Network-neutral production node API.
src/quinkgl/core/learning_node.py - Gossip round executor
src/quinkgl/gossip/round_executor.py
Learning Pipeline
Local training, update encoding, and aggregation.
- Model adapters · Supports PyTorch, TensorFlow, and custom models.
src/quinkgl/models/base.py - PyTorch trainer
src/quinkgl/models/trainers/pytorch.py - Update pipeline · Codec, compression, sparsification, quantization, and residual feedback.
src/quinkgl/serialization/stages.py - Affinity topology
src/quinkgl/topology/affinity.py - Data fingerprints · Enables affinity without sharing raw data.
src/quinkgl/fingerprint/computer.py - Aggregation strategies · Pluggable standard, non-IID, async, and Byzantine-resilient merging.
src/quinkgl/aggregation/strategies.py
P2P Network
Peer transport, chunk transfer, and fallback routing.
- Gossip node
src/quinkgl/network/gossip_node.py - Transport supervisor · Owns discovery, IPv8 integration, manifest exchange, and TOFU trust.
src/quinkgl/network/transport_supervisor.py - Authenticated chunk transfer · Maintains incoming and outgoing transfer state.
src/quinkgl/network/chunk_transfer.py - gRPC tunnel fallback · Used when direct IPv8/UDP connectivity fails.
src/quinkgl/network/fallback/tunnel_server.py
Durability & Observability
State recovery and runtime reporting.
- Model store · Preserves model and round state for recovery.
src/quinkgl/storage/model_store.py - Runtime event contract
src/quinkgl/observability/event_contract.py - Telemetry server · Provides enrollment, ingest, read, WebSocket, projection, retention, and tokens.
src/quinkgl/telemetry/server.py
Other components
- Docker Compose swarm · Runs independent peer processes for local multi-node scenarios.
docker/docker-compose.yml
Connections 27
- quinkgl CLI → Run lifecycle: starts
- quinkgl CLI → .qgl manifest: creates and verifies
- .qgl manifest → Manifest codec: canonicalizes
- .qgl manifest → Manifest signing: optionally signs
- Run lifecycle → Deterministic run plan: builds
- Run lifecycle → LearningNode: initializes
- Deterministic run plan → Gossip round executor: configures
- LearningNode → Gossip node: uses for P2P runtime
- LearningNode → Gossip round executor: executes rounds
- Gossip round executor → Model adapters: trains locally
- Model adapters → PyTorch trainer: implemented by
- Gossip round executor → Update pipeline: encodes updates
- Gossip round executor → Affinity topology: selects candidates
- Data fingerprints → Affinity topology: supplies affinity
- Gossip round executor → Aggregation strategies: merges received updates
- Update pipeline → Authenticated chunk transfer: sends payloads
- Authenticated chunk transfer → Gossip round executor: delivers updates
- Gossip node → Transport supervisor: supervises
- Transport supervisor → .qgl manifest: exchanges and validates
- Transport supervisor → Authenticated chunk transfer: routes transfers
- Transport supervisor → gRPC tunnel fallback: falls back to
- Gossip round executor → Model store: checkpoints
- Model store → Gossip round executor: restores state
- Run lifecycle → Runtime event contract: emits
- Gossip round executor → Runtime event contract: emits
- Runtime event contract → Telemetry server: feeds
- Docker Compose swarm → Gossip node: deploys peer replicas