# How to change default agent\_timesteps\_total in rllib\_trainer.train()

**URL:** https://discuss.ray.io/t/how-to-change-default-agent-timesteps-total-in-rllib-trainer-train/2705
**Category:** RLlib
**Created:** [June 29, 2021, 5:35pm UTC](https://discuss.ray.io/t/how-to-change-default-agent-timesteps-total-in-rllib-trainer-train/2705 "2021-06-29T17:35:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Arif\_Jahangir](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/arif_jahangir/32/806_2.png) [@Arif\_Jahangir](https://discuss.ray.io/u/Arif_Jahangir)
#### Post date: [June 29, 2021, 5:35pm UTC](https://discuss.ray.io/t/how-to-change-default-agent-timesteps-total-in-rllib-trainer-train/2705/1 "2021-06-29T17:35:07Z")

</div>

Hi  
Could some please tell me how to change default agent\_timesteps\_total in rllib\_trainer.train(). Defualt is 4000 steps. How can we change this. Thanks

---

<div class="post-metadata">

### Author: ![arturn](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/arturn/32/2096_2.png) [@arturn](https://discuss.ray.io/u/arturn)
#### Post date: [June 29, 2021, 7:37pm UTC](https://discuss.ray.io/t/how-to-change-default-agent-timesteps-total-in-rllib-trainer-train/2705/2 "2021-06-29T19:37:04Z")

</div>

Hi Arif,

agent\_timesteps\_total is a metric that shows you what it’s name suggests.  
In the [tune documentation](https://docs.ray.io/en/master/tune/api_docs/execution.html) you find mutliple possibilities to stop a training:

> - **stop** (dict | callable | [`Stopper`](https://docs.ray.io/en/master/tune/api_docs/stoppers.html#ray.tune.Stopper)) – Stopping criteria. If dict, the keys may be any field in the return result of ‘train()’, whichever is reached first. If function, it must take (trial\_id, result) as arguments and return a boolean (True if trial should be stopped, False otherwise). This can also be a subclass of `ray.tune.Stopper` , which allows users to implement custom experiment-wide stopping (i.e., stopping an entire Tune run based on some time constraint).

So in your case, you could call tune.run() like this:  
tune.run(stop={“timesteps\_total”: 4000}).

Hope this helps

---

<div class="post-metadata">

### Author: ![Arif\_Jahangir](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/arif_jahangir/32/806_2.png) [@Arif\_Jahangir](https://discuss.ray.io/u/Arif_Jahangir)
#### Post date: [June 29, 2021, 7:39pm UTC](https://discuss.ray.io/t/how-to-change-default-agent-timesteps-total-in-rllib-trainer-train/2705/3 "2021-06-29T19:39:29Z")

</div>

Thank you a lot @arturn

---

<div class="post-metadata">

### Author: ![mannyv](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mannyv/32/606_2.png) [@mannyv](https://discuss.ray.io/u/mannyv)
#### Post date: [June 29, 2021, 11:02pm UTC](https://discuss.ray.io/t/how-to-change-default-agent-timesteps-total-in-rllib-trainer-train/2705/4 "2021-06-29T23:02:42Z")

</div>

Hi @Arif_Jahangir,

There is also a key in the config called “timesteps\_per\_iteration” that controls how many new timesteps of experience are collected for each call to train(). For PPO the default is 4000 but you can adjust that if you want.

The intended usage in rllib is that the train function will be called many times in a loop. Either by you or automatically by tune. You can use the stopping criteria @arturn mentioned in combination with tune to determine when training should stop.
