[ONNX] Weight compression for opset < 21#3497
Merged
Merged
Conversation
anzr299
approved these changes
May 19, 2025
alexsu52
reviewed
May 20, 2025
andrey-churkin
commented
May 22, 2025
| @@ -0,0 +1,179 @@ | |||
| ,prompts,answers,language | |||
Contributor
Author
There was a problem hiding this comment.
@alexsu52 The req_qa_onnx.csv file was obtained using the following "gold" model:
model_gold = ORTModelForCausalLM.from_pretrained(
self.fp32_model_dir,
trust_remote_code=True,
provider="OpenVINOExecutionProvider"
)It is identical to ref_qa.csv, which was generated using the model below:
model_gold = OVModelForCausalLM.from_pretrained(
self.fp32_model_dir,
trust_remote_code=True,
load_in_8bit=False,
compile=False,
stateful=is_stateful,
ov_config={"KV_CACHE_PRECISION": "f16"},
)So, if you don't mind, I suggest using only the ref_qa.csv file.
andrey-churkin
commented
May 22, 2025
Comment on lines
+169
to
+176
| if not (self.fp32_model_dir / self.ONNX_MODEL_NAME).exists(): | ||
| opset_version = self.params.get("opset", None) | ||
| if opset_version: | ||
| main_export(self.model_id, self.fp32_model_dir, opset=opset_version) | ||
| self.model_hf = ORTModelForCausalLM.from_pretrained(self.fp32_model_dir, trust_remote_code=True) | ||
| else: | ||
| self.model_hf = ORTModelForCausalLM.from_pretrained(self.model_id, export=True) | ||
| self.model_hf.save_pretrained(self.fp32_model_dir) |
Contributor
Author
There was a problem hiding this comment.
We can't specify the opset version with ORTModelForCausalLM.from_pretrained(). To obtain a model with an opset version lower than 21, we should use the main_export() method (or a similar approach).
Contributor
Author
AlexanderDokuchaev
approved these changes
May 23, 2025
Collaborator
|
To be merged after #3510 |
b84ba68 to
fa16f34
Compare
Contributor
Author
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes
Replace the
MatMuloperation with theMatMulNBitsoperation from ONNX Runtime contrib operators.See https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md
Reason for changes
The
DequantizeLinearoperation supports theblock_sizeattribute only starting from opset 21.Related tickets
Ref: 163946
Tests