Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tvmc] Introduce 'tune' subcommand (part 3/4) #6537

Merged
merged 6 commits into from
Sep 29, 2020
Merged

[tvmc] Introduce 'tune' subcommand (part 3/4) #6537

merged 6 commits into from
Sep 29, 2020

Conversation

leandron
Copy link
Contributor

Introduce a sub-command to drive auto-tuning via command line, using AutoTVM, to produce the tuning records that can be used at compile time, or to further improve other tuning sessions. It follow good practices present on the auto-tuning tutorials.

In case you want to try it out (supposing you have your tvm built and working with this PR), you can have a look on the example below:

$ wget https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet50-v2-7.onnx
$ python -m tvm.driver.tvmc --verbose tune --trials 1 --output log1.txt --target="llvm" resnet50-v2-7.onnx
(...messages...)
WARNING:root:Attribute spatial is ignored in relay.sym.batch_norm
[Task  1/23]  Current/Best:    0.00/   0.00 GFLOPS | Progress: (1/1) | 1.32 s Done.
[Task  2/23]  Current/Best:    0.00/   0.00 GFLOPS | Progress: (1/1) | 1.23 s Done.
[Task  3/23]  Current/Best:    0.00/   0.00 GFLOPS | Progress: (1/1) | 1.07 s Done.
...

cc @comaniac @masahi @FrozenGene for reviews if possible

@comaniac comaniac self-assigned this Sep 23, 2020
@comaniac comaniac changed the title tvmc: introduce 'tune' subcommand (part 3/4) [tvmc] Introduce 'tune' subcommand (part 3/4) Sep 23, 2020
Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python/tvm/driver/tvmc/autotuner.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/autotuner.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/autotuner.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/autotuner.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/autotuner.py Show resolved Hide resolved
python/tvm/driver/tvmc/autotuner.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/autotuner.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/autotuner.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/autotuner.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/common.py Show resolved Hide resolved
@comaniac comaniac added the status: need update need update based on feedbacks label Sep 23, 2020
@FrozenGene
Copy link
Member

Thanks @leandron , great job. Besides this, I think we could also add some features I think it is important too:

  1. We could add --num-threads to control how many cores to tune. This is important for remote devices like ARM
  2. We could add --cpu-mode to control BIG core or LITTLE core to tune. Imagine remote devices like have A72 + A35. This feature maybe should require us to expose one interface in our AutoTVM to use API runtime.config_threadpool.

@leandron
Copy link
Contributor Author

leandron commented Sep 25, 2020

We could add --num-threads to control how many cores to tune. This is important for remote devices like ARM

@FrozenGene that looks interesting. Just to clarify, is this not related to the parameter n_parallel, from autotvm.RPCRunner, already supported via --parallel?

We could add --cpu-mode to control BIG core or LITTLE core to tune. Imagine remote devices like have A72 + A35. This feature maybe should require us to expose one interface in our AutoTVM to use API runtime.config_threadpool.

Yes, that looks useful. Can we add it in a separate PR, considering it requires some infra to be exposed to AutoTVM?

@FrozenGene
Copy link
Member

We could add --num-threads to control how many cores to tune. This is important for remote devices like ARM

@FrozenGene that looks interesting. Just to clarify, is this not related to the parameter n_parallel, from autotvm.RPCRunner, already supported via --parallel?

Yes, it is not related with n_parallel, which is to support we have multi devices to tune.

We could add --cpu-mode to control BIG core or LITTLE core to tune. Imagine remote devices like have A72 + A35. This feature maybe should require us to expose one interface in our AutoTVM to use API runtime.config_threadpool.

Yes, that looks useful. Can we add it in a separate PR, considering it requires some infra to be exposed to AutoTVM?

Fine to me.

@leandron
Copy link
Contributor Author

@FrozenGene that looks interesting. Just to clarify, is this not related to the parameter n_parallel, from autotvm.RPCRunner, already supported via --parallel?

Yes, it is not related with n_parallel, which is to support we have multi devices to tune.

Understood. I'm happy to look into it. Can you expand a bit on how that would work, so that we can decide whether adding it here or on a future PR?

@FrozenGene
Copy link
Member

@FrozenGene that looks interesting. Just to clarify, is this not related to the parameter n_parallel, from autotvm.RPCRunner, already supported via --parallel?

Yes, it is not related with n_parallel, which is to support we have multi devices to tune.

Understood. I'm happy to look into it. Can you expand a bit on how that would work, so that we can decide whether adding it here or on a future PR?

You need to do the similar thing like we control BIG / LITTLE core via runtime.config_threadpool, this api could let us control how many cores and which cpu mode we like. So I am fine leave this in the future pr together with control BIG / LITTLE cpu mode.

@leandron
Copy link
Contributor Author

Re-triggering CI

@leandron
Copy link
Contributor Author

This PR is passing CI again.

@comaniac @FrozenGene do you mind having another look?

@comaniac comaniac merged commit c0a6bc3 into apache:master Sep 29, 2020
@comaniac
Copy link
Contributor

Thanks @leandron @FrozenGene

@comaniac comaniac added status: accepted and removed status: need update need update based on feedbacks labels Sep 29, 2020
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 13, 2020
* tvmc: introduce 'tune' subcommand (part 3/4)

 * introduces a subcommand to drive auto-tuning

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>

* [tvmc] address code review comments

* adjust --min-repeat-ms default value logic

* re-arrange rpc arguments to be --rpc-tracker=hostname:port and --rpc-key=str

* use a local reference of the tvmc logger

* add --target-host, default to llvm

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 14, 2020
* tvmc: introduce 'tune' subcommand (part 3/4)

 * introduces a subcommand to drive auto-tuning

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>

* [tvmc] address code review comments

* adjust --min-repeat-ms default value logic

* re-arrange rpc arguments to be --rpc-tracker=hostname:port and --rpc-key=str

* use a local reference of the tvmc logger

* add --target-host, default to llvm

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 15, 2020
* tvmc: introduce 'tune' subcommand (part 3/4)

 * introduces a subcommand to drive auto-tuning

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>

* [tvmc] address code review comments

* adjust --min-repeat-ms default value logic

* re-arrange rpc arguments to be --rpc-tracker=hostname:port and --rpc-key=str

* use a local reference of the tvmc logger

* add --target-host, default to llvm

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 15, 2020
* tvmc: introduce 'tune' subcommand (part 3/4)

 * introduces a subcommand to drive auto-tuning

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>

* [tvmc] address code review comments

* adjust --min-repeat-ms default value logic

* re-arrange rpc arguments to be --rpc-tracker=hostname:port and --rpc-key=str

* use a local reference of the tvmc logger

* add --target-host, default to llvm

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 16, 2020
* tvmc: introduce 'tune' subcommand (part 3/4)

 * introduces a subcommand to drive auto-tuning

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>

* [tvmc] address code review comments

* adjust --min-repeat-ms default value logic

* re-arrange rpc arguments to be --rpc-tracker=hostname:port and --rpc-key=str

* use a local reference of the tvmc logger

* add --target-host, default to llvm

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Oct 19, 2020
* tvmc: introduce 'tune' subcommand (part 3/4)

 * introduces a subcommand to drive auto-tuning

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>

* [tvmc] address code review comments

* adjust --min-repeat-ms default value logic

* re-arrange rpc arguments to be --rpc-tracker=hostname:port and --rpc-key=str

* use a local reference of the tvmc logger

* add --target-host, default to llvm

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants