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

Workaround HF Quantizer apply_quantization_config misuse #180

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

kylesayrs
Copy link
Contributor

@kylesayrs kylesayrs commented Oct 4, 2024

CompressedTensorsHfQuantizer attempts to use apply_quantization_config to apply the quantization config to the model

def _process_model_before_weight_loading(self, model, **kwargs):
        from compressed_tensors.quantization import apply_quantization_config

        ct_quantization_config = self.compressor.quantization_config
        apply_quantization_config(model, ct_quantization_config, run_compressed=True)

However, self.compressor.quantization_config can be None in the case that only sparsity is present. This does not align with the function contract of apply_quantization_config. In such a case, an error is thrown.

def apply_quantization_config(
    model: Module, config: QuantizationConfig, run_compressed: bool = False
) -> Dict:

This PR adjusts the function to handle Nones until this branch's changes are landed on transformers

rahul-tuli
rahul-tuli previously approved these changes Oct 4, 2024
Copy link
Contributor

@dsikka dsikka left a comment

Choose a reason for hiding this comment

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

Add a comment for when this would be the case for clarity

@rahul-tuli
Copy link
Member

This is needed!

@mgoin mgoin merged commit d6d823c into main Oct 7, 2024
1 check passed
@mgoin mgoin deleted the kylesayrs/bugfix-support-apply-none branch October 7, 2024 16:55
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.

4 participants