Skip to content

Commit

Permalink
configurable cap of bounded #71
Browse files Browse the repository at this point in the history
  • Loading branch information
shu5620 committed Aug 16, 2023
1 parent e19a749 commit ed8c268
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion border-async-trainer/src/actor_manager/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ where
/// This parameter is used as `n_buffer` in [`ReplayBufferProxyConfig`].
n_buffer: usize,

/// capacity of channel between each actor and actor-manager
channel_capacity: usize,

/// Flag to stop training
stop: Arc<Mutex<bool>>,

Expand Down Expand Up @@ -90,6 +93,7 @@ where
env_config: env_config.clone(),
step_proc_config: step_proc_config.clone(),
n_buffer: config.n_buffer,
channel_capacity: config.channel_capacity,
stop,
threads: vec![],
batch_message_receiver: None,
Expand Down Expand Up @@ -130,7 +134,7 @@ where

// Create channel for [BatchMessage]
// let (s, r) = unbounded();
let (s, r) = bounded(1000);
let (s, r) = bounded(self.channel_capacity);
self.batch_message_receiver = Some(r.clone());

// Runs sampling processes
Expand Down
4 changes: 4 additions & 0 deletions border-async-trainer/src/actor_manager/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ pub struct ActorManagerConfig {
///
/// The default value is 100.
pub n_buffer: usize,

/// capacity of channel between each actor and actor-manager
pub channel_capacity: usize,
}

impl Default for ActorManagerConfig {
fn default() -> Self {
Self {
n_buffer: 100,
channel_capacity: 1000,
}
}
}
3 changes: 3 additions & 0 deletions border-async-trainer/src/async_trainer/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ pub struct AsyncTrainerConfig {

/// The number of episodes for evaluation
pub eval_episodes: usize,

/// capacity of channel between each actor-manager and async-trainer
pub channel_capacity: usize,
}

impl AsyncTrainerConfig {
Expand Down
2 changes: 1 addition & 1 deletion border-async-trainer/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn train_async<A, E, R, S, P>(

// Creates channels
// let (item_s, item_r) = unbounded(); // items pushed to replay buffer
let (item_s, item_r) = bounded(50); // items pushed to replay buffer
let (item_s, item_r) = bounded(async_trainer_config.channel_capacity); // items pushed to replay buffer
let (model_s, model_r) = unbounded(); // model_info

// guard for initialization of envs in multiple threads
Expand Down

0 comments on commit ed8c268

Please sign in to comment.