-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add Split QuickGelu Fusion #20344
base: main
Are you sure you want to change the base?
Add Split QuickGelu Fusion #20344
Conversation
// Trying to find Split->QuickGelu->Mul Path | ||
std::vector<const Node::EdgeEnd*> edges; | ||
std::vector<graph_utils::EdgeEndToMatch> quickgelu_mul_path{ | ||
{0, 0, "QuickGelu", {1, 11, 13}, kOnnxDomain}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the activation can be other elementwise operator instead of QuickGelu, maybe we can add a todo here to support other operators.
"fused " + split_node.Name() + " and " + quickgelu_node.Name() + " and " + mul.Name() + " into SplitQuickGelu"; | ||
|
||
std::string op_type = "SplitQuickGelu"; | ||
Node& fused_node = graph.AddNode(graph.GenerateNodeName(op_type), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add transformer name into node's name to make future debugging easier to figure out which graph transformer generate the node.
…/add_split_quickgelu_fusion
# inp = torch.randn((76, 54, 1368), device='cuda:0') | ||
# out = temp(inp) | ||
|
||
from onnxruntime.training.ortmodule import ORTModule |
Check warning
Code scanning / lintrunner
RUFF/E402 Warning test
See https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file
# out = temp(inp) | ||
|
||
from onnxruntime.training.ortmodule import ORTModule | ||
import time |
Check warning
Code scanning / lintrunner
RUFF/E402 Warning test
See https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file
|
||
def compare_torch_ort_perf(inp, num_steps=1000): | ||
model2 = ORTModule(temp) | ||
ort_temp_out = model2(inp) |
Check warning
Code scanning / lintrunner
RUFF/F841 Warning test
See https://docs.astral.sh/ruff/rules/unused-variable
print("Current input shape:", inp.shape) | ||
torch.cuda.synchronize() | ||
start = time.time() | ||
for i in range(num_steps): |
Check warning
Code scanning / lintrunner
RUFF/B007 Warning test
See https://docs.astral.sh/ruff/rules/unused-loop-control-variable
print("Total time torch:", time.time() - start) | ||
torch.cuda.synchronize() | ||
start = time.time() | ||
for i in range(num_steps): |
Check warning
Code scanning / lintrunner
RUFF/B007 Warning test
See https://docs.astral.sh/ruff/rules/unused-loop-control-variable
Description
Add Split QuickGelu Fusion
Motivation and Context