-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rllib] Add the ability to run arbitrary Python scripts with ray.tune #1132
Conversation
@@ -5,4 +5,4 @@ hopper-ppo: | |||
resources: | |||
cpu: 64 | |||
gpu: 4 | |||
config: {"gamma": 0.995, "kl_coeff": 1.0, "num_sgd_iter": 20, "sgd_stepsize": 1e-4, "sgd_batchsize": 32768, "devices": ["/gpu:0", "/gpu:1", "/gpu:2", "/gpu:3"], "tf_session_args": {"device_count": {"GPU": 4}, "log_device_placement": false, "allow_soft_placement": true}, "timesteps_per_batch": 160000, "num_workers": 64} | |||
config: {"gamma": 0.995, "kl_coeff": 1.0, "num_sgd_iter": 20, "sgd_stepsize": .0001, "sgd_batchsize": 32768, "devices": ["/gpu:0", "/gpu:1", "/gpu:2", "/gpu:3"], "tf_session_args": {"device_count": {"GPU": 4}, "log_device_placement": false, "allow_soft_placement": true}, "timesteps_per_batch": 160000, "num_workers": 64} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently, pyyaml has a bug where it can't parse scientific notation correctly.
x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0})) | ||
|
||
|
||
def train(config={'activation': 'relu'}, reporter=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the integration with ray.tune
Merged build finished. Test FAILed. |
Test FAILed. |
Test FAILed. |
Thanks, this is really useful (most people have standalone training scripts); will review it later today! |
Merged build finished. Test PASSed. |
Test PASSed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments.
RUNNING = 'RUNNING' | ||
TERMINATED = 'TERMINATED' | ||
ERROR = 'ERROR' | ||
PENDING = "PENDING" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the proper format for strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we prefer double quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, we've mostly been using double quotes.
python/ray/tune/trial.py
Outdated
@@ -98,7 +97,7 @@ def stop(self, error=False): | |||
|
|||
try: | |||
if self.agent: | |||
self.agent.stop.remote() | |||
ray.get(self.agent.stop.remote()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there any tradeoffs to doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm maybe it shouldn't block, I removed this.
python/ray/tune/trial.py
Outdated
self.last_result.training_iteration, | ||
round(self.last_result.episode_reward_mean, 1)) | ||
|
||
pieces = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is nice - could use a dict that maps from formatting string to result and it would probably be cleaner.
python/ray/rllib/train.py
Outdated
@@ -32,16 +32,20 @@ | |||
# Extends the base parser defined in ray/tune/config_parser, to add some | |||
# RLlib specific arguments. For more arguments, see the configuration | |||
# defined there. | |||
parser.add_argument("--redis-address", default=None, type=str, | |||
parser.add_argument("--redis_address", default=None, type=str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://ray.readthedocs.io/en/latest/using-ray-on-a-cluster.html has redis-address
, makes sense to standardize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
python/ray/tune/README.rst
Outdated
finer-grained control over trial setup and scheduling. Some examples of | ||
calling ray.tune programmatically include: | ||
|
||
- python/ray/tune/examples/tune_mnist_ray.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python/ray/tune/examples/tune_mnist_ray.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(formatting `` would be nice)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
python/ray/tune/script_runner.py
Outdated
elif hasattr(importlib, "machinery"): | ||
# Python 3.3 | ||
from importlib.machinery import SourceFileLoader | ||
foo = SourceFileLoader("external_file", file_path).load_module() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: foo...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
if i % 10 == 0: | ||
train_accuracy = accuracy.eval(feed_dict={ | ||
x: batch[0], y_: batch[1], keep_prob: 1.0}) | ||
if status_reporter: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to annotate this part to indicate specific modification of status reporter here.
Merged build finished. Test FAILed. |
Test FAILed. |
Merged build finished. Test FAILed. |
Test FAILed. |
Merged build finished. Test FAILed. |
Test FAILed. |
Merged build finished. Test PASSed. |
Test PASSed. |
Merged build finished. Test PASSed. |
Test PASSed. |
I've seen this a few times in the failing tests cc @stephanie-wang
|
Yeah, test failures all look innocuous to me. |
I'd suggest merging unless there are other changes you want to do here. |
This builds on top of #1107 to also support evaluation of standalone Python scripts.
See the README for a detailed example of parallelizing evaluation of a MNIST script.
I also did some refactoring to move common classes from RLlib into the ray.tune dir, however this isn't completely finished so ray.tune still has some RLlib dependencies.
cc @richardliaw @pcmoritz