-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support `slice` operation in ExperienceSet * Support naive distributed policy training by proxy * Dynamically allocate trainers according to number of experience * code check * code check * code check * Fix a bug in distributed trianing with no gradient * Code check * Move Back-Propagation from trainer to policy_manager and extract trainer-allocation strategy * 1.call allocate_trainer() at first of update(); 2.refine according to code review * Code check * Refine code with new interface * Update docs of PolicyManger and ExperienceSet * Add images for rl_toolkit docs * Update diagram of PolicyManager * Refine with new interface * Extract allocation strategy into `allocation_strategy.py` * add `distributed_learn()` in policies for data-parallel training * Update doc of RL_toolkit * Add gradient workers for data-parallel * Refine code and update docs * Lint check * Refine by comments * Rename `trainer` to `worker` * Rename `distributed_learn` to `learn_with_data_parallel` * Refine allocator and remove redundant code in policy_manager * remove arugments in allocate_by_policy and so on
- Loading branch information
Showing
18 changed files
with
728 additions
and
89 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
|
||
import sys | ||
from os import getenv | ||
from os.path import dirname, realpath | ||
|
||
from maro.rl.learning import grad_worker | ||
|
||
workflow_dir = dirname(dirname(realpath(__file__))) # template directory | ||
if workflow_dir not in sys.path: | ||
sys.path.insert(0, workflow_dir) | ||
|
||
from general import log_dir, policy_func_dict | ||
|
||
|
||
if __name__ == "__main__": | ||
# TODO: WORKERID in docker compose script. | ||
worker_id = getenv("WORKERID") | ||
num_hosts = getenv("NUMHOSTS") | ||
distributed = getenv("DISTRIBUTED") == "True" | ||
if worker_id is None: | ||
raise ValueError("missing environment variable: WORKERID") | ||
if num_hosts is None: | ||
if distributed: | ||
raise ValueError("missing environment variable: NUMHOSTS") | ||
else: | ||
num_hosts = 0 | ||
|
||
group = getenv("LEARNGROUP", default="learn") | ||
grad_worker( | ||
policy_func_dict, | ||
int(worker_id), | ||
int(num_hosts), | ||
group, | ||
proxy_kwargs={ | ||
"redis_address": (getenv("REDISHOST", default="maro-redis"), int(getenv("REDISPORT", default=6379))), | ||
"max_peer_discovery_retries": 50 | ||
}, | ||
log_dir=log_dir | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.