Skip to content

Conversation

@zhuhaozhe
Copy link
Collaborator

@zhuhaozhe zhuhaozhe commented Oct 28, 2024

Enable concat linear for CPU mkldnn path.
Previously, we have a concat linear in freezing passes but it not worked on CPU.
This is because concat_linear pattern happened after mkldnn_weight_prepack. And concat_linear only handle addmm/mm etc.

addmm -> mkldnn linear
addmm -> mkldnn linear -> cannot concat

# only worked when disable mkldnn
addmm ->
addmm -> concat linear

Now we changed mkldnn linear related pass numbers larger than concat_linear pass numbers.

addmm -> concat linear -> mkldnn linear
addmm ->

So it can work fine with mkldnn linear now.

Also, since concat linear not always have benefits. We add 1 flag config.cpp.enable_concat_linear and set default value to False. User can enable this by their need.

Stack from ghstack (oldest at bottom):

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang @aakhundov

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 28, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/139048

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit db8300d with merge base 034b105 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

zhuhaozhe added a commit that referenced this pull request Oct 28, 2024
ghstack-source-id: e372006
Pull Request resolved: #139048
@zhuhaozhe zhuhaozhe marked this pull request as draft October 28, 2024 07:27
@zhuhaozhe zhuhaozhe added topic: not user facing topic category ciflow/trunk Trigger trunk jobs on your pull request labels Oct 28, 2024
[ghstack-poisoned]
zhuhaozhe added a commit that referenced this pull request Oct 28, 2024
ghstack-source-id: ae8a586
Pull Request resolved: #139048
[ghstack-poisoned]
@zhuhaozhe zhuhaozhe requested a review from jgong5 November 11, 2024 06:15
Copy link
Collaborator

@jgong5 jgong5 left a comment

Choose a reason for hiding this comment

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

Could you please update the PR description on changes?

KeywordArg("reshape_2"),
),
pass_number=1,
pass_number=2,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Explain the change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previously mkldnn_linear pass is 0 and _recover_linear is based on mkldnn_linear so it should be 1.
Now we set mkldnn_linear pass to 1 (since concat linear is 0), then the recover_linear pass number should be 2.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add the note in the code too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for advice, added this note in code.

[ghstack-poisoned]
zhuhaozhe added a commit that referenced this pull request Nov 12, 2024
ghstack-source-id: 2fa6b3c
Pull Request resolved: #139048
@zhuhaozhe zhuhaozhe requested a review from jgong5 November 12, 2024 02:39
@zhuhaozhe zhuhaozhe marked this pull request as ready for review November 13, 2024 00:56
@zhuhaozhe
Copy link
Collaborator Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: Approvers from one of the following sets are needed:

  • superuser (pytorch/metamates)
  • Core Reviewers (mruberry, lezcano, Skylion007, ngimel, peterbell10, ...)
  • Core Maintainers (soumith, gchanan, ezyang, dzhulgakov, malfet, ...)
Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

zhuhaozhe added a commit that referenced this pull request Nov 13, 2024
ghstack-source-id: 5983251
Pull Request resolved: #139048
@zhuhaozhe zhuhaozhe requested a review from jansel November 13, 2024 01:03
@zhuhaozhe
Copy link
Collaborator Author

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

Enable concat linear for CPU mkldnn path.
Previously, we have a concat linear in freezing passes but it not worked on CPU.
This is because `concat_linear` pattern happened after `mkldnn_weight_prepack`. And `concat_linear` only handle `addmm/mm` etc.

```
addmm -> mkldnn linear
addmm -> mkldnn linear -> cannot concat

# only worked when disable mkldnn
addmm ->
addmm -> concat linear
```
Now we changed `mkldnn linear` related pass numbers larger than `concat_linear` pass numbers.

```
addmm -> concat linear -> mkldnn linear
addmm ->

```
So it can work fine with mkldnn linear now.

Also, since concat linear not always have benefits. We add 1 flag `config.cpp.enable_concat_linear` and set default value to False. User can enable this by their need. 








cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Successfully rebased gh/zhuhaozhe/41/orig onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via ghstack checkout https://github.com/pytorch/pytorch/pull/139048)

