• Docs >
  • worker.coordinator.commander
Shortcuts

worker.coordinator.commander

base_serial_commander

BaseSerialCommander

class ding.worker.coordinator.base_serial_commander.BaseSerialCommander(cfg: dict, learner: BaseLearner, collector: BaseSerialCollector, evaluator: InteractionSerialEvaluator, replay_buffer: IBuffer, policy: namedtuple = None)[source]
Overview:

Base serial commander class.

Interface:

__init__, step

Property:

policy

__init__(cfg: dict, learner: BaseLearner, collector: BaseSerialCollector, evaluator: InteractionSerialEvaluator, replay_buffer: IBuffer, policy: namedtuple = None) None[source]
Overview:

Init the BaseSerialCommander

Arguments:
  • cfg (dict): the config of commander

  • learner (BaseLearner): the learner

  • collector (BaseSerialCollector): the collector

  • evaluator (InteractionSerialEvaluator): the evaluator

  • replay_buffer (IBuffer): the buffer

step() None[source]
Overview:

Step the commander

base_parallel_commander

BaseCommander

class ding.worker.coordinator.base_parallel_commander.BaseCommander[source]
Overview:

Base parallel commander abstract class.

Interface:

get_collector_task

NaiveCommander

class ding.worker.coordinator.base_parallel_commander.NaiveCommander(cfg: dict)[source]
Overview:

A naive implementation of parallel commander.

Interface:

__init__, get_collector_task, get_learner_task, finsh_collector_task, finish_learner_task, notify_fail_collector_task, notify_fail_learner_task, update_learner_info

__init__(cfg: dict) None[source]
Overview:

Init the naive commander according to config

Arguments:
  • cfg (dict): The config to init commander. Should include

    “collector_task_space” and “learner_task_space”.

finish_collector_task(task_id: str, finished_task: dict) None[source]
Overview:

finish collector task will add the collector_task_finish_count

finish_learner_task(task_id: str, finished_task: dict) str[source]
Overview:

finish learner task will add the learner_task_finish_count and get the buffer_id of task to close the buffer

Return:

the finished_task buffer_id

get_collector_task() dict[source]
Overview:

Get a new collector task when collector_task_count is smaller than collector_task_space.

Return:
  • task (dict): New collector task.

get_learner_task() dict[source]
Overview:

Get the new learner task when task_count is less than task_space

Return:
  • task (dict): the new learner task

notify_fail_collector_task(task: dict) None[source]
Overview:

naive coordinator will pass when need to notify_fail_collector_task

notify_fail_learner_task(task: dict) None[source]
Overview:

naive coordinator will pass when need to notify_fail_learner_task

create_parallel_commander

Overview:

create the commander according to cfg

Arguments:
  • cfg (dict): the commander cfg to create, should include import_names and parallel_commander_type

solo_parallel_commander

SoloCommander

class ding.worker.coordinator.solo_parallel_commander.SoloCommander(cfg: dict)[source]
Overview:

Parallel commander for solo games.

Interface:

__init__, get_collector_task, get_learner_task, finish_collector_task, finish_learner_task, notify_fail_collector_task, notify_fail_learner_task, update_learner_info

__init__(cfg: dict) None[source]
Overview:

Init the solo commander according to config.

Arguments:
  • cfg (dict): Dict type config file.

finish_collector_task(task_id: str, finished_task: dict) bool[source]
Overview:

Get collector’s finish_task_info and release collector_task_space. If collector’s task is evaluation, judge the convergence and return it.

Arguments:
  • task_id (str): the collector task_id

  • finished_task (dict): the finished task

Returns:
  • convergence (bool): Whether the stop val is reached and the algorithm is converged.

    If True, the pipeline can be finished.

finish_learner_task(task_id: str, finished_task: dict) str[source]
Overview:

Get learner’s finish_task_info, release learner_task_space, reset corresponding variables.

Arguments:
  • task_id (str): Learner task_id

  • finished_task (dict): Learner’s finish_learn_info.

Returns:
  • buffer_id (str): Buffer id of the finished learner.

get_collector_task() dict | None[source]
Overview:

Return the new collector task when there is residual task space; Otherwise return None.

Return:
  • task (Optional[dict]): New collector task.

get_learner_task() dict | None[source]
Overview:

Return the new learner task when there is residual task space; Otherwise return None.

Return:
  • task (Optional[dict]): New learner task.

notify_fail_collector_task(task: dict) None[source]
Overview:

Release task space when collector task fails.

notify_fail_learner_task(task: dict) None[source]
Overview:

Release task space when learner task fails.