-
Notifications
You must be signed in to change notification settings - Fork 125
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
Save an openvino config summarizing all information related to quantization when saving model #578
Merged
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fa8c3fd
fix doc
echarlaix 3145898
remove default compression value
echarlaix dfc4893
set default compression config when not provided
echarlaix db22a52
save openvino config to include quantization configuration
echarlaix f35aa15
fix style
echarlaix 5634c29
add test
echarlaix 30a5101
style
echarlaix f1b4c55
update setup
echarlaix 4261314
fix
echarlaix bae24bf
fix
echarlaix fbbe804
style
echarlaix 237cc73
remove from quantization_config key from ov_config
echarlaix aa667ef
add test
echarlaix a297f09
fix
echarlaix 704f91a
fix
echarlaix cb847bb
update setup
echarlaix 3a71f42
modify method name
echarlaix 1137b7a
merge main in branch
echarlaix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,8 +38,6 @@ save_dir = "ptq_model" | |
def preprocess_function(examples, tokenizer): | ||
return tokenizer(examples["sentence"], padding="max_length", max_length=128, truncation=True) | ||
|
||
# Load the default quantization configuration detailing the quantization we wish to apply | ||
quantization_config = OVConfig() | ||
Comment on lines
-41
to
-42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed as currently unused |
||
# Instantiate our OVQuantizer using the desired configuration | ||
quantizer = OVQuantizer.from_pretrained(model) | ||
# Create the calibration dataset used to perform static quantization | ||
|
@@ -52,7 +50,6 @@ calibration_dataset = quantizer.get_calibration_dataset( | |
) | ||
# Apply static quantization and export the resulting quantized model to OpenVINO IR format | ||
quantizer.quantize( | ||
quantization_config=quantization_config, | ||
calibration_dataset=calibration_dataset, | ||
save_directory=save_dir, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do I understand correctly that with these changes you need to add a quantization_config to .from_pretrained when loading a model, but that doesn't actually do anything until you call quantizer.quantize?
What is the reason for that change? If the motivation is to save the config, it seems we could just update that after quantizing the model?
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.
There is no modification of the quantization process in this PR (you can still apply quantization by providing the
quantization_config
orload_in_8bit
arguments when creating an instance ofOVModel
), the main addition is that we save the configuration containing all the information related to quantization when saving the model withmodel.save_pretrained(output_dir)
. I also removed the default compression value that was default when creating anOVConfig
instance as it's not used (we should start moving all quantization parameters inquantization_config
in the future).