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

[AutoScheduler] Python based measure callbacks #7143

Merged
merged 9 commits into from
Dec 24, 2020

Conversation

comaniac
Copy link
Contributor

@comaniac comaniac commented Dec 21, 2020

The current auto_scheduler callbacks can only be implemented in C++. This PR exposes the interface of measure callbacks to Python so that people can plug in their own callback functions easily.

Note: looks like I cannot pass the SearchPolicy node to the PackedFunc. Specifically, callback_func(policy, inputs, results); results in the type mismatching error. This also prevents us from introducing the Python API for SearchCallback. Any advise is appreciated.

cc @merrymercy @jcf94

@comaniac
Copy link
Contributor Author

Per offline discussion, we cast the abstract SearchPolicy to the actual instance so that we can pass it to the packed function.

@merrymercy @jcf94 PTAL.

Copy link
Contributor

@jcf94 jcf94 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@comaniac
Copy link
Contributor Author

I also took a look at the SearchCallback (it should be named to something like PreSearchCallback because it will be called once in the beginning of search instead of every round) but decided not to add a Python interface in this PR. Since we don't expose useful SearchPolicy APIs to Python, the Python-based callback can do nothing at this moment. Meanwhile, it's worthwhile to consider PreloadCustomSketchRule as @antinucleon suggested in another PR.

@jcf94
Copy link
Contributor

jcf94 commented Dec 24, 2020

I also took a look at the SearchCallback (it should be named to something like PreSearchCallback because it will be called once in the beginning of search instead of every round) but decided not to add a Python interface in this PR. Since we don't expose useful SearchPolicy APIs to Python, the Python-based callback can do nothing at this moment. Meanwhile, it's worthwhile to consider PreloadCustomSketchRule as @antinucleon suggested in another PR.

Actually we already have a init_search_callbacks in the constructor function of SearchPolicy which will be called before the search process. And we also have the PreloadCustomSketchRule in our dev repo ...

@comaniac
Copy link
Contributor Author

Actually we already have a init_search_callbacks in the constructor function of SearchPolicy which will be called before the search process. And we also have the PreloadCustomSketchRule in our dev repo ...

Yeah that's why I bring up this, but my point is these callbacks are C-based instead of Python so there are not that convenient for users to experiment.

@jcf94
Copy link
Contributor

jcf94 commented Dec 24, 2020

Actually we already have a init_search_callbacks in the constructor function of SearchPolicy which will be called before the search process. And we also have the PreloadCustomSketchRule in our dev repo ...

Yeah that's why I bring up this, but my point is these callbacks are C-based instead of Python so there are not that convenient for users to experiment.

Oh, I find that comment: #7132 (comment)
I agree with your point.
So seems we will need to:

  1. Add the PreloadCustomSketchRule which enables users to add their own custom sketches. (And that's what we have already planed long before but didn't take action to bring that here from our dev repo ....)
  2. Just like your have added a python based MeasureCallback here, we'd better add a python based SearchCallback for init_search_callbacks.
  3. Better re-arrange the rules->push_back(.......) part, maybe also move them to Python as a InitSearchCallback.

Also cc @merrymercy @antinucleon

@merrymercy merrymercy merged commit 68e7838 into apache:main Dec 24, 2020
@comaniac comaniac deleted the ansor_callback_py branch December 24, 2020 17:08
tkonolige pushed a commit to tkonolige/incubator-tvm that referenced this pull request Jan 11, 2021
* add

* make it work

* format

* add poilcy

* comment

* move test

* format

* fix ci

* Delete useless old code

Co-authored-by: Lianmin Zheng <[email protected]>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Jan 20, 2021
* add

* make it work

* format

* add poilcy

* comment

* move test

* format

* fix ci

* Delete useless old code

Co-authored-by: Lianmin Zheng <[email protected]>
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jan 21, 2021
* add

* make it work

* format

* add poilcy

* comment

* move test

* format

* fix ci

* Delete useless old code

Co-authored-by: Lianmin Zheng <[email protected]>
electriclilies pushed a commit to electriclilies/tvm that referenced this pull request Feb 18, 2021
* add

* make it work

* format

* add poilcy

* comment

* move test

* format

* fix ci

* Delete useless old code

Co-authored-by: Lianmin Zheng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants