Welcome to the DISCO developer guide. Here you will have a first overview of the project, how to install and run an instance of DISCO and links to further documentation.
The DISCO project is composed of multiple parts. At the root level, there are four main folders: discojs
, server
, web-client
and cli
.
-
discojs
, or Disco.js, is the JavaScript library that contains federated and decentralized learning logic. The library allows to train and use machine learning models in a distributed fashion. The library itself is composed of thedisco-node
anddisco-web
modules, both of them extending the platform-agnostic code indisco-core
. In other words,disco-core
contains most of the implementation but can't be used by itself, whiledisco-web
anddisco-node
allow usingdisco-core
via different technologies. To some extents, you can think ofdisco-core
as an abstract class extended bydisco-web
anddisco-node
.disco-node
lets you use Disco.js with Node.js. For example, theserver
and thecli
rely ondisco-node
. A user can also directly import thedisco-node
package in their Node.js programs.disco-web
allows using Disco.js through a browser. Theweb-client
, discussed below, relies ondisco-web
to implement a browser UI.
The main difference between the two is how they handle storage: a browser doesn't have access to the file system (for security reasons) while a Node.js application does.
-
server
contains the server implementation necessary to use Disco.js. Indeed, while the federated and decentralized learning logic is implemented by Disco.js, we still need a server to orchestrate users in both paradigms. In decentralized learning, the server exposes an API for users to query the necessary information to train models in a decentralized fashion, such as the list of other peers. Thus, the server never receives training data or model parameters. In federated learning, the server receives model updates but never training data. It keeps track of participants and updates the model weights. Aserver
instance is always necessary to use DISCO, whether one is using a browser UI, the CLI or directly programming withdisco-node
. -
web-client
implements a browser User Interface. In other words, it implements a website allowing users to use DISCO without coding. Via the browser, a user can create and participate in federated and decentralized training sessions, evaluate models, etc. -
cli
contains the Command Line Interface for Disco.js. For example, the CLI allows a user to create and join training sessions from the command line, benchmark performance by emulating multiple clients, etc.
Here is a summary diagram:
flowchart LR
subgraph discojs
discojs-node-->|extends|discojs-core;
discojs-web-->|extends|discojs-core;
end
subgraph User Interface
web-client-->|uses|discojs-web;
custom_browser["custom browser implementation"]-->|uses|discojs-web;
server-->| uses |discojs-node;
cli-->|uses|discojs-node;
custom_node["custom Node.js scripts"]-->|uses|discojs-node;
end
The following instructions will install the required dependencies, build Disco.js and launch a DISCO server and a web client. If you run into any sort of trouble check our FAQ; otherwise please create a new issue or feel free to ask on our slack.
- We recommend using nvm (Node Version Manager) to handle multiple Node.js versions. Start by installing
nvm
by following their installation instructions. After installation, you should be able to run
nvm -v
0.39.7 # my nvm version at the time
- Install Node.js version 16
nvm install 16
You can now choose which Node.js version to use:
nvm use 16
Using Node.js v16 should automatically set your npm (Node Package Manager, different from nvm) version to 8:
npm --version
8.xx.xx
nvm
manages your different Node.js versions while npm
handles your different Node.js project packages within one version.
- Clone the repository
git clone [email protected]:epfml/disco.git
cd disco
- Run the installation script
sh install.sh
What does install.sh
do?
The installation script installs the dependencies required by the different parts of the project, which are described in the Structure section. It first installs the Disco.js library dependencies, notably, `TensorFlow.js`, and anything else required for federated and decentralized learning logic. The script then builds the library, a step necessary to compile TypeScript into JavaScript.
cd discojs
npm ci # stands for `clean install`, to ensure than only expected dependencies are being installed.
npm run build
The script then installs dependencies for the web client, which implements a browser UI.
By default, the project points to the @epfml/disco-web package published on the npm
remote repository. In a development environment, we want to use the local web client in the discojs/web-client
folder. To do so, we need to link the local folder as the actual dependency.
cd ../web-client
npm ci
npm link ../discojs/discojs-web
You can verify than the link is effective by checking that npm ls
lists @epfml/[email protected] -> ./../discojs/discojs-web
.
Similarly, we install the server dependencies, and then the discojs-node
dependency to the local folder rather than the remote npm package @epfml/disco-node:
cd ../server
npm ci
npm link ../discojs/discojs-node
Install the CLI dependencies:
cd ../cli
npm ci
Finally, we install ts-node
globally in order to compile and run TypeScript code in a single command from anywhere.
npm install -g ts-node
- Launch DISCO
As you may have seen, there are many ways to use DISCO. Here we will run a server and a web client. From there, a user can use DISCO from their browser.
- First launch a
server
instance, which is used for federated and decentralized learning tasks, e.g. to list peers participating in a decentralized task.
cd server
npm run dev
The server should be listening on http://localhost:8080/
.
- Secondly, start a web client, which will allow you to use DISCO from your browser. You may have to do so from another terminal since the previous one is now used by the server.
cd web-client
npm run dev
The web client should be running on http://localhost:8081
, if not first restart the server and then the web client.
Important
Make sure to first start the server to ensure that it is listening to port 8080.
You can now access DISCO at http://localhost:8081/
- Next you may want to read our onboarding guide which lists the following steps to onbaord DISCO. Additionally the Architecture guide gives more information on our use of TypeScript and Vue.js, the frontend framework.
- If you are only planning to use DISCO in your own scripts, you can find a stand-alone example relying on
discojs-node
here. The example runs with Node.js outside any browser, using the@epfml/discojs-node
NPM package and theserver
module. A DISCO server is launched by the script itself and the data is already available in the repo.
As there are many guides in the project, here is a table of contents referencing them all:
- DISCO README
- Developer guide
- The
docs
folder contains in-depth documention on the project: - Respective
README
files contain installation and packaging instructions relevant to the module