Skip to content
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

dequantize matmul and matmul_v2 Y weights in quant2_int8 #37618

Merged
merged 8 commits into from
Dec 1, 2021

Conversation

sfraczek
Copy link
Contributor

@sfraczek sfraczek commented Nov 26, 2021

PR types

Bug fixes

PR changes

Others

Describe

fix for a problem in issue: #36962.
There, matmul_v2 has weights quantized but they are not dequantized during conversion of qat model to fp32 model. later matmul_v2 fp32 is used with those quantized weights.
I separated also conv2d and matmul unit tests for quant2_int8_mkldnn_pass

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

wozna
wozna previously approved these changes Nov 29, 2021
@@ -336,6 +338,9 @@ def _is_int8_weights(op_node, weight_name):
self._dequantize_op_weights(graph, op, "Filter", "Output")
elif op.name() in self._mul_ops and _is_int8_weights(op, "Y"):
self._dequantize_op_weights(graph, op, "Y", "Out")
elif op.name() in self._matmul_ops and _is_int8_weights(op, "Y"):
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you can combine this part into one and just check op.name() in [self._mul_ops, self._matmul_ops]. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can apply your idea, but I will concatenate those lists before for loop

Copy link
Contributor Author

@sfraczek sfraczek Nov 29, 2021

Choose a reason for hiding this comment

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

I wonder if we even need matmul_ops variable separate from mul_ops

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, it looks like we are doing exactly the same things for them, so for me you can combine it.

@lidanqing-intel
Copy link
Contributor

@baoachun We have big concern about matmul_v2 and related passes. Let's discuss it when you got time

  1. Should we enable all fuses of mul, matmul_v1, fc for matmul_v2
  2. Could we just keep matmul_v2 as the only interface and mapping it into different ops: mul, matmul_v1, fc according to different situations

@baoachun
Copy link
Contributor

@baoachun We have big concern about matmul_v2 and related passes. Let's discuss it when you got time

1. Should we enable all fuses of mul, matmul_v1, fc for matmul_v2

2. Could we just keep matmul_v2 as the only interface and mapping it into different ops: mul, matmul_v1, fc according to different situations

I'm sorry I don't understand what you mean very much. What is the problem now?

@sfraczek sfraczek changed the title dequantize matmul and matmul_v2 Y weights in qat2_int8 dequantize matmul and matmul_v2 Y weights in quant2_int8 Nov 30, 2021
@sfraczek sfraczek requested a review from jczaja December 1, 2021 10:22
Copy link
Contributor

@lidanqing-intel lidanqing-intel left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@lidanqing-intel lidanqing-intel left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@wozna wozna left a comment

Choose a reason for hiding this comment

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

LGTM

@jczaja jczaja merged commit 7094251 into PaddlePaddle:develop Dec 1, 2021
Zjq9409 pushed a commit to Zjq9409/Paddle that referenced this pull request Dec 10, 2021
…e#37618)

* dequantize matmul and matmul_v2 Y weights in qat2_int8

* review fix

* split conv and mul tests, add matmul test

* fixup

* fix ci build

* remove unused variables

* formatting fix

* remove extra newline at end of file
@sfraczek sfraczek added the int8 label Dec 21, 2021
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.

5 participants