-
Notifications
You must be signed in to change notification settings - Fork 266
fix(pytorch): Rename layer_scale parameter to avoid quantization error #2172
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
neural_compressor/adaptor/pytorch.py:4175
- The current filter condition excludes any parameter containing 'gamma', which might unintentionally filter out valid parameters. Consider checking explicitly for 'layer_scale' and 'layer_gamma' instead to avoid potential misclassification.
if "scale" in node.target and not any(exclude in node.target for exclude in ["layer_scale", "gamma"]):
Hi @ved1beta Thanks for your commit. Suggestion: BTW, currently our CI is blocked by #2171. To resolve the CI issue, please update your branch after #2171 is merged. |
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/pycqa/isort: 5.13.2 → 6.0.1](PyCQA/isort@5.13.2...6.0.1) - [github.com/psf/black.git: 24.10.0 → 25.1.0](https://github.com/psf/black.git/compare/24.10.0...25.1.0) - [github.com/codespell-project/codespell: v2.3.0 → v2.4.1](codespell-project/codespell@v2.3.0...v2.4.1) - [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.11.4](astral-sh/ruff-pre-commit@v0.8.6...v0.11.4) Signed-off-by: Sun, Xuehao <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: changwangss <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: xin3he <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: V-E-D <[email protected]>
9c09ae4
to
7f76ab4
Compare
eecb889
to
ae0701c
Compare
hey i did required changes but had a merge conflict , fixing it |
for more information, see https://pre-commit.ci
Thanks, @ved1beta, merged |
Here's the formatted PR description based on our changes:
Type of Change
Description
This PR fixes an issue where PyTorch models using
layer_scale
parameters fail during quantization due to tensor conversion errors. The problem occurs when the quantization process attempts to convert tensor-type scale parameters to Python scalars.Key changes:
layer_scale
parameter tolayer_gamma
to avoid conflicts with scale detection_get_module_scale_zeropoint
method to better handle scale parametersThe fix maintains backward compatibility while resolving the quantization failure.
Expected Behavior & Potential Risk
Expected Behavior:
layer_gamma
parameter will successfully complete quantizationPotential Risks:
layer_scale
parameter name might need updatesHow has this PR been tested?
Tests have been implemented in
test/adaptor/test_pytorch_layer_scale.py
with two test cases:test_layer_scale_error
: Verifies the original issue by confirming that models withlayer_scale
parameter fail quantization with the expected errortest_layer_gamma_success
: Validates that models using the newlayer_gamma
parameter successfully complete quantizationTest Environment:
To reproduce:
cd neural-compressor python3 test/adaptor/test_pytorch_layer_scale.py
Dependency Change?
No new dependencies were introduced or removed.