ast_toolbox.samplers.parallel_sampler module

Original parallel sampler pool backend.

ast_toolbox.samplers.parallel_sampler.close()[source]

Close the worker pool.

ast_toolbox.samplers.parallel_sampler.initialize(n_parallel)[source]

Initialize the worker pool.

SIGINT is blocked for all processes created in parallel_sampler to avoid the creation of sleeping and zombie processes.

If the user interrupts run_experiment, there’s a chance some processes won’t die due to a dead lock condition where one of the children in the parallel sampler exits without releasing a lock once after it catches SIGINT.

Later the parent tries to acquire the same lock to proceed with his cleanup, but it remains sleeping waiting for the lock to be released. In the meantime, all the process in parallel sampler remain in the zombie state since the parent cannot proceed with their clean up.

Parameters:n_parallel (int) – Number of workers to run in parallel.
ast_toolbox.samplers.parallel_sampler.populate_task(env, policy, scope=None)[source]

Set each worker’s env and policy.

Parameters:
  • env (ast_toolbox.envs.ASTEnv) – The environment.
  • policy (garage.tf.policies.Policy) – The policy.
  • scope (str) – Scope for identifying the algorithm. Must be specified if running multiple algorithms simultaneously, each using different environments and policies.
ast_toolbox.samplers.parallel_sampler.sample_paths(policy_params, max_samples, max_path_length=inf, env_params=None, scope=None)[source]

Sample paths from each worker.

Parameters:
  • policy_params – parameters for the policy. This will be updated on each worker process
  • max_samples (int) – desired maximum number of samples to be collected. The actual number of collected samples might be greater since all trajectories will be rolled out either until termination or until max_path_length is reached
  • max_path_length (int, optional) – horizon / maximum length of a single trajectory
  • scope (str) – Scope for identifying the algorithm. Must be specified if running multiple algorithms simultaneously, each using different environments and policies.
ast_toolbox.samplers.parallel_sampler.set_seed(seed)[source]

Set the seed in each worker.

Parameters:seed (int) – The random seed to be used by the worker.
ast_toolbox.samplers.parallel_sampler.terminate_task(scope=None)[source]

Close each worker’s env and terminate each policy.

Parameters:scope (str) – Scope for identifying the algorithm. Must be specified if running multiple algorithms simultaneously, each using different environments and policies.