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

[PDPD FE] : Refactored PaddlePaddle Quantization #26347

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

Pey-crypto
Copy link
Contributor

@Pey-crypto Pey-crypto commented Sep 1, 2024

Fix for #20687

  1. Supports both per-tensor and per-channel quantization using the axis attribute.
  2. Uses FakeQuantize for quantize_linear and a simple subtract-multiply operation for dequantize_linear.
  3. The HALF_AWAY_FROM_ZERO round mode is ignored, as it's not explicitly handled.

@Pey-crypto Pey-crypto requested a review from a team as a code owner September 1, 2024 06:28
@github-actions github-actions bot added the category: PDPD FE OpenVINO PaddlePaddle FrontEnd label Sep 1, 2024
@sys-openvino-ci sys-openvino-ci added the ExternalPR External contributor label Sep 1, 2024
@Pey-crypto Pey-crypto changed the title [TF FE] : Refactored PaddlePaddle Quantization [PDPD FE] : Refactored PaddlePaddle Quantization Sep 1, 2024
@xczhai
Copy link
Contributor

xczhai commented Sep 3, 2024

Hi @Pey-crypto
Thanks for your commits. But we can polish this PR for better maintain.

  1. please check https://github.com/openvinotoolkit/openvino/blob/master/src/frontends/paddle/src/internal/pass/transform_fakequantize.cpp is needed or not. Theoretically, such pass should be remove since your commit works.
  2. Previously, I prepare some unittests for Quantization. Maybe you can import these tests to such PR. It can ensure the motification accuracy. https://github.com/xczhai/openvino/tree/refactor_paddle_slim

BR.

@Pey-crypto
Copy link
Contributor Author

@xczhai ,
Currently working on the errors.

@xczhai
Copy link
Contributor

xczhai commented Sep 3, 2024

@xczhai , Currently working on the errors.

If you have any questions, feel free reach me. I will reply asap.

@Pey-crypto
Copy link
Contributor Author

Pey-crypto commented Sep 5, 2024

@xczhai , Currently working on the errors.

If you have any questions, feel free reach me. I will reply asap.

https://github.com/xczhai/openvino/blob/a839d4c87e6275851f8e08d518d1e0049d382adb/src/frontends/paddle/tests/test_models/gen_scripts/generate_quantize_linear.py
Is this the correct file?. I thought it would be a
c++ test file rather than python.

@xczhai
Copy link
Contributor

xczhai commented Sep 6, 2024

@xczhai , Currently working on the errors.

If you have any questions, feel free reach me. I will reply asap.

https://github.com/xczhai/openvino/blob/a839d4c87e6275851f8e08d518d1e0049d382adb/src/frontends/paddle/tests/test_models/gen_scripts/generate_quantize_linear.py Is this the correct file?. I thought it would be a c++ test file rather than python.

For

@xczhai , Currently working on the errors.

If you have any questions, feel free reach me. I will reply asap.

https://github.com/xczhai/openvino/blob/a839d4c87e6275851f8e08d518d1e0049d382adb/src/frontends/paddle/tests/test_models/gen_scripts/generate_quantize_linear.py Is this the correct file?. I thought it would be a c++ test file rather than python.

@xczhai , Currently working on the errors.

If you have any questions, feel free reach me. I will reply asap.

https://github.com/xczhai/openvino/blob/a839d4c87e6275851f8e08d518d1e0049d382adb/src/frontends/paddle/tests/test_models/gen_scripts/generate_quantize_linear.py Is this the correct file?. I thought it would be a c++ test file rather than python.

Hi,

@Pey-crypto
Copy link
Contributor Author

Pey-crypto commented Sep 10, 2024

@xczhai I am not able to build or test the commit I have made , because mlas and oneDNN are missing their MAKE files during the build. Using the -DENABLE flags doesn't seem to help. I have made two unit tests, for the functions and have not changed the underlying python api.

