Skip to content

Conversation

@XiaobingSuper
Copy link
Collaborator

@XiaobingSuper XiaobingSuper commented Oct 13, 2022

Stack from ghstack (oldest at bottom):

Differential Revision: D40351062

For mkldnn quantization path, we will do weight prepack using dummy data to query the expected weight format, the packed weight's format may differ from the real input case(the weight format depends on the input's shape), and there will have a block weight to block weight reorder if the packed weight format differs with the expected weight format. The mkldnn may meet the following issue when doing such reorder(test on ICX machine):

test_conv_reorder_issue_onednn
    torch.ops.quantized.conv2d(qx, w_packed, output_scale=1.0, output_zero_point=0)
  File "/home/weiwen/.conda/envs/int8-dev/lib/python3.9/site-packages/torch/_ops.py", line 472, in __call__
    return self._op(*args, **kwargs or {})
RuntimeError: could not create a primitive descriptor for a reorder primitive

This PR will fix it: if the block weight to block weight reorder is failed, we will reorder the block weight to plain weight first, and then reorder the plain weight to the target block weight.

cc @jerryzh168 @jianyuh @raghuramank100 @jamesr66a @vkuzo @jgong5 @Xia-Weiwen @leslie-fang-intel @VitalyFedyunin @mingfeima @sanchitintel @ashokei @jingxu10

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 13, 2022

🔗 Helpful Links

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

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

✅ No Failures

As of commit 5929579:
💚 Looks good so far! There are no failures yet. 💚

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

@pytorch-bot pytorch-bot bot added the release notes: quantization release notes category label Oct 13, 2022
XiaobingSuper added a commit that referenced this pull request Oct 13, 2022
ghstack-source-id: cd377dd
Pull Request resolved: #86876
@XiaobingSuper XiaobingSuper marked this pull request as draft October 13, 2022 03:21
@jerryzh168
Copy link
Contributor

@jerryzh168 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@jerryzh168
Copy link
Contributor

@XiaobingSuper I have confirmed with my colleague that we can land this first, could you publish this draft PR?

@jerryzh168
Copy link
Contributor

could you 1. clean up the fix 2. split the changes to default to a separate PR?

@XiaobingSuper XiaobingSuper marked this pull request as ready for review November 10, 2022 05:45
@github-actions github-actions bot added module: cpu CPU specific problem (e.g., perf, algorithm) oncall: quantization Quantization support in PyTorch labels Nov 10, 2022
@XiaobingSuper
Copy link
Collaborator Author

could you 1. clean up the fix 2. split the changes to default to a separate PR?

Done, please help review it.

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.

The change LGTM but could you please add the description the suspected issue and how the change addresses it?

@XiaobingSuper
Copy link
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 11, 2022
@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: This PR has internal changes and must be landed via Phabricator

Details for Dev Infra team Raised by workflow job

@jerryzh168
Copy link
Contributor

@jerryzh168 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@XiaobingSuper
Copy link
Collaborator Author

@jerryzh168 , could you help see the internal failed test case? I can't access it.

