-
Notifications
You must be signed in to change notification settings - Fork 79
ATen scheduler for the new Matmul/LinearOp IR nodes
#2209
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
Changes from all commits
a695299
961ea76
fe23404
075a83f
a7a15a8
15b9062
44d13c4
0cf2e6b
bb52526
6c130d7
6bb6031
b75d72f
54314bf
22031f2
76fd527
dc45b68
5cb9fe5
2047629
bc86019
6d14c32
9910676
b9613f0
6a059ab
5b9a4a3
1ad32ea
a1b22e2
bcd5791
7183408
ffd48df
8f80548
a11c4a9
d051311
41e2bbb
6e3aa0a
5786f13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // clang-format off | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2023-present NVIDIA CORPORATION & AFFILIATES. | ||
| * All rights reserved. | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| // clang-format on | ||
|
|
||
| #include <ir/utils.h> | ||
| #include <scheduler/debug_utils.h> | ||
| #include <scheduler/expr_eval_sched.h> | ||
| #include <scheduler/registry_utils.h> | ||
|
|
||
| namespace nvfuser { | ||
|
|
||
| // Check if the fusion has a single MatmulOp node | ||
| bool ExprEvalScheduler::canScheduleCompileTime(Fusion* fusion) { | ||
| auto exprs = fusion->exprs(); | ||
| if (exprs.size() == 1 && exprs.front()->isA<MatmulOp>()) { | ||
| return true; | ||
| } | ||
| scheduler_debug_utils::canScheduleRejectReason( | ||
| heuristicType(), | ||
| "Fusion must contain a single expression of type MatmulOp"); | ||
| return false; | ||
| } | ||
|
|
||
| void ExprEvalScheduler::schedule(Fusion* fusion) { | ||
| fusion->aliasOutputToInput( | ||
| fusion->outputs()[0], /*input=*/nullptr, AllocationType::Evaluate); | ||
| } | ||
|
|
||
| } // namespace nvfuser |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // clang-format off | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2023-present NVIDIA CORPORATION & AFFILIATES. | ||
| * All rights reserved. | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| // clang-format on | ||
| #pragma once | ||
|
|
||
| #include <scheduler/heuristic.h> | ||
| #include <scheduler/registry.h> | ||
|
|
||
| namespace nvfuser { | ||
|
|
||
| class Fusion; | ||
| class SchedulerRuntimeInfo; | ||
| class HeuristicSummary; | ||
|
|
||
| // ExprEval scheduler represents the case where we allocate outputs directly | ||
| // using EE. No code is generated. | ||
| class ExprEvalScheduler : public SchedulerEntry { | ||
| public: | ||
| explicit ExprEvalScheduler( | ||
| Fusion* fusion, | ||
| SchedulerRuntimeInfo& runtime_info, | ||
| HeuristicSummary* data_cache = nullptr) | ||
| : SchedulerEntry(heuristicType()) { | ||
| params_ = | ||
| std::make_shared<HeuristicParams>("", runtime_info.getIndexType()); | ||
| } | ||
|
|
||
| // This scheduler only accepts MatmulOp. | ||
| static bool canScheduleCompileTime(Fusion* fusion); | ||
|
|
||
| static bool canScheduleRunTime( | ||
| Fusion* fusion, | ||
| SchedulerRuntimeInfo& runtime_info, | ||
| HeuristicSummary* data_cache) { | ||
| return true; | ||
| } | ||
|
|
||
| constexpr static ScheduleHeuristic heuristicType() { | ||
| return ScheduleHeuristic::ExprEval; | ||
| } | ||
|
|
||
| void schedule(Fusion* fusion) override; | ||
| }; | ||
|
|
||
| } // namespace nvfuser |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -55,11 +55,13 @@ enum class ScheduleHeuristic { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| InnerPersistent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| InnerOuterPersistent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OuterPersistent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Transpose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Transpose, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ExprEval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //! Define a schedule table to loop over all the heuristics in priority order. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| constexpr std::array<ScheduleHeuristic, 8> all_heuristics_in_priority_order = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| constexpr std::array<ScheduleHeuristic, 9> all_heuristics_in_priority_order = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ScheduleHeuristic::ExprEval, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some cases get accepted by NoOp scheduler, which is why I prioritized ExprEval scheduler. We may need to change the heuristics of
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh! Thanks for mentioning that. Does Lines 341 to 359 in 8c18701
size_zero would be false in the case that root_dom.empty(). However, the code below might not properly handle zero-dimensional outputs: Fuser/csrc/scheduler/no_op.cpp Lines 71 to 80 in 8c18701
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is likely because there no reductions identified since we use ATen, and all the dimensions in the output are broadcast dimensions. So the cases where M/N = 1 get picked by |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ScheduleHeuristic::NoOp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ScheduleHeuristic::Matmul, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ScheduleHeuristic::Reduction, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.