@xczhai
Copy link
Contributor

xczhai commented Sep 10, 2024

@xczhai I am not able to build or test the commit I have made , because mlas and oneDNN are missing their MAKE files during the build. Using the -DENABLE flags doesn't seem to help. I have made two unit tests, for the functions and have not changed the underlying python api.

Did you execute git submodule update --init --recursive before building codes?

@Pey-crypto
Copy link
Contributor Author

Pey-crypto commented Sep 10, 2024

@xczhai I am not able to build or test the commit I have made , because mlas and oneDNN are missing their MAKE files during the build. Using the -DENABLE flags doesn't seem to help. I have made two unit tests, for the functions and have not changed the underlying python api.

Did you execute git submodule update --init --recursive before building codes?

yup multiple times, i even cleared the submodules again and tried it again. I even used the --progress and --verbose flags to see the git clone process underneath, but all the clones were happening successfully

@xczhai
Copy link
Contributor

xczhai commented Sep 10, 2024

@xczhai I am not able to build or test the commit I have made , because mlas and oneDNN are missing their MAKE files during the build. Using the -DENABLE flags doesn't seem to help. I have made two unit tests, for the functions and have not changed the underlying python api.

Did you execute git submodule update --init --recursive before building codes?

yup multiple times, i even cleared the submodules again and tried it again. I even used the --progress and --verbose flags to see the git clone process underneath, but all the clones were happening successfully

please share the commands you have tried.

@Pey-crypto
Copy link
Contributor Author

Pey-crypto commented Sep 10, 2024

@xczhai I am not able to build or test the commit I have made , because mlas and oneDNN are missing their MAKE files during the build. Using the -DENABLE flags doesn't seem to help. I have made two unit tests, for the functions and have not changed the underlying python api.

Did you execute git submodule update --init --recursive before building codes?

yup multiple times, i even cleared the submodules again and tried it again. I even used the --progress and --verbose flags to see the git clone process underneath, but all the clones were happening successfully

please share the commands you have tried.

git submodule update --init --recursive --progress
cmake --build . --parallel $(nproc)
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_MLAS=OFF -DENABLE_ONEDNN=OFF ..

@xczhai
Copy link
Contributor

xczhai commented Sep 10, 2024

@xczhai I am not able to build or test the commit I have made , because mlas and oneDNN are missing their MAKE files during the build. Using the -DENABLE flags doesn't seem to help. I have made two unit tests, for the functions and have not changed the underlying python api.

Did you execute git submodule update --init --recursive before building codes?

yup multiple times, i even cleared the submodules again and tried it again. I even used the --progress and --verbose flags to see the git clone process underneath, but all the clones were happening successfully

please share the commands you have tried.

git submodule update --init --recursive --progress cmake --build . --parallel $(nproc) cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_MLAS=OFF -DENABLE_ONEDNN=OFF ..

You should turn on mlas and onednn though it takes more time to build.

@Pey-crypto
Copy link
Contributor Author

Pey-crypto commented Sep 10, 2024

@xczhai I am not able to build or test the commit I have made , because mlas and oneDNN are missing their MAKE files during the build. Using the -DENABLE flags doesn't seem to help. I have made two unit tests, for the functions and have not changed the underlying python api.

Did you execute git submodule update --init --recursive before building codes?

yup multiple times, i even cleared the submodules again and tried it again. I even used the --progress and --verbose flags to see the git clone process underneath, but all the clones were happening successfully

please share the commands you have tried.

git submodule update --init --recursive --progress cmake --build . --parallel $(nproc) cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_MLAS=OFF -DENABLE_ONEDNN=OFF ..

You should turn on mlas and onednn though it takes more time to build.

i did do that also, but then cmake reports mlas and onednn makefiles aren't available. I will try again and get back with the results.

@xczhai
Copy link
Contributor

xczhai commented Sep 10, 2024

