# Should I worry about measure error when auto-tuning multiple tasks simultaneously?

**URL:** <https://discuss.tvm.apache.org/t/should-i-worry-about-measure-error-when-auto-tuning-multiple-tasks-simultaneously/17381>\
**Category:** Uncategorized\
**Created:** [June 22, 2024, 6:53am UTC](https://discuss.tvm.apache.org/t/should-i-worry-about-measure-error-when-auto-tuning-multiple-tasks-simultaneously/17381 "2024-06-22T06:53:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rikora](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/rikora/32/5634_2.png) [@Rikora](https://discuss.tvm.apache.org/u/Rikora)\
**Post date:** [June 22, 2024, 6:53am UTC](https://discuss.tvm.apache.org/t/should-i-worry-about-measure-error-when-auto-tuning-multiple-tasks-simultaneously/17381/1 "2024-06-22T06:53:47Z")

</div>

Hi, I am new to tvm and I’m working with ansor. I’ve followed some tutorials and they worked well. Now I wonder If the measurements will remain correct if I launch multiple auto-tuning tasks simultaneously? I have referred to [How does AutoTVM distribute resources for tuning and runtime measurements on one single CPU?](https://discuss.tvm.apache.org/t/how-does-autotvm-distribute-resources-for-tuning-and-runtime-measurements-on-one-single-cpu/5530). It seems like it’s OK when CPU/GPU resources are relatively abundant. But what if I run 1,000 tasks on a CPU with only 32 threads? Or what if the total memory requirement of these task are somehow too large, lead to OS swap issue? Any help would be appreciated! 🙂

---

<div class="post-metadata">

**Author:** ![vinx13](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/vinx13/32/121_2.png) [@vinx13](https://discuss.tvm.apache.org/u/vinx13)\
**Post date:** [June 26, 2024, 1:37am UTC](https://discuss.tvm.apache.org/t/should-i-worry-about-measure-error-when-auto-tuning-multiple-tasks-simultaneously/17381/2 "2024-06-26T01:37:06Z")

</div>

if you tune GPU tasks this is likely fine since it measures GPU time. if you tune CPU tasks, running tuner and worker on the same machine can be inaccurate

---

<div class="post-metadata">

**Author:** ![tsu-bin](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/tsu-bin/32/5004_2.png) [@tsu-bin](https://discuss.tvm.apache.org/u/tsu-bin)\
**Post date:** [June 28, 2024, 4:30am UTC](https://discuss.tvm.apache.org/t/should-i-worry-about-measure-error-when-auto-tuning-multiple-tasks-simultaneously/17381/3 "2024-06-28T04:30:37Z")

</div>

Hi, not sure what the ‘multiple tasks’ you were refer to specifically, if the ‘tasks’ is what Ansor extrated from IrModule, which has nothing to do with hardware resource. For Ansor there are intermittent measuring periods when single task schedule is built and measured on target hardware. The measuring is done task by task sequentially not parallel.

---

<div class="post-metadata">

**Author:** ![Rikora](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/rikora/32/5634_2.png) [@Rikora](https://discuss.tvm.apache.org/u/Rikora)\
**Post date:** [July 3, 2024, 12:50am UTC](https://discuss.tvm.apache.org/t/should-i-worry-about-measure-error-when-auto-tuning-multiple-tasks-simultaneously/17381/4 "2024-07-03T00:50:44Z")

</div>

Thanks for replying! Sorry for the confusion. ☹

The ‘task’ I am refering to is not the subgraphs within a model.

It simply means different Ansor programs. For example, executing 10 scripts, each utilizing Ansor to tune its own operators. A GPU is shared for their measurements. 😀

---

<div class="post-metadata">

**Author:** ![tsu-bin](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/tsu-bin/32/5004_2.png) [@tsu-bin](https://discuss.tvm.apache.org/u/tsu-bin)\
**Post date:** [July 3, 2024, 3:58am UTC](https://discuss.tvm.apache.org/t/should-i-worry-about-measure-error-when-auto-tuning-multiple-tasks-simultaneously/17381/5 "2024-07-03T03:58:40Z")

</div>

Concurrent launching parallel cuda-graph or cuda kernel can definitely cause latency become larger, so results in inaccurate measuring. From my observation, Ansor tuning process is almost cpu bond (please correct me if I’m wrong), the gpu measuring span is only small portion, the most of time is spend on sampling valid schedule from sketch, and this is done by python multiprocessing, by default setting it will utilise all cpu cores, so I doubt is there any benefit to run multiple Ansor process concurrently.
