# \[Tune\] Help Clarifying a tip in Trainable Class API

**URL:** <https://discuss.ray.io/t/tune-help-clarifying-a-tip-in-trainable-class-api/8070>\
**Category:** Ray Tune\
**Created:** [October 28, 2022, 8:07pm UTC](https://discuss.ray.io/t/tune-help-clarifying-a-tip-in-trainable-class-api/8070 "2022-10-28T20:07:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![max\_ronda](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@max\_ronda](https://discuss.ray.io/u/max_ronda)\
**Post date:** [October 28, 2022, 8:07pm UTC](https://discuss.ray.io/t/tune-help-clarifying-a-tip-in-trainable-class-api/8070/1 "2022-10-28T20:07:23Z")

</div>

Hi Ray Team, I found this statement on the [Tune Training Class API:](https://docs.ray.io/en/latest/tune/api_docs/trainable.html#trainable-class-api)

_**As a rule of thumb, the execution time of `step` should be large enough to avoid overheads (i.e. more than a few seconds), but short enough to report progress periodically (i.e. at most a few minutes).**_

I get the first part. A trial should take longer than just a second but **what about the second part**? What will happen if my trial runs for hours? Will I not be able to use the Trainable Class API?

Thanks!

---

<div class="post-metadata">

**Author:** ![bveeramani](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/bveeramani/32/2941_2.png) [@bveeramani](https://discuss.ray.io/u/bveeramani)\
**Post date:** [November 1, 2022, 2:11am UTC](https://discuss.ray.io/t/tune-help-clarifying-a-tip-in-trainable-class-api/8070/2 "2022-11-01T02:11:14Z")

</div>

Hey @max_ronda, thanks for posting to the forum!

You should be able to use the `Trainable` API even if the execution time of `step` is long.

> …but short enough to report progress periodically (i.e. at most a few minutes).

My understanding is that there’s nothing wrong with long steps _per se_ – it’s more that frequent reports are useful to provide observability. For example, if you report too infrequently, you wouldn’t know if your program froze.

@Max_Pumperla did I misinterpret this?

---

<div class="post-metadata">

**Author:** ![Max\_Pumperla](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/max_pumperla/32/2475_2.png) [@Max\_Pumperla](https://discuss.ray.io/u/Max_Pumperla)\
**Post date:** [November 1, 2022, 7:21am UTC](https://discuss.ray.io/t/tune-help-clarifying-a-tip-in-trainable-class-api/8070/3 "2022-11-01T07:21:39Z")

</div>

Hey there!

I think the point is that “step” is designed to periodically report something. If something takes several hours to finish, you could still use it, but it would somewhat defy the purpose. In that case, you’d most likely just want to report your results once at the very end. Of course, if you train an LLM on the entire internet and each step does in fact take days, that’s ok too!

This is not a statement about Tune’s technical limitations, but rather about intended usage.

---

<div class="post-metadata">

**Author:** ![max\_ronda](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@max\_ronda](https://discuss.ray.io/u/max_ronda)\
**Post date:** [November 1, 2022, 3:25pm UTC](https://discuss.ray.io/t/tune-help-clarifying-a-tip-in-trainable-class-api/8070/4 "2022-11-01T15:25:42Z")

</div>

Thanks for the clarification @Max_Pumperla ! In my case, I am using Tune slightly different, not only to Tune a ML model but any objective function. So steps might take longer depending on what I am running.

Another quick question:

Should there be any noticeable difference using `Function API` vs `Trainable API`? From my testing, I found Trainable API scaled better. Is that because Trainable API uses `Ray Actors` and spawns one Actor with one Step? While Function API uses threads within Ray Actor? Could you **clarify** that ?

---

<div class="post-metadata">

**Author:** ![bveeramani](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/bveeramani/32/2941_2.png) [@bveeramani](https://discuss.ray.io/u/bveeramani)\
**Post date:** [November 1, 2022, 11:43pm UTC](https://discuss.ray.io/t/tune-help-clarifying-a-tip-in-trainable-class-api/8070/5 "2022-11-01T23:43:53Z")

</div>

> Should there be any noticeable difference using `Function API` vs `Trainable API`?

There shouldn’t be. We convert functions to `Trainable`s internally.

> From my testing, I found Trainable API scaled better.

I’m surprised to hear this. Could you tell me more? In particular, by which metric did the trainable API scale better?

---

<div class="post-metadata">

**Author:** ![max\_ronda](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@max\_ronda](https://discuss.ray.io/u/max_ronda)\
**Post date:** [November 8, 2022, 7:14pm UTC](https://discuss.ray.io/t/tune-help-clarifying-a-tip-in-trainable-class-api/8070/6 "2022-11-08T19:14:27Z")

</div>

Hey @bveeramani I will post some benchmarks to showcase that

---

<div class="post-metadata">

**Author:** ![bveeramani](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/bveeramani/32/2941_2.png) [@bveeramani](https://discuss.ray.io/u/bveeramani)\
**Post date:** [November 9, 2022, 8:15pm UTC](https://discuss.ray.io/t/tune-help-clarifying-a-tip-in-trainable-class-api/8070/7 "2022-11-09T20:15:33Z")

</div>

@max_ronda awesome, thanks!
