Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[FEATURE] Add query_keys transformer version without split #21115

Merged
merged 9 commits into from
Aug 23, 2022

Conversation

agrabows
Copy link
Contributor

@agrabows agrabows commented Aug 8, 2022

Description

MXNet is fusing split, reshape, swapaxis and batch_dot operators for performance purpose. In gpt-2 model this fuse could be done as well if we exclude split.
image
->
image

Checklist

Essentials

  • PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented

@mxnet-bot
Copy link

Hey @agrabows , Thanks for submitting the PR
All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands:

  • To trigger all jobs: @mxnet-bot run ci [all]
  • To trigger specific jobs: @mxnet-bot run ci [job1, job2]

CI supported jobs: [unix-cpu, unix-gpu, website, windows-cpu, centos-gpu, edge, sanity, centos-cpu, windows-gpu, miscellaneous, clang]


Note:
Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin.
All CI tests must pass before the PR can be merged.

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 8, 2022
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 9, 2022
src/operator/subgraph/dnnl/dnnl_transformer.cc Outdated Show resolved Hide resolved
src/operator/subgraph/dnnl/dnnl_transformer.cc Outdated Show resolved Hide resolved
src/operator/subgraph/dnnl/dnnl_transformer.cc Outdated Show resolved Hide resolved
src/operator/subgraph/dnnl/dnnl_transformer.cc Outdated Show resolved Hide resolved
src/operator/subgraph/dnnl/dnnl_transformer.cc Outdated Show resolved Hide resolved
src/operator/subgraph/dnnl/dnnl_transformer.cc Outdated Show resolved Hide resolved
src/operator/subgraph/dnnl/dnnl_transformer_qk_common.h Outdated Show resolved Hide resolved
@agrabows agrabows requested a review from szha as a code owner August 10, 2022 15:49
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 10, 2022
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 10, 2022
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test and removed pr-work-in-progress PR is still work in progress labels Aug 10, 2022
@agrabows
Copy link
Contributor Author

image

@mseth10 mseth10 added pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 10, 2022
@mseth10 mseth10 removed the pr-work-in-progress PR is still work in progress label Aug 11, 2022
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-awaiting-review PR is waiting for code review and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 11, 2022
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-awaiting-review PR is waiting for code review pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 16, 2022
Copy link
Contributor

@bartekkuncer bartekkuncer left a comment

Choose a reason for hiding this comment

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

LGTM.

src/operator/subgraph/dnnl/dnnl_transformer.cc Outdated Show resolved Hide resolved
src/operator/subgraph/dnnl/dnnl_transformer.cc Outdated Show resolved Hide resolved
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-awaiting-review PR is waiting for code review and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 17, 2022
input_names.emplace_back("min_q");
input_names.emplace_back("max_q");
}
input_names.emplace_back("keys");
Copy link
Contributor

Choose a reason for hiding this comment

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

"key" input name should be before "min_q" and "max_q"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 377 to 385
float* output_min_0 = outputs[2].data().dptr<float>();
float* output_max_0 = outputs[3].data().dptr<float>();
float* output_min_1 = outputs[4].data().dptr<float>();
float* output_max_1 = outputs[5].data().dptr<float>();
*output_min_0 = min_output_;
*output_max_0 = max_output_;
*output_min_1 = min_output_;
*output_max_1 = max_output_;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There are only 3 output tensors. Doesn't it throw exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it didn't but you are right, this code was incorrect

@@ -29,54 +29,78 @@
#include "operator/subgraph/common.h"
#include "dnnl_transformer-inl.h"

// 3 tensors within one (queries key values) =
// 3 tensors within one (queries key values)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// 3 tensors within one (queries key values)
// 3 tensors within one (queries keys values)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*status = kFirstSwapAx;
matched_list->push_back(&input_node);
}
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this return true be in 'if' statement below matched_list->push_back(&input_node); ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-awaiting-review PR is waiting for code review pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 22, 2022
@agrabows
Copy link
Contributor Author

@mxnet-bot run ci [unix-gpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [unix-gpu]

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-awaiting-review PR is waiting for code review and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 22, 2022
@bgawrych bgawrych merged commit 1a418e4 into apache:master Aug 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants