[Metaschedule] ApplyCustomRule only if present#13827
[Metaschedule] ApplyCustomRule only if present#13827quic-sanirudh wants to merge 1 commit intoapache:mainfrom
Conversation
|
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 |
When a PrimFunc contains the `schedule_rule` attribute, all schedule rules are ignored except `ApplyCustomRule()`, regardless of whether `ApplyCustomRule()` itself is available or not. This patch changes the code so that `schedule_rule` attribute is only considered when `ApplyCustomRule()` is one of the schedule_rules passed to post_order_apply and ignored otherwise in favor of the existing custom rules. This was needed as some topi.nn computes contain the `schedule_rule` attribute, which causes them to be ignored by meta_schedule irrespective of whether a custom rule function is registered or not.
df03154 to
5bfd64d
Compare
|
@junrushao @zxybazh Could you please take a look at this PR. I was writing a new schedule rule and realized that it wasn't being applied on some blocks just because they had the I wasn't sure of whether to check for the presence of just |
|
Thanks for contributing! IIUC, you would like to apply non custom schedule rules to a block that has On the other hand, if we set |
Yes I'm trying to apply a non custom schedule rule to blocks that contain the When tuning a relay Also, there might be users new to metaschedule but familiar with generic TVM relay workflow and they might see that their ops are not tuned at all if their op strategy by default picks up this compute and they might not have any custom schedule functions registered. I ran into this as well, but luckily I was familiar with the meta schedule code enough to find the problem quickly. As for setting I did not realize about Alternative to this PR, we could remove those P.S. One last thing. I'm quite new to this entire code base, so please feel free to correct me anywhere and thanks for reviewing the change. |
|
Hey thanks for sharing more details. And yes I agree a test for schedule rule as None would be helpful. From a design perspective, we would like to make sure custom schedule rules are applied without interference from other schedule rules. From user perspective, first this provides a default for most of the hardwares like x86 or cuda, and these schedule rules can be customized or replaced if you register a new schedule function into the tvm global registry in the same schedule rule name. Removing those topi default schedule rules wouldnot only make it harder for new users to get started but also impact many current tuning workflows. IMHO, the use case to apply non-custom schedule rules to some topi nn function is actually more of a high-level usage because for the topi nn workloads that you pointed out, usual schedule rules would not be able to extract the best performance comparing to using the schedule rules we specified. On the other hand, these custom schedule rules are target specific, if you do have a good schedule rule set for certain workload, please feel free to send in new custom schedule rule for your hardware, it would benefit even more users :) |
|
@zxybazh Thanks for the explanation. I understand that this change breaks the assumption of
Thanks again for the discussion, and I'll close this PR for now :) |
When a PrimFunc contains the
schedule_ruleattribute, all schedule rules are ignored exceptApplyCustomRule(), regardless of whetherApplyCustomRule()itself is available or not.This patch changes the code so that
schedule_ruleattribute is only considered whenApplyCustomRule()is one of the schedule_rules passed to post_order_apply and ignored otherwise in favor of the existing custom rules.This was needed as some topi.nn computes contain the
schedule_ruleattribute, which causes them to be ignored by meta_schedule irrespective of whether a custom rule function is registered or not.