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

Fix ort config instantiation (from_pretrained) and saving (save_pretrained) #1865

Merged
merged 4 commits into from
May 28, 2024

Conversation

IlyasMoutawwakil
Copy link
Member

@IlyasMoutawwakil IlyasMoutawwakil commented May 22, 2024

What does this PR do?

Fixes #1838

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Who can review?

@IlyasMoutawwakil IlyasMoutawwakil changed the title Fix ort config instantiation (from_dict) and saving (to_dict) Fix ort config instantiation (from_pretrained) and saving (save_pretrained) May 22, 2024
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Comment on lines +301 to +309
if isinstance(self.format, str):
self.format = QuantFormat[self.format]
if isinstance(self.mode, str):
self.mode = QuantizationMode[self.mode]
if isinstance(self.activations_dtype, str):
self.activations_dtype = QuantType[self.activations_dtype]
if isinstance(self.weights_dtype, str):
self.weights_dtype = QuantType[self.weights_dtype]

Copy link
Member Author

Choose a reason for hiding this comment

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

post init : str -> enums

Comment on lines +1031 to +1043
def to_dict(self) -> Dict[str, Any]:
dict_config = {
"opset": self.opset,
"use_external_data_format": self.use_external_data_format,
"one_external_file": self.one_external_file,
"optimization": self.dataclass_to_dict(self.optimization),
"quantization": self.dataclass_to_dict(self.quantization),
}

if self.optimum_version:
dict_config["optimum_version"] = self.optimum_version

return dict_config
Copy link
Member Author

Choose a reason for hiding this comment

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

called by the mixin at save time (BaseConfig)

Copy link
Collaborator

@echarlaix echarlaix left a comment

Choose a reason for hiding this comment

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

Looks good, thanks a lot @IlyasMoutawwakil

@echarlaix echarlaix merged commit cbbda3e into main May 28, 2024
41 of 47 checks passed
@echarlaix echarlaix deleted the fix-ort-config branch May 28, 2024 16:03
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.

Quantizing from cli using config file fails
3 participants