Skip to content

Conversation

@Xia-Weiwen
Copy link
Collaborator

@Xia-Weiwen Xia-Weiwen commented Nov 8, 2022

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 8, 2022

🔗 Helpful Links

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

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

✅ No Failures

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

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

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel

[ghstack-poisoned]
Xia-Weiwen added a commit that referenced this pull request Nov 8, 2022
ghstack-source-id: 55fef92
Pull Request resolved: #88665
cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel

[ghstack-poisoned]
@Xia-Weiwen Xia-Weiwen marked this pull request as ready for review November 11, 2022 05:30
cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel

[ghstack-poisoned]
.set_object_type(torch.nn.LayerNorm, qconfig_layernorm) \

if backend == 'onednn':
qconfig_mapping.set_object_type(torch.nn.LeakyReLU, qconfig) \
Copy link
Contributor

Choose a reason for hiding this comment

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

do we support quantization for standalone leakyrelu module/op?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's required that the fused module shares the same qconfig with separate modules/ops otherwise there will be an error in UT. So, I added these here.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, sounds good, we should be able to configure qconfig for patterns I think, but this will come up a bit later, cc @andrewor14 as FYI

Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a TODO comment here? so that we will remember to remove this later when we support fusion patterns in QConfigMapping

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I have added a TODO comment in this PR: #89188

Comment on lines 178 to 185
.set_backend_pattern_configs(_get_binary_op_configs(binary_op_dtype_configs)) \
.set_backend_pattern_config(_get_cat_config(default_op_dtype_configs)) \
.set_backend_pattern_configs(_get_default_op_configs(default_op_dtype_configs)) \
.set_backend_pattern_configs(_get_fixed_qparams_op_configs(fixed_qparams_op_dtype_configs)) \
.set_backend_pattern_configs(_get_share_qparams_op_configs(share_qparams_op_dtype_configs)) \
.set_backend_pattern_configs(_get_bn_configs(default_op_dtype_configs)) \
.set_backend_pattern_configs(_get_rnn_op_configs(rnn_op_dtype_configs)) \
.set_backend_pattern_configs(_get_embedding_op_configs(embedding_op_dtype_configs))
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure onednn actually supports all the ops here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, I thought we needed all these configs set so I just copied them here. I will try to remove them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They are removed

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel

[ghstack-poisoned]
@Xia-Weiwen Xia-Weiwen requested a review from z-a-f as a code owner November 17, 2022 05:45
@Xia-Weiwen Xia-Weiwen changed the title [Quant][FX] Add backend config for onednn backend [Quant][FX] Add backend config for onednn backend and fuse Linear-LeakyReLU Nov 17, 2022
… Linear-LeakyReLU"

**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx




cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel

[ghstack-poisoned]
… Linear-LeakyReLU"

**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx




cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel

[ghstack-poisoned]
… Linear-LeakyReLU"

**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx




cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel

[ghstack-poisoned]
@Xia-Weiwen Xia-Weiwen added the intel This tag is for PR from Intel label Nov 21, 2022
… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
@Xia-Weiwen Xia-Weiwen added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 25, 2022
… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
@github-actions github-actions bot added the release notes: quantization release notes category label Dec 5, 2022
@Xia-Weiwen
Copy link
Collaborator Author

Hi @jerryzh168. Do you have more comments? Thanks!

@Xia-Weiwen
Copy link
Collaborator Author

Xia-Weiwen commented Dec 9, 2022

Hi @jerryzh168. Is it ok to land this? Thanks

Comment on lines 146 to 148
return BackendConfig("onednn") \
.set_backend_pattern_configs(conv_configs) \
.set_backend_pattern_configs(linear_configs)
Copy link
Contributor

Choose a reason for hiding this comment

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

onednn backend only supports these?

Copy link
Collaborator Author

@Xia-Weiwen Xia-Weiwen Dec 12, 2022

Choose a reason for hiding this comment

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

@jerryzh168 For other ops, do I need to copy default configs here or just ignore them? What is expected? Here is your previous comment: #88665 (comment)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looks like they are needed. I have added them back. Please take a look again. Thanks.

Copy link
Contributor

@jerryzh168 jerryzh168 Dec 16, 2022

Choose a reason for hiding this comment

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

OK looks good, so for the other ops do we just fallback to the default (fbgemm) implementation? e.g. quantized::layer_norm

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we use default native implementations for ops other than conv/linear. However, we still need to set pattern configs for other ops here. Otherwise, those ops are not quantized if we use onednn's backend config for prepare_fx and convert_fx.

… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
# 1.1 linear module + leaky_relu fusion config
# linear leaky_relu, linear module + leaky_relu module
linear_configs.append(
BackendPatternConfig((nn.LeakyReLU, nn.Linear))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we updated the pattern format recently, please take a look at #90698

Copy link
Collaborator Author

@Xia-Weiwen Xia-Weiwen Dec 15, 2022

Choose a reason for hiding this comment

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

Thanks. It's fixed.

… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
… Linear-LeakyReLU"


**Summary**
Add backend config for onednn backend so that it can support more post op fusion for int8 inference. First `Linear - LeakyReLU` fusion is implemented based on previous PRs.

**Test plan**
python test_quantization.py TestFuseFx

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
@Xia-Weiwen
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

hasanyeganeh pushed a commit to hasanyeganeh/pytorch-pytorch that referenced this pull request Dec 21, 2022
@facebook-github-bot facebook-github-bot deleted the gh/Xia-Weiwen/3/head branch June 8, 2023 14:57
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 This tag is for PR from Intel Merged oncall: quantization Quantization support in PyTorch open source release notes: AO frontend release notes: quantization release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants