Skip to content

[microTVM] tuning on micro targets with meta-schedule#13514

Merged
mehrdadh merged 7 commits intoapache:mainfrom
mkatanbaf:micro-with-meta-schedule
Jan 11, 2023
Merged

[microTVM] tuning on micro targets with meta-schedule#13514
mehrdadh merged 7 commits intoapache:mainfrom
mkatanbaf:micro-with-meta-schedule

Conversation

@mkatanbaf
Copy link
Copy Markdown
Contributor

@mkatanbaf mkatanbaf commented Nov 29, 2022

adds support for tuning microTVM models using meta-schedule.

Summary of the changes:

  • adds "c" to the targets supported by meta-schedule
  • implements a builder and runner for micro devices
  • runs a simple tuning job for verification

@tvm-bot
Copy link
Copy Markdown
Collaborator

tvm-bot commented Nov 29, 2022

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@mkatanbaf mkatanbaf force-pushed the micro-with-meta-schedule branch 3 times, most recently from 341cecf to bc41156 Compare December 7, 2022 18:15
@mkatanbaf mkatanbaf marked this pull request as ready for review December 7, 2022 18:40
@mkatanbaf
Copy link
Copy Markdown
Contributor Author

cc @areusch @guberti @zxybazh

@mkatanbaf mkatanbaf changed the title [microTVM] micro tuning with meta-schedule [microTVM] tuning on micro targets with meta-schedule Dec 7, 2022
Copy link
Copy Markdown
Member

@zxybazh zxybazh left a comment

Choose a reason for hiding this comment

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

Thanks for send the PR for micro targets MS tuning! Generally looks ok to me except a few spots needs clarification and minor changes. Would be great if someone else could take a look at the relay executor and tvm rpc changes.

Comment thread python/tvm/meta_schedule/relay_integration.py
Comment thread python/tvm/meta_schedule/relay_integration.py
Comment thread python/tvm/contrib/micro/meta_schedule/test_autotune_ms.py Outdated
Comment thread python/tvm/contrib/micro/meta_schedule/rpc_runner_micro.py Outdated
Comment thread src/meta_schedule/schedule_rule/schedule_rule.cc Outdated
Copy link
Copy Markdown
Member

@guberti guberti left a comment

Choose a reason for hiding this comment

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

I'm not the right person to do an in-depth review here, but I'm really excited for these changes. Looking at this was helpful for understanding meta-schedule - I left a few nits too.

Comment thread python/tvm/contrib/micro/meta_schedule/local_builder_micro.py Outdated
Comment thread python/tvm/contrib/micro/meta_schedule/local_builder_micro.py Outdated
Comment thread python/tvm/contrib/micro/meta_schedule/local_builder_micro.py
Comment thread python/tvm/contrib/micro/meta_schedule/local_builder_micro.py Outdated
Comment thread python/tvm/contrib/micro/meta_schedule/local_builder_micro.py Outdated
Comment thread python/tvm/contrib/micro/meta_schedule/rpc_runner_micro.py Outdated
@mkatanbaf
Copy link
Copy Markdown
Contributor Author

@tvm-bot rerun

@mehrdadh
Copy link
Copy Markdown
Member

@mkatanbaf you might need to rebase with main.

@mkatanbaf mkatanbaf force-pushed the micro-with-meta-schedule branch from c0396fa to fc04678 Compare December 12, 2022 18:36
Copy link
Copy Markdown
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

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

thanks @mkatanbaf , added a few more comments/questions

Comment thread python/tvm/rpc/server.py Outdated
mod = IRModule({"main": prim_func})
runtime = Runtime("crt", {"system-lib": True})
mod = RemoveWeightLayoutRewriteBlock(skip_ndarray_rewrite=True)(mod)
rt_mod = tvm_build(mod, target=target, runtime=runtime)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just to confirm--are the relay.build changes needed in this PR? if not, could we remove them until we figure out how to wrap a TIR function in a Relay function?

Copy link
Copy Markdown
Contributor Author

@mkatanbaf mkatanbaf Jan 3, 2023

Choose a reason for hiding this comment

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

No, they are not. We continue to use tvm_build in tuning. The changes in relay_integration.py are needed for compiling the relay program using the MetaSchedule tuning database.

Comment thread src/target/target_kind.cc Outdated
Comment thread src/target/source/codegen_c_host.cc
Comment thread src/meta_schedule/schedule_rule/schedule_rule.cc Outdated
@mkatanbaf mkatanbaf force-pushed the micro-with-meta-schedule branch from bf80e6d to afda2c1 Compare January 3, 2023 23:49
Comment thread python/tvm/contrib/micro/meta_schedule/test_autotune_ms.py Outdated
Comment thread python/tvm/contrib/micro/meta_schedule/test_autotune_ms.py
@mkatanbaf
Copy link
Copy Markdown
Contributor Author

@areusch @mehrdadh @zxybazh Could you please take another look?

Comment thread tests/python/unittest/test_micro_ms_tuning.py Outdated
@mehrdadh mehrdadh requested review from guberti and zxybazh January 9, 2023 19:56
@mehrdadh
Copy link
Copy Markdown
Member

mehrdadh commented Jan 9, 2023

LGTM, I'll wait for the others and then merge it.
cc @guberti @zxybazh

@guberti
Copy link
Copy Markdown
Member

guberti commented Jan 9, 2023

LGTM, I think we can merge once tests pass.

@mkatanbaf mkatanbaf force-pushed the micro-with-meta-schedule branch from 8322e09 to 0c09eb7 Compare January 9, 2023 21:30
Copy link
Copy Markdown
Member

@zxybazh zxybazh left a comment

Choose a reason for hiding this comment

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

Generally looking good, just one question about the schedule rule set up.


Array<ScheduleRule> ScheduleRule::DefaultMicro() {
return {
ScheduleRule::AutoInline(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there any specific reason that ApplyCustomRule is not included as a rule here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, there was not. I copied the rules from the Hexagon rules a while ago, and the ApplyCustomRule was not added then. I added the rule.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi, after you add the ApplyCustomRule you may also consider to add other rules in the current Hexagon rules like InlineConstantScalars.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@zxybazh I think this could be in a follow up PR since the PR has been open for a while. thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @zxybazh, I already added the rest of Hexagon rules except the ParallelizeVectorizeUnroll which is not needed on the micro targets.

@mehrdadh
Copy link
Copy Markdown
Member

@tvm-bot rerun

@mehrdadh mehrdadh merged commit c2bc1ec into apache:main Jan 11, 2023
fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
adds support for tuning microTVM models using meta-schedule.

Summary of the changes:

adds "c" to the targets supported by meta-schedule
implements a builder and runner for micro devices
runs a simple tuning job for verification

Co-authored-by: Mohamad <mkatanbaf@users.noreply.github.com>
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.

7 participants