# AutoTVM clarification

**URL:** <https://discuss.tvm.apache.org/t/autotvm-clarification/8766>\
**Category:** Application\
**Created:** [December 30, 2020, 2:15am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766 "2020-12-30T02:15:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![roger-zhao](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/roger-zhao/32/2224_2.png) [@roger-zhao](https://discuss.tvm.apache.org/u/roger-zhao)\
**Post date:** [December 30, 2020, 2:15am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766/1 "2020-12-30T02:15:42Z")

</div>

Hi, as far as I know, AutoTVM is amazing for automatically kernel generating, however, some limitation still exists(might be I’m wrong, pls correct me):

1. For the beginning, we need online running with hardware target for training a reliable cost model;

2. For each network model, we need tuning out a dedicated(only for this model) cost model and schedule policy(only for this model, of course we can build a “data-base”-like to store many of them then can use it when runtime, such as tophub, right?), then for another model, we need do tuning again(still online, even with transfer learning);

---

<div class="post-metadata">

**Author:** ![fantasyRqg](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/fantasyrqg/32/2566_2.png) [@fantasyRqg](https://discuss.tvm.apache.org/u/fantasyRqg)\
**Post date:** [January 4, 2021, 3:06am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766/2 "2021-01-04T03:06:56Z")

</div>

[How to optimize GEMM on CPU](https://tvm.apache.org/docs/tutorials/optimize/opt_gemm.html) shows basic steps what AutoTVM does

AutoTVM search optimiazations depends on search policies(cacheline, simd, etc. ) and nn operator’s params (input shape ,outputshape , kernel shape, etc)

Operators with same params can share optimized result cross network models. But in practical , operators with same params is rare

---

<div class="post-metadata">

**Author:** ![roger-zhao](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/roger-zhao/32/2224_2.png) [@roger-zhao](https://discuss.tvm.apache.org/u/roger-zhao)\
**Post date:** [January 4, 2021, 4:34am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766/3 "2021-01-04T04:34:47Z")

</div>

That’s so kind of you! So, this means even TVM has “transfer learning” for AutoTVM, almost a brand-new autotuning will be needed if tuning a new NN model in the same hardware target, right? and “transfer learning” can just speed up or resume a tuning task, right?

---

<div class="post-metadata">

**Author:** ![fantasyRqg](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/fantasyrqg/32/2566_2.png) [@fantasyRqg](https://discuss.tvm.apache.org/u/fantasyRqg)\
**Post date:** [January 4, 2021, 4:42am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766/4 "2021-01-04T04:42:16Z")

</div>

There is no ‘transfer learning’. just same Operator params result in same cacluation

same data block ,same vectorization , etc .

---

<div class="post-metadata">

**Author:** ![roger-zhao](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/roger-zhao/32/2224_2.png) [@roger-zhao](https://discuss.tvm.apache.org/u/roger-zhao)\
**Post date:** [January 4, 2021, 5:17am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766/5 "2021-01-04T05:17:14Z")

</div>

Ok. Actually TVM has a API called “load\_history(\*.tmp)” named as “transfer learning”, such as [transfer\_learning TVM example](https://github.com/apache/tvm/blob/86a8504a7ccb956591ffd1a529f625df7d20b520/tutorials/autotvm/tune_relay_cuda.py#L196)

---

<div class="post-metadata">

**Author:** ![fantasyRqg](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/fantasyrqg/32/2566_2.png) [@fantasyRqg](https://discuss.tvm.apache.org/u/fantasyRqg)\
**Post date:** [January 4, 2021, 6:09am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766/6 "2021-01-04T06:09:40Z")

</div>

You are right there is ‘transfer learning’ . This is first time I known ‘load\_history’ api .

---

<div class="post-metadata">

**Author:** ![roger-zhao](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/roger-zhao/32/2224_2.png) [@roger-zhao](https://discuss.tvm.apache.org/u/roger-zhao)\
**Post date:** [January 4, 2021, 7:01am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766/7 "2021-01-04T07:01:23Z")

</div>

@comaniac @zhiics , am I right?

---

<div class="post-metadata">

**Author:** ![comaniac](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/comaniac/32/899_2.png) [@comaniac](https://discuss.tvm.apache.org/u/comaniac)\
**Post date:** [January 4, 2021, 8:05am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766/8 "2021-01-04T08:05:10Z")

</div>

When you use the `load_history` of `XGBTuner`, the cost model in the `XGBTuner` will be trained by the loaded tuning logs so that it could find better configs sooner; otherwise it starts with random configs and uses their measurement results to train a new cost model.

---

<div class="post-metadata">

**Author:** ![roger-zhao](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/roger-zhao/32/2224_2.png) [@roger-zhao](https://discuss.tvm.apache.org/u/roger-zhao)\
**Post date:** [January 4, 2021, 8:14am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766/9 "2021-01-04T08:14:10Z")

</div>

Thanks, so theoretically I can say that if the saved tuning log has enough infos(or tuning trials), so I can train a cost model offline(I mean without a real hardware target), because from user side, they don’t want to tuning every model/OPs(time cost) before deploying into production environment for the same hardware target.

---

<div class="post-metadata">

**Author:** ![comaniac](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/comaniac/32/899_2.png) [@comaniac](https://discuss.tvm.apache.org/u/comaniac)\
**Post date:** [January 4, 2021, 8:28am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766/10 "2021-01-04T08:28:09Z")

</div>

In that case, it’s actually better to directly save the best config of every op you have tuned. Otherwise your users still need to use the trained cost model to tune the ops for a few trials on the hardware device. You could refer to the idea in this presentation: [https://youtu.be/Aw9Z07n5jJQ](https://youtu.be/Aw9Z07n5jJQ)

---

<div class="post-metadata">

**Author:** ![roger-zhao](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/roger-zhao/32/2224_2.png) [@roger-zhao](https://discuss.tvm.apache.org/u/roger-zhao)\
**Post date:** [January 4, 2021, 9:32am UTC](https://discuss.tvm.apache.org/t/autotvm-clarification/8766/11 "2021-01-04T09:32:33Z")

</div>

Thanks so so much, it’s what exactly I want to see!