@xczhai I am not able to build or test the commit I have made , because mlas and oneDNN are missing their MAKE files during the build. Using the -DENABLE flags doesn't seem to help. I have made two unit tests, for the functions and have not changed the underlying python api.

Did you execute git submodule update --init --recursive before building codes?

yup multiple times, i even cleared the submodules again and tried it again. I even used the --progress and --verbose flags to see the git clone process underneath, but all the clones were happening successfully

please share the commands you have tried.

git submodule update --init --recursive --progress cmake --build . --parallel $(nproc) cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_MLAS=OFF -DENABLE_ONEDNN=OFF ..

You should turn on mlas and onednn though it takes more time to build.

i did do that also, but then cmake reports mlas and onednn makefiles aren't available. I will try again and get back with the results.

Could you share the CPU platform and OS info? I can try to reproduce it locally.

@Pey-crypto
Copy link
Contributor Author

@xczhai I am not able to build or test the commit I have made , because mlas and oneDNN are missing their MAKE files during the build. Using the -DENABLE flags doesn't seem to help. I have made two unit tests, for the functions and have not changed the underlying python api.

Did you execute git submodule update --init --recursive before building codes?

yup multiple times, i even cleared the submodules again and tried it again. I even used the --progress and --verbose flags to see the git clone process underneath, but all the clones were happening successfully

please share the commands you have tried.

git submodule update --init --recursive --progress cmake --build . --parallel $(nproc) cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_MLAS=OFF -DENABLE_ONEDNN=OFF ..

You should turn on mlas and onednn though it takes more time to build.

i did do that also, but then cmake reports mlas and onednn makefiles aren't available. I will try again and get back with the results.

Could you share the CPU platform and OS info? I can try to reproduce it locally.

Operating System: Ubuntu 24.04 LTS
Model name: 12th Gen Intel(R) Core(TM) i5-12500H
Architecture: x86-64

@github-actions github-actions bot added the category: build OpenVINO cmake script / infra label Sep 10, 2024
@Pey-crypto
Copy link
Contributor Author

Pey-crypto commented Sep 10, 2024

@xczhai Finally figured out the error, the permissions on those folders were messed up somehow, attaching strace revealed perms were being changed. I guess it was a local issue on my end.

@Pey-crypto
Copy link
Contributor Author

Pey-crypto commented Sep 11, 2024

Hi @Pey-crypto Thanks for your commits. But we can polish this PR for better maintain.

1. please check https://github.com/openvinotoolkit/openvino/blob/master/src/frontends/paddle/src/internal/pass/transform_fakequantize.cpp is needed or not. Theoretically, such pass should be remove since your commit works.

2. Previously, I prepare some unittests for Quantization. Maybe you can import these tests to such PR. It can ensure the motification accuracy. https://github.com/xczhai/openvino/tree/refactor_paddle_slim

BR.

Hi @xczhai,
Removed transform_fakquantize as the node is being made in quantize_linear. Removed references of fuse_fakequantize_ops from the paddle frontend.

@mlukasze
Copy link
Contributor

@xczhai please evaluate current state of the PR, enable jenkins pipelines if good enough

@Pey-crypto
Copy link
Contributor Author

@xczhai I used structured bindings, which wasn't compliant with C++ 11 standard, I have replaced it with tie.

@xczhai
Copy link
Contributor

xczhai commented Sep 19, 2024

@xczhai I used structured bindings, which wasn't compliant with C++ 11 standard, I have replaced it with tie.

Yes, you are right. The current implementation should be aligned with C++11.

@Pey-crypto
Copy link
Contributor Author

@xczhai , I have fixed the tests. Could you review it?

@xczhai
Copy link
Contributor

xczhai commented Oct 3, 2024

@xczhai , I have fixed the tests. Could you review it?

OK. I start it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: build OpenVINO cmake script / infra category: PDPD FE OpenVINO PaddlePaddle FrontEnd ExternalPR External contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants