• This repository has been archived on 16/Feb/2023
  • Stars
    star
    614
  • Rank 72,554 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Peer-to-peer Platform for Secure, Privacy-preserving, Decentralized Data Science

PyGrid logo

Tests

Deprecation note

For convenience reasons, this repository has been moved into PySyft:

https://github.com/OpenMined/PySyft/tree/dev/packages/grid

New developments and issues will be managed in this monorepo structure.

PyGrid

PyGrid is a peer-to-peer network of data owners and data scientists who can collectively train AI models using PySyft. PyGrid is also the central server for conducting both model-centric and data-centric federated learning.

You may control PyGrid via our user-interface, PyGrid Admin.

Architecture

PyGrid platform is composed by three different components.

  • Network - A Flask-based application used to manage, monitor, control, and route instructions to various PyGrid Domains.
  • Domain - A Flask-based application used to store private data and models for federated learning, as well as to issue instructions to various PyGrid Workers.
  • Worker - An emphemeral instance, managed by a PyGrid Domain, that is used to compute data.

Use Cases

Federated Learning

Simply put, federated learning is machine learning where the data and the model are initially located in two different locations. The model must travel to the data in order for training to take place in a privacy-preserving manner. Depending on what you're looking to accomplish, there are two types of federated learning that you can perform with the help of PyGrid.

Model-centric FL

Model-centric FL is when the model is hosted in PyGrid. This is really useful when you have data located at an "edge device" like a person's mobile phone or web browser. Since the data is private, we should respect that and leave it on the device. The following workflow will take place:

  1. The device will request to train a model
  2. The model and a training plan may be sent to that device
  3. The training will take place with private data on the device itself
  4. Once training is completed, a "diff" is generated between the new and the original state of the model
  5. The diff is reported back to PyGrid and it's averaged into the model

This takes place potentially with hundreds, or thousands of devices simultaneously. For model-centric federated learning, you only need to run a Domain. Networks and Workers are irrelevant for this specific use-case.

Note: For posterity sake, we previously used to refer to this process as "static federated learning".

Cycled MCFL

Data-centric FL

Data-centric FL is the same problem as model-centric FL, but from the opposite perspective. The most likely scenario for data-centric FL is where a person or organization has data they want to protect in PyGrid (instead of hosting the model, they host data). This would allow a data scientist who is not the data owner, to make requests for training or inference against that data. The following workflow will take place:

  1. A data scientist searches for data they would like to train on (they can search either an individual Domain, or a Network of Domains)
  2. Once the data has been found, they may write a training plan and optionally pre-train a model
  3. The training plan and model are sent to the PyGrid Domain in the form of a job request
  4. The PyGrid Domain will gather the appropriate data from its database and send the data, the model, and the training plan to a Worker for processing
  5. The Worker performs the plan on the model using the data
  6. The result is returned to the Domain
  7. The result is returned to the data scientist

For the last step, we're working on adding the capability for privacy budget tracking to be applied that will allow a data owner to "sign off" on whether or not a trained model should be released.

Note: For posterity sake, we previously used to refer to this process as "dynamic federated learning".

Domain-only data-centric FL

Technically speaking, it isn't required to run a Network when performing data-centric federated learning. Alternatively, as a data owner, you may opt to only run a Domain, but participate in a Network hosted by someone else. The Network host will not have access to your data.

Domain-only DCFL

Network-based data-centric FL

Many times you will wat to use a Network to allow multiple Domains to be connected together. As a data owner, it's not strictly necessary to own and operate mulitple Domains. PyGrid doesn't prescribe one way to organize Domains and Networks, but we expose these applications to allow you and various related stakeholders to make the correct decision about your infrastructure needs.

Network-based DCFL

Local Setup

Currently, we suggest two ways to run PyGrid locally: Docker and manually running from source. With Docker, we can organize all the services we'd like to use and then boot them all in one command. With manually running from source, we have to run them as separate tasks.

Docker

To install Docker, just follow the docker documentation.

1. Setting the your hostfile

Before start the grid platform locally using Docker, we need to set up the domain names used by the bridge network. In order to use these Domains from outside of the containers context, you should add the following domain names on your /etc/hosts

127.0.0.1 network
127.0.0.1 alice
127.0.0.1 bob
127.0.0.1 charlie
127.0.0.1 dan

Note that you're not restricted to running 4 nodes and a network. You could instead run just a single node if you'd like - this is often all you need for model-centric federated learning. For the sake of our example, we'll use the network running 4 nodes underneath but you're welcome to modify it to your needs.

2. Run Docker Images

The latest PyGrid Network and Node images are also available on the Docker Hub.

3. Optional - Build your own images

If you want to build your own custom images, you may do so using the following command for the Node:

docker build ./apps/domain --file ./apps/domain/Dockerfile --tag openmined/grid-domain:mybuildname

Or for the Worker:

docker build ./apps/worker --file ./apps/worker/Dockerfile --tag openmined/grid-worker:mybuildname

Or for the Network:

docker build ./apps/network --file ./apps/network/Dockerfile --tag openmined/grid-network:mybuildname

Manual Start

Running a Node

Installation

First install poetry and run poetry install in apps/node

To start the PyGrid Node manually, run:

cd apps/node
./run.sh --id bob --port 5000 --start_local_db

You can pass the arguments or use environment variables to set the network configs.

Arguments

  • -h, --help - Shows the help message and exit
  • -p [PORT], --port [PORT] - Port to run server on (default: 5000)
  • --host [HOST] - The Node host
  • --num_replicas [NUM] - The number of replicas to provide fault tolerance to model hosting
  • --id [ID] - The ID of the Node
  • --start_local_db - If this flag is used a SQLAlchemy DB URI is generated to use a local db

Environment Variables

  • GRID_NODE_PORT - Port to run server on
  • GRID_NODE_HOST - The Node host
  • NUM_REPLICAS - Number of replicas to provide fault tolerance to model hosting
  • DATABASE_URL - The Node database URL
  • SECRET_KEY - The secret key

Running a Network

To start the PyGrid Network manually, run:

cd apps/network
./run.sh --port 7000 --start_local_db

You can pass the arguments or use environment variables to set the network configs.

Arguments

  • -h, --help - Shows the help message and exit
  • -p [PORT], --port [PORT] - Port to run server on (default: 7000)
  • --host [HOST] - The Network host
  • --start_local_db - If this flag is used a SQLAlchemy DB URI is generated to use a local db

Environment Variables

  • GRID_NETWORK_PORT - Port to run server on
  • GRID_NETWORK_HOST - The Network host
  • DATABASE_URL - The Network database URL
  • SECRET_KEY - The secret key

Deployment & CLI

Please check the instruction for deployment and CLI here.

Contributing

If you're interested in contributing, check out our Contributor Guidelines.

Support

For support in using this library, please join the #support Slack channel. Click here to join our Slack community!

License

Apache License 2.0

More Repositories

1

PySyft

Perform data science on data that remains in someone else's server
Python
9,418
star
2

TenSEAL

A library for doing homomorphic encryption operations on tensors
C++
790
star
3

PyDP

The Python Differential Privacy Library. Built on top of: https://github.com/google/differential-privacy
Python
486
star
4

private-ai-resources

SOON TO BE DEPRECATED - Private machine learning progress
469
star
5

PipelineDP

PipelineDP is a Python framework for applying differentially private aggregations to large datasets using batch processing systems such as Apache Spark, Apache Beam, and more.
Python
271
star
6

PyVertical

Privacy Preserving Vertical Federated Learning
Python
211
star
7

SyferText

A privacy preserving NLP framework
Python
196
star
8

courses

A place where our community can discuss OpenMined Courses, including posting questions, sharing feedback, or providing comments for discussion!
168
star
9

syft.js

The official Syft worker for Web and Node, built in Javascript
JavaScript
147
star
10

Roadmap

This repository contains OpenMined's official development and community roadmap.
131
star
11

PSI

Private Set Intersection Cardinality protocol based on ECDH and Bloom Filters
C++
128
star
12

SyMPC

A SMPC companion library for Syft
Python
96
star
13

KotlinSyft

The official Syft worker for secure on-device machine learning
Kotlin
83
star
14

