[wingman -> rllib] Remote and entangled environments (#3968)

* added all our environment changes

* fixed merge request comments and remote env

* fixed remote check

* moved remote_worker_envs to correct config section

* lint

* auto wrap impl

* fix

* fixed the tests
This commit is contained in:
bjg2
2019-02-13 10:08:26 -08:00
committed by Eric Liang
parent b3f72e8a75
commit 0e37ac6d1d
6 changed files with 170 additions and 23 deletions
+29 -10
View File
@@ -129,6 +129,10 @@ COMMON_CONFIG = {
"compress_observations": False,
# Drop metric batches from unresponsive workers after this many seconds
"collect_metrics_timeout": 180,
# If using num_envs_per_worker > 1, whether to create those new envs in
# remote processes instead of in the same worker. This adds overheads, but
# can make sense if your envs are very CPU intensive (e.g., for StarCraft).
"remote_worker_envs": False,
# === Offline Datasets ===
# __sphinx_doc_input_begin__
@@ -463,7 +467,9 @@ class Agent(Trainable):
"tf_session_args": self.
config["local_evaluator_tf_session_args"]
}),
extra_config or {}))
extra_config or {}),
remote_worker_envs=False,
)
@DeveloperAPI
def make_remote_evaluators(self, env_creator, policy_graph, count):
@@ -476,9 +482,16 @@ class Agent(Trainable):
}
cls = PolicyEvaluator.as_remote(**remote_args).remote
return [
self._make_evaluator(cls, env_creator, policy_graph, i + 1,
self.config) for i in range(count)
self._make_evaluator(
cls,
env_creator,
policy_graph,
i + 1,
self.config,
remote_worker_envs=self.config["remote_worker_envs"])
for i in range(count)
]
@DeveloperAPI
@@ -544,8 +557,13 @@ class Agent(Trainable):
raise ValueError(
"`input_evaluation` should not be set when input=sampler")
def _make_evaluator(self, cls, env_creator, policy_graph, worker_index,
config):
def _make_evaluator(self,
cls,
env_creator,
policy_graph,
worker_index,
config,
remote_worker_envs=False):
def session_creator():
logger.debug("Creating TF session {}".format(
config["tf_session_args"]))
@@ -573,10 +591,10 @@ class Agent(Trainable):
compress_columns=config["output_compress_columns"]))
else:
output_creator = (lambda ioctx: JsonWriter(
config["output"],
ioctx,
max_file_size=config["output_max_file_size"],
compress_columns=config["output_compress_columns"]))
config["output"],
ioctx,
max_file_size=config["output_max_file_size"],
compress_columns=config["output_compress_columns"]))
return cls(
env_creator,
@@ -605,7 +623,8 @@ class Agent(Trainable):
callbacks=config["callbacks"],
input_creator=input_creator,
input_evaluation_method=config["input_evaluation"],
output_creator=output_creator)
output_creator=output_creator,
remote_worker_envs=remote_worker_envs)
@override(Trainable)
def _export_model(self, export_formats, export_dir):