@XiaobingSuper XiaobingSuper added the intel priority matters to intel architecture from performance wise label Nov 15, 2022
Differential Revision: [D40351062](https://our.internmc.facebook.com/intern/diff/D40351062)


There has a potential issue when reordering block to block, now, if it failed, we will fist reorder to plain, and then reorder to the target block.

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 Xia-Weiwen leslie-fang-intel VitalyFedyunin mingfeima sanchitintel ashokei jingxu10

[ghstack-poisoned]
@XiaobingSuper
Copy link
Collaborator Author

reproduce

A test case is added. @@jerryzh168

@vkuzo
Copy link
Contributor

vkuzo commented Nov 21, 2022

Could we add some more context on what the issue was, which hardware the issue affects, and how this PR is fixing it? Also, to clarify, the test fails before this PR and passes after?

Differential Revision: [D40351062](https://our.internmc.facebook.com/intern/diff/D40351062)

For mkldnn quantization path, we will do weight prepack using dummy data to query the expected weight format, the packed weight's format may differ from the real input case(the weight format depends on the input's shape), and there will have a block weight to block weight reorder if the packed weight format differs with the expected weight format.  The mkldnn may meet the following issue when doing such reorder(test on ICX machine):

```
test_conv_reorder_issue_onednn
    torch.ops.quantized.conv2d(qx, w_packed, output_scale=1.0, output_zero_point=0)
  File "/home/weiwen/.conda/envs/int8-dev/lib/python3.9/site-packages/torch/_ops.py", line 472, in __call__
    return self._op(*args, **kwargs or {})
RuntimeError: could not create a primitive descriptor for a reorder primitive
```

This PR will fix it: if the block weight to block weight reorder is failed, we will reorder the block weight to plain weight first, and then reorder the plain weight to the target block weight.


cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 Xia-Weiwen leslie-fang-intel VitalyFedyunin mingfeima sanchitintel ashokei jingxu10

[ghstack-poisoned]
@XiaobingSuper
Copy link
Collaborator Author

Could we add some more context on what the issue was, which hardware the issue affects, and how this PR is fixing it? Also, to clarify, the test fails before this PR and passes after?

@vkuzo , I add more context to descript the issue, please help see it.

@XiaobingSuper
Copy link
Collaborator Author

@jerryzh168, could we land it?

@jerryzh168
Copy link
Contributor

sure, will try landing this again

@jerryzh168
Copy link
Contributor

@jerryzh168 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@jerryzh168
Copy link
Contributor

@XiaobingSuper could you rebase the PR on master?

Differential Revision: [D40351062](https://our.internmc.facebook.com/intern/diff/D40351062)

For mkldnn quantization path, we will do weight prepack using dummy data to query the expected weight format, the packed weight's format may differ from the real input case(the weight format depends on the input's shape), and there will have a block weight to block weight reorder if the packed weight format differs with the expected weight format.  The mkldnn may meet the following issue when doing such reorder(test on ICX machine):

```
test_conv_reorder_issue_onednn
    torch.ops.quantized.conv2d(qx, w_packed, output_scale=1.0, output_zero_point=0)
  File "/home/weiwen/.conda/envs/int8-dev/lib/python3.9/site-packages/torch/_ops.py", line 472, in __call__
    return self._op(*args, **kwargs or {})
RuntimeError: could not create a primitive descriptor for a reorder primitive
```

This PR will fix it: if the block weight to block weight reorder is failed, we will reorder the block weight to plain weight first, and then reorder the plain weight to the target block weight.


cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 Xia-Weiwen leslie-fang-intel VitalyFedyunin mingfeima sanchitintel ashokei jingxu10

[ghstack-poisoned]
@XiaobingSuper
Copy link
Collaborator Author

@XiaobingSuper could you rebase the PR on master?

rebased.

@jerryzh168
Copy link
Contributor

@jerryzh168 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@XiaobingSuper
Copy link
Collaborator Author

@jerryzh168 , please help land it if it is ok for you.

@jerryzh168
Copy link
Contributor

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a rebase job. Check the current status here

Differential Revision: [D40351062](https://our.internmc.facebook.com/intern/diff/D40351062)

For mkldnn quantization path, we will do weight prepack using dummy data to query the expected weight format, the packed weight's format may differ from the real input case(the weight format depends on the input's shape), and there will have a block weight to block weight reorder if the packed weight format differs with the expected weight format.  The mkldnn may meet the following issue when doing such reorder(test on ICX machine):

```
test_conv_reorder_issue_onednn
    torch.ops.quantized.conv2d(qx, w_packed, output_scale=1.0, output_zero_point=0)
  File "/home/weiwen/.conda/envs/int8-dev/lib/python3.9/site-packages/torch/_ops.py", line 472, in __call__
    return self._op(*args, **kwargs or {})
RuntimeError: could not create a primitive descriptor for a reorder primitive
```

This PR will fix it: if the block weight to block weight reorder is failed, we will reorder the block weight to plain weight first, and then reorder the plain weight to the target block weight.


cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 Xia-Weiwen leslie-fang-intel VitalyFedyunin mingfeima sanchitintel ashokei jingxu10

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Successfully rebased gh/XiaobingSuper/17/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/86876)

pytorchmergebot pushed a commit that referenced this pull request Nov 30, 2022
ghstack-source-id: 0105c99
Pull Request resolved: #86876
@jerryzh168
Copy link
Contributor

@jerryzh168 , please help land it if it is ok for you.

trying to land, just need to make sure CI is green

@jerryzh168
Copy link
Contributor

@jerryzh168 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@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

kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Dec 10, 2022
Differential Revision: [D40351062](https://our.internmc.facebook.com/intern/diff/D40351062)

For mkldnn quantization path, we will do weight prepack using dummy data to query the expected weight format, the packed weight's format may differ from the real input case(the weight format depends on the input's shape), and there will have a block weight to block weight reorder if the packed weight format differs with the expected weight format.  The mkldnn may meet the following issue when doing such reorder(test on ICX machine):

```
test_conv_reorder_issue_onednn
    torch.ops.quantized.conv2d(qx, w_packed, output_scale=1.0, output_zero_point=0)
  File "/home/weiwen/.conda/envs/int8-dev/lib/python3.9/site-packages/torch/_ops.py", line 472, in __call__
    return self._op(*args, **kwargs or {})
RuntimeError: could not create a primitive descriptor for a reorder primitive
```

This PR will fix it: if the block weight to block weight reorder is failed, we will reorder the block weight to plain weight first, and then reorder the plain weight to the target block weight.

Pull Request resolved: pytorch#86876
Approved by: https://github.com/jgong5, https://github.com/jerryzh168
@facebook-github-bot facebook-github-bot deleted the gh/XiaobingSuper/17/head branch June 8, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request intel priority matters to intel architecture from performance wise Merged module: cpu CPU specific problem (e.g., perf, algorithm) oncall: quantization Quantization support in PyTorch open source release notes: quantization release notes category

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

9 participants