PyDentity

A repository for leveraging Self-Sovereign Identity in applications
Jupyter Notebook
65
star
15

PySyft-TensorFlow

SOON TO BE DEPRECATED - The TensorFlow bindings for PySyft
Python
57
star
16

Threepio

A multi-language library for translating commands between PyTorch, TensorFlow, and TensorFlow.js
Python
56
star
17

sycret

Function Secret Sharing library for Python and Rust with hardware acceleration
Rust
50
star
18

SwiftSyft

The official Syft worker for iOS, built in Swift
Swift
47
star
19

openmined-website

The OpenMined website...
JavaScript
43
star
20

covid-alert

A privacy-preserving app for comparing last-known locations of coronavirus patients
JavaScript
43
star
21

PyFE

A library for running Functional Encryption on tensors
Python
41
star
22

PIR

Private Information Retrieval protocol
C++
41
star
23

PyZPK

Python wrapper for open source Zero Proof Knowledge Library
C++
27
star
24

openmined

OpenMined courses application
TypeScript
25
star
25

opus

Python
22
star
26

PyAriesFL

Federated Learning on HyperLedger Aries
Python
21
star
27

syft-proto

Defines types for all Serde encoding across languages
JavaScript
20
star
28

datasets

Jupyter Notebook
16
star
29

pygrid-admin

The user interface for PyGrid!
TypeScript
13
star
30

JavaDP

Differential privacy implementation in the Java family of languages (Java, Kotlin, Scala etc...)
11
star
31

aries-did.js

A repo for exploring the use of Hyperledger Aries to facilitate decentralised identity services.
TypeScript
11
star
32

syft_experimental

Deliberate experimental Rust implementation of Syft
Rust
11
star
33

SwiftDP

Swift wrapper for Google's Differential Privacy Project
Objective-C++
11
star
34

writing

11
star
35

sgx-experiments

Trusted execution experiments with Intel SGX
Makefile
11
star
36

omui

The OpenMined UI component system for usage in all our web applications and Framer prototyping
TypeScript
10
star
37

design

This is the main hub for those interested in design in the OpenMined community
Jupyter Notebook
10
star
38

CampX

Tensor Based Environment Framework for Training RL Agents - Pre Alpha
Python
8
star
39

.github

All our community health files
7
star
40

design-assets

All OpenMined design assets
7
star
41

Bootcamps

7
star
42

serverless-website-api

SOON TO BE DEPRECATED - A Github statistics fetcher, running on a cron job, with permanent storage to DynamoDB, for the OpenMined community.
JavaScript
7
star
43

privacy-conference

The website for our 2020 privacy conference
JavaScript
6
star
44

PyDPValidator

Validation assets for core OpenMined libraries
Jupyter Notebook
6
star
45

X-PenTest

Repository for carrying out Pentesting on OM Infrastructure
6
star
46

NetworkRegistry

5
star
47

miner

A collection of web scraping technologies focused around making it easy for users to download their data.
5
star
48

paillier.js

A pure javascript implementation of paillier - runnable in browser, node, or react native
TypeScript
5
star
49

research

5
star
50

Hackathon-DSA

Jupyter Notebook
4
star
51

openmined-ghost-theme

SOON TO BE DEPRECATED - The theme for the OpenMined and Weekly Digs blogs.
SCSS
4
star
52

GridMonitor

SOON TO BE DEPRECATED - A user interface for monitoring a network router for PyGrid Platform
CSS
3
star
53

diffPrivR

R implementation of google's differential privacy library
3
star
54

daa.js

A javascript wrapper around https://github.com/xaptum/ecdaa
3
star
55

syft-enclave

Python
3
star
56

syft.cpp

SOON TO BE DEPRECATED - A library for encrypted, privacy preserving machine learning
C++
3
star
57

OpenGridNodes

1
star
58

KotlinPSI

A Kotlin library for private set intersection
1
star
59

clojure-dp

Clojure
1
star
60

trasterisk

kwarger is a Flake8 plugin which enforces named kwargs or trasterisks in your function arguments
Python
1
star
61

SwiftPSI

A Swift library for private set intersection
1
star