Package: jaynes
OverviewThe reality of ML training in universities is that we use what ever
hardware we are given (for free). This means that we might have a few
beefy GPU machines, an HPC cluster, plus some GCE/AWS credits that we
get through grants.Jaynesis a well-designed python package that makes running across these
inhomogenous hardward resources a pleasure.install(requires unix operating system.)pipinstalljaynesThe best way to get started with jaynes is to take a look at one of the
example projects in the[geyang/jaynes-starter-kit].
For a rough idea, here is how to use jaynes to launch a training
function:To runlocally:importjaynesdeftraining(arg_1,key_arg=None,key_arg_2=None):print(f'training is running! (arg_1={arg_1}, key_arg={key_arg})')jaynes.config(mode="local",arg_1=10,key_arg=0.3)jaynes.run(training)jaynes.listen()We recommend setting up amaintraining function with the following
sinature:fromparams_protoimportParamsProtoclassArgs(ParamsProto):seed=100lr=3e-4# ...defmain(**deps):fromml_loggerimportloggerArgs._update(deps)logger.log_params(Args=vars(Args))# ... your main training stepsThis way you can call the main fn directly for local debugging, but
launch it as an entry point at scale.SetupJaynes has gone through a large number of iterations. This version
incorporates best practices we learned from other open-source
communities. You can specify ajaynes.ymlconfig file (copy one
from our sample project to get started!) for the
type of hosts (ssh/docker/singularity) and launchers
(ssh/ec2/gce/slurm), so that none of those settings need to appear in
your ML python script. When called from python, Jaynes automatically
traverses the file tree to find the root of the project, the same way as
git.For example, to run your code-block on a remote computer via ssh:# your_project/jaynes.ymlversion:0verbose:truerun:# this is specific to each launch, and is dynamically overwritten in-memorymounts:-!mounts.S3Codes3_prefix:s3://ge-bair/jaynes-debuglocal_path:.host_path:/home/ubuntu/container_path:/Users/geyang/learning-to-learnpypath:trueexcludes:"--exclude='*__pycache__'--exclude='*.git'--exclude='*.idea'--exclude='*.egg-info'--exclude='*.pkl'"compress:truerunner:!runners.Dockername:# not implemented yetimage:"episodeyang/super-expert"startup:"yes|pipinstalljaynesml-logger-q"work_directory:"{mounts[0].container_path}"ipc:hosthost:envs:"LANG=utf-8"pre_launch:"pipinstalljaynesml-logger-q"launch:type:sship:<your ip address>username:ubuntupem:~/.ssh/your_rsa_keyIn python (your code-block):# your_project/launch.pyimportjaynesdeftraining(arg_1,key_arg=None):print(f'training is running! (arg_1={arg_1}, key_arg={key_arg})')jaynes.run(training)Using ModesA lot of times you want to setup a different runmodesso it is easy
to switch between them during development.# your_project/jaynes.ymlversion:0mounts:# mount configurations Available keys: NOW, UUID,-!mounts.S3Code&code-block_mounts3_prefix:s3://ge-bair/jaynes-debuglocal_path:.host_path:/home/ubuntu/jaynes-mounts/{NOW:%Y-%m-%d}/{NOW:%H%M%S.%f}# container_path: /Users/geyang/learning-to-learnpypath:trueexcludes:"--exclude='*__pycache__'--exclude='*.git'--exclude='*.idea'--exclude='*.egg-info'--exclude='*.pkl'"compress:truehosts:hodor:&hodorip:<your ip address>username:ubuntupem:~/.ssh/incrementium-berkeleyrunners:-!runners.Docker&ssh_dockername:"some-job"# only for dockerimage:"episodeyang/super-expert"startup:yes | pip install jaynes ml-logger -qenvs:"LANG=utf-8"pypath:"{mounts[0].container_path}"launch_directory:"{mounts[0].container_path}"ipc:hostuse_gpu:falsemodes:# todo: add support to modes.hodor:mounts:-*code-block_mountrunner:*ssh_dockerlaunch:type:ssh<<:*hodornow run in python# your_project/launch.pyimportjaynesdeftraining(arg_1,key_arg=None):print(f'training is running! (arg_1={arg_1}, key_arg={key_arg})')jaynes.config(mode="hodor")jaynes.run(training)ToDos☐ more documentation☐ singularity support☐ GCE support☐ support using non-s3 code-block repo.Done☒ get the initial template to workInstallationpipinstalljaynesUsage (Show me the Mo-NAY!! :moneybag::money_with_wings:)Check out thetest_projectsfolder for projects
that you can run.To Developgitclonehttps://github.com/episodeyang/jaynes.gitcdjaynesmakedevTo test, runmaketestThismake devcommand should build the wheel and install it in your
current python environment. Take a look at thehttps://github.com/episodeyang/jaynes/blob/master/Makefilefor details.To publish, first update the version number, then do:makepublishAcknowledgementsThis code-block is inspired by @justinfu’sdoodad, which is in turn built
on top of Peter Chen’s script.This code-block is written from scratch to allow a more permissible
open-source license (BSD). Go bears :bear: !!