pytorchmergebot pushed a commit that referenced this pull request Nov 13, 2024
ghstack-source-id: 6baddbe
Pull Request resolved: #139048
[ghstack-poisoned]
zhuhaozhe added a commit that referenced this pull request Nov 13, 2024
ghstack-source-id: d7d2575
Pull Request resolved: #139048
[ghstack-poisoned]
zhuhaozhe added a commit that referenced this pull request Nov 13, 2024
ghstack-source-id: 67a37ec
Pull Request resolved: #139048
zhuhaozhe added a commit that referenced this pull request Nov 13, 2024
ghstack-source-id: 67a37ec
Pull Request resolved: #139048
[ghstack-poisoned]
zhuhaozhe added a commit that referenced this pull request Nov 13, 2024
ghstack-source-id: db13b11
Pull Request resolved: #139048
[ghstack-poisoned]
zhuhaozhe added a commit that referenced this pull request Nov 13, 2024
ghstack-source-id: fa261e2
Pull Request resolved: #139048
[ghstack-poisoned]
zhuhaozhe added a commit that referenced this pull request Nov 13, 2024
ghstack-source-id: c3472bb
Pull Request resolved: #139048
[ghstack-poisoned]
zhuhaozhe added a commit that referenced this pull request Nov 13, 2024
ghstack-source-id: 801b03a
Pull Request resolved: #139048
@zhuhaozhe
Copy link
Collaborator Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

zero000064 pushed a commit to zero000064/pytorch that referenced this pull request Nov 14, 2024
Enable concat linear for CPU mkldnn path.
Previously, we have a concat linear in freezing passes but it not worked on CPU.
This is because `concat_linear` pattern happened after `mkldnn_weight_prepack`. And `concat_linear` only handle `addmm/mm` etc.

```
addmm -> mkldnn linear
addmm -> mkldnn linear -> cannot concat

# only worked when disable mkldnn
addmm ->
addmm -> concat linear
```
Now we changed `mkldnn linear` related pass numbers larger than `concat_linear` pass numbers.

```
addmm -> concat linear -> mkldnn linear
addmm ->

```
So it can work fine with mkldnn linear now.

Also, since concat linear not always have benefits. We add 1 flag `config.cpp.enable_concat_linear` and set default value to False. User can enable this by their need.

Pull Request resolved: pytorch#139048
Approved by: https://github.com/jgong5, https://github.com/jansel
pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
Enable concat linear for CPU mkldnn path.
Previously, we have a concat linear in freezing passes but it not worked on CPU.
This is because `concat_linear` pattern happened after `mkldnn_weight_prepack`. And `concat_linear` only handle `addmm/mm` etc.

```
addmm -> mkldnn linear
addmm -> mkldnn linear -> cannot concat

# only worked when disable mkldnn
addmm ->
addmm -> concat linear
```
Now we changed `mkldnn linear` related pass numbers larger than `concat_linear` pass numbers.

```
addmm -> concat linear -> mkldnn linear
addmm ->

```
So it can work fine with mkldnn linear now.

Also, since concat linear not always have benefits. We add 1 flag `config.cpp.enable_concat_linear` and set default value to False. User can enable this by their need.

Pull Request resolved: pytorch#139048
Approved by: https://github.com/jgong5, https://github.com/jansel
fmo-mt pushed a commit to fmo-mt/pytorch that referenced this pull request Dec 11, 2024
Enable concat linear for CPU mkldnn path.
Previously, we have a concat linear in freezing passes but it not worked on CPU.
This is because `concat_linear` pattern happened after `mkldnn_weight_prepack`. And `concat_linear` only handle `addmm/mm` etc.

```
addmm -> mkldnn linear
addmm -> mkldnn linear -> cannot concat

# only worked when disable mkldnn
addmm ->
addmm -> concat linear
```
Now we changed `mkldnn linear` related pass numbers larger than `concat_linear` pass numbers.

```
addmm -> concat linear -> mkldnn linear
addmm ->

```
So it can work fine with mkldnn linear now.

Also, since concat linear not always have benefits. We add 1 flag `config.cpp.enable_concat_linear` and set default value to False. User can enable this by their need.

Pull Request resolved: pytorch#139048
Approved by: https://github.com/jgong5, https://github.com/jansel
@github-actions github-actions bot deleted the gh/zhuhaozhe/41/head branch December 14, 2024 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants