# Tune.run() vs Tuner.fit()

**URL:** <https://discuss.ray.io/t/tune-run-vs-tuner-fit/7041>\
**Category:** Ray Tune\
**Created:** [August 1, 2022, 9:54pm UTC](https://discuss.ray.io/t/tune-run-vs-tuner-fit/7041 "2022-08-01T21:54:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![raytune\_kuberay\_user](https://avatars.discourse-cdn.com/v4/letter/r/a87d85/32.png) [@raytune\_kuberay\_user](https://discuss.ray.io/u/raytune_kuberay_user)\
**Post date:** [August 1, 2022, 9:54pm UTC](https://discuss.ray.io/t/tune-run-vs-tuner-fit/7041/1 "2022-08-01T21:54:38Z")

</div>

Recently saw the readme change from using tune.run() to use Tuner.fit()

> <https://github.com/ray-project/ray/commit/8fe439998ecd48b1da5216d882123e6bde3b8fb7>
>
> Signed-off-by: Kai Fricke coding@kaifricke.com
> 
> Why are these changes needed?
> …
> Splitting up #26884: This PR includes changes to use Tuner() instead of tune.run() for most docs files (rst and py), and a change to move reuse\_actors to the TuneConfig

Will tune.run() API be removed in the future?  
How stable is this new Tuner.fit() API?  
Which API do you recommend?

---

<div class="post-metadata">

**Author:** ![xwjiang2010](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/xwjiang2010/32/1476_2.png) [@xwjiang2010](https://discuss.ray.io/u/xwjiang2010)\
**Post date:** [August 1, 2022, 11:32pm UTC](https://discuss.ray.io/t/tune-run-vs-tuner-fit/7041/2 "2022-08-01T23:32:39Z")

</div>

@raytune_kuberay_user  
Thanks for asking this question.  
Tuner is the recommended way of running hpo workload on Ray AIR. The migration is needed for various Ray components (Ray Tune/ Ray Train etc) in Ray AIR to have consistent feel and APIs.  
If you are looking to expand your use case beyond just tuning, Tuner would be a better API to use. `Tuner` is currently at the beta stage (with the new ray 2.0.0 release). In the long run, `tune.run` will be deprecated. If you see any gap with the `tune.run` API, please file a bug and let Ray Team know. Thank you!!

---

<div class="post-metadata">

**Author:** ![raytune\_kuberay\_user](https://avatars.discourse-cdn.com/v4/letter/r/a87d85/32.png) [@raytune\_kuberay\_user](https://discuss.ray.io/u/raytune_kuberay_user)\
**Post date:** [August 2, 2022, 6:00pm UTC](https://discuss.ray.io/t/tune-run-vs-tuner-fit/7041/3 "2022-08-02T18:00:37Z")

</div>

@xwjiang2010 Thanks for the reply.

In terms of functionality, are there anything that tune.run() supports and Tuner doesn’t support? (Also tuner supports but tune.run() doesn’t support?)

Our use cases are to use ray.tune + tensorflow + horovod/tf.distributed strategy. In the future, we might want to try elastic horovod with ray

---

<div class="post-metadata">

**Author:** ![kai](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kai/32/3380_2.png) [@kai](https://discuss.ray.io/u/kai)\
**Post date:** [August 3, 2022, 2:41pm UTC](https://discuss.ray.io/t/tune-run-vs-tuner-fit/7041/4 "2022-08-03T14:41:03Z")

</div>

There are minor API differences - e.g. the `export_models` argument has not been carried over to Tuner() as it will be deprecated (instead you should just export the models within the checkpoints).

At the moment, Tuner() uses tune.run internally, but this may change in the future.

We believe that all use cases should be covered in the Tuner() API, so if any functionality is missing, please let us know and we’ll add it!

As for benefits, the Tuner() API supports e.g. better restoration, failure handling, and a neater output format (results grid instead of experiment analysis).

---

<div class="post-metadata">

**Author:** ![zhh210](https://avatars.discourse-cdn.com/v4/letter/z/ce73a5/32.png) [@zhh210](https://discuss.ray.io/u/zhh210)\
**Post date:** [November 4, 2022, 5:28pm UTC](https://discuss.ray.io/t/tune-run-vs-tuner-fit/7041/5 "2022-11-04T17:28:17Z")

</div>

where to pass over `checkpoint_freq` in `Tuner()`? it works find in `tune.run(checkpoint_freq=1)` but can’t find where it can be passed to `Tuner`. Neither `run_config` nor `checkpoint_config` accepted `checkpoint_freq`.

---

<div class="post-metadata">

**Author:** ![xwjiang2010](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/xwjiang2010/32/1476_2.png) [@xwjiang2010](https://discuss.ray.io/u/xwjiang2010)\
**Post date:** [November 4, 2022, 5:38pm UTC](https://discuss.ray.io/t/tune-run-vs-tuner-fit/7041/6 "2022-11-04T17:38:41Z")

</div>

use `run_config.checkpoint_config`.

---

<div class="post-metadata">

**Author:** ![a28091](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/a28091/32/5388_2.png) [@a28091](https://discuss.ray.io/u/a28091)\
**Post date:** [September 3, 2023, 1:56pm UTC](https://discuss.ray.io/t/tune-run-vs-tuner-fit/7041/7 "2023-09-03T13:56:24Z")

</div>

Hi! In tune.run(…) it is possible to use

`tune.run(..., config={"evaluation_config": {..}}`

to evaluate your agent after training.  
What is the proper way to implement this within tune.Tuner() API?

---

<div class="post-metadata">

**Author:** ![kai](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kai/32/3380_2.png) [@kai](https://discuss.ray.io/u/kai)\
**Post date:** [September 5, 2023, 8:10am UTC](https://discuss.ray.io/t/tune-run-vs-tuner-fit/7041/8 "2023-09-05T08:10:02Z")

</div>

@a28091 this is an rllib-specific setting, but it should work the same in `tune.run` and `Tuner.fit()` - i.e. just pass it as part of your `param_space`:

```auto
Tuner(
    ...,
    param_space={"evaluation_config": ...}
)

```
