- Notifications
You must be signed in to change notification settings - Fork41
License
google-deepmind/launchpad
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Launchpad is a library that simplifies writing distributed programs byseamlessly launching them on a variety of different platforms. Switching betweenlocal and distributed execution requires only a flag change.
Launchpad introduces a programming model that represents a distributed systemas a graph data structure (aProgram) describing the system’s topology.Each node in the program graph represents a service in the distributed system,i.e. the fundamental unit of computation that we are interested in running.As nodes are added to this graph, Launchpad constructs a handle for each of them.A handle ultimately represents a client to the yet-to-be-constructed service.A directed edge in the program graph, representing communication betweentwo services, is created when the handle associated with one node is givento another at construction time. This edge originates from the receiving node,indicating that the receiving node will be the one initiating communication.This process allows Launchpad to define cross-service communication simplyby passing handles to nodes. Launchpad provides a number of node types,including:
- PyNode - a simple node executing provided Python code upon entry.It is similar to a main function, but with the distinction thateach node may be running in separate processes and on different machines.
- CourierNode - it enables cross-node communication.CourierNodes cancommunicate by calling public methods on each other either synchronouslyor asynchronously via futures. The underlying remote procedure callsare handled transparently by Launchpad.
- ReverbNode - it exposes functionality of Reverb, an easy-to-use datastorage and transport system primarily used by RL algorithms asan experience replay. You can read more about Reverbhere.
- MultiThreadingColocation - allows to colocate multiple other nodes ina single process.
- MultiProcessingColocation - allows to colocate multiple other nodes assub processes.
Using Launchpad involves writing nodes and defining the topology of yourdistributed program by passing to each node references of the other nodes thatit can communicate with. The core data structure dealing with this is called aLaunchpad program, which can then be executed seamlessly with a number ofsupported runtimes.
Launchpad supports a number of launch types, both for running programs ona single machine, in a distributed manner, or in a form of a test. Launch typecan be controlled by thelaunch_type
argument passed tolp.launch
method,or specified through the--lp_launch_type
command line flag.Please refer to the documentation of theLaunchTypefor details.
Please keep in mind that Launchpad is not hardened for production use, and while wedo our best to keep things in working order, things may break or segfault.
⚠️ Launchpad currently only supports Linux based OSes.
The recommended way to install Launchpad is withpip
. We also provideinstructions to build from source using the same docker images we use forreleases.
TensorFlow can be installed separately or as part of thepip
install.Installing TensorFlow as part of the install ensures compatibility.
$ pip install dm-launchpad[tensorflow]# Without Tensorflow install and version dependency check.$ pip install dm-launchpad
$ pip install dm-launchpad-nightly[tensorflow]# Without Tensorflow install and version dependency check.$ pip install dm-launchpad-nightly
Similarily,Reverb can be installedensuring compatibility:
$ pip install dm-launchpad[reverb]
The most convenient way to develop Launchpad is with Docker.This way you can compile and test Launchpad inside a container withouthaving to install anything on your host machine, while you can stilluse your editor of choice for making code changes.The steps are as follows.
Checkout Launchpad's source code from GitHub.
$ git checkout https://github.com/deepmind/launchpad.git$ cd launchpad
Build the Docker container to be used for compiling and testing Launchpad.You can specifytensorflow_pip
parameter to set the versionof Tensorflow to build against. You can also specify which version(s) of Pythoncontainer should support. The command below enables support for Python3.7, 3.8, 3.9 and 3.10.
$ docker build --tag launchpad:devel \ --build-arg tensorflow_pip=tensorflow==2.3.0 \ --build-arg python_version="3.7 3.8 3.9 3.10" - < docker/build.dockerfile
The next step is to enter the built Docker image, binding checked outLaunchpad's sources to /tmp/launchpad within the container.
$ docker run --rm --mount "type=bind,src=$PWD,dst=/tmp/launchpad" \ -it launchpad:devel bash
At this point you can build and install Launchpad within the container byexecuting:
$ /tmp/launchpad/oss_build.sh
By default it builds Python 3.8 version, you can change that with--python
flag.
$ /tmp/launchpad/oss_build.sh --python 3.8
To make sure installation was successful and Launchpad works as expected, youcan run some examples provided:
$ python3.8 -m launchpad.examples.hello_world.launch$ python3.8 -m launchpad.examples.consumer_producers.launch --lp_launch_type=local_mp
To make changes to Launchpad codebase, edit sources checked out from GitHubdirectly on your host machine (outside of the Docker container). All changes arevisible inside the Docker container. To recompile just run theoss_build.sh
script again from the Docker container. In order to reduce compilation time ofthe consecutive runs, make sure to not exit the Docker container.
If you use Launchpad in your work, please cite the accompanyingtechnical report:
@article{yang2021launchpad,title={Launchpad: A Programming Model for Distributed Machine Learning Research},author={Fan Yang and Gabriel Barth-Maron and Piotr Stańczyk and Matthew Hoffman and Siqi Liu and Manuel Kroiss and Aedan Pope and Alban Rrustemi},year={2021},journal={arXiv preprint arXiv:2106.04516},url={https://arxiv.org/abs/2106.04516},}
We greatly appreciate all the help fromReverbandTF-Agents teams in settingup building and testing setup for Launchpad.
About
Resources
License
Uh oh!
There was an error while loading.Please reload this page.