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

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

Merged
merged 7 commits into from
Jan 11, 2023

Conversation

mkatanbaf
Copy link
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
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
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
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.

Copy link
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.

@mkatanbaf
Copy link
Contributor Author

@tvm-bot rerun

@mehrdadh
Copy link
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
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

python/tvm/rpc/server.py Outdated Show resolved Hide resolved
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
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
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.

src/target/target_kind.cc Outdated Show resolved Hide resolved
src/target/source/codegen_c_host.cc Show resolved Hide resolved
@mkatanbaf mkatanbaf force-pushed the micro-with-meta-schedule branch from bf80e6d to afda2c1 Compare January 3, 2023 23:49
@mkatanbaf
Copy link
Contributor Author

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

@mehrdadh mehrdadh requested review from zxybazh and guberti January 9, 2023 19:56
@mehrdadh
Copy link
Member

mehrdadh commented Jan 9, 2023

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

@guberti
Copy link
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
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.

@@ -251,6 +251,29 @@ Array<ScheduleRule> ScheduleRule::DefaultHexagon() {
};
}

Array<ScheduleRule> ScheduleRule::DefaultMicro() {
return {
ScheduleRule::AutoInline(
Copy link
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
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
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
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
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
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