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

Allow creating compressor when trust_remote_code=True #104

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

dbogunowicz
Copy link
Contributor

@dbogunowicz dbogunowicz commented Jul 2, 2024

This code:

from compressed_tensors import ModelCompressor
compressor = ModelCompressor.from_pretrained("microsoft/Phi-3-mini-128k-instruct",trust_remote_code=True)

Failed before:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/root/compressed-tensors/.venv/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py", line 983, in from_pretrained
    return config_class.from_dict(config_dict, **unused_kwargs)
  File "/root/compressed-tensors/.venv/lib/python3.10/site-packages/transformers/configuration_utils.py", line 772, in from_dict
    config = cls(**config_dict)
  File "/root/compressed-tensors/.venv/lib/python3.10/site-packages/transformers/models/phi3/configuration_phi3.py", line 158, in __init__
    self._rope_scaling_validation()
  File "/root/compressed-tensors/.venv/lib/python3.10/site-packages/transformers/models/phi3/configuration_phi3.py", line 185, in _rope_scaling_validation
    raise ValueError(f"`rope_scaling`'s type field must be one of ['su', 'yarn'], got {rope_scaling_type}")
ValueError: `rope_scaling`'s type field must be one of ['su', 'yarn'], got longrope

After the diff, we can properly initialize the config (and thus the compressor, although in this example it will be None) with trust_remote_code=True

@@ -81,6 +81,7 @@ class ModelCompressor:
def from_pretrained(
cls,
pretrained_model_name_or_path: str,
**kwargs,
Copy link
Member

Choose a reason for hiding this comment

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

nit: Add kwargs in docstring?

Copy link
Member

@anmarques anmarques left a comment

Choose a reason for hiding this comment

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

I tested w/ microsoft/Phi-3-mini-128k-instruct both original and after SparseML quantization and it worked

@anmarques anmarques merged commit b341803 into main Jul 3, 2024
1 check passed
@anmarques anmarques deleted the dbogunowicz-patch-2 branch July 3, 2024 16:18
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.

3 participants