Skip to content

correct weight quantizer for grouped_linear/layernorm_linear and layernorm_mlp #1733

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

HuangHunag-MT
Copy link
Contributor

Description

In grouped_linear/layernorm_linear and layernorm_mlp, weight._quantizer is not the same with quantizer saved in global buffer, and resulting in the problem of scale always being 1.

After fixing the issue, the mean relative error of the loss for 200 steps of fp8 and bf16 decreased from 0.15% to 0.09% in the two-layer deepseek example.

Fixes

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:
refers to behaviour in linear.py: 1246-1250

1246            # Make sure weight tensor has correct quantizer
1247            # Note: Quantizer might have changed if quantization
1248            # recipe changed
1249            if weight_quantizer is not None and isinstance(weight_tensor, QuantizedTensor):
1250                weight_tensor._quantizer = weight_quantizer
  • set weight_tensors[i]._quantizer = weight_quantizers[i] in grouped_linear.py
  • set weight_tensor._quantizer = weight_quantizer in layernorm_linear.py
  • set fc1/2_weight._quantizer = fc1/2_weight_quantizer layernorm_mlp.py

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant