-
Notifications
You must be signed in to change notification settings - Fork 213
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
[PTQ][OV] BF16 support #2307
base: develop
Are you sure you want to change the base?
[PTQ][OV] BF16 support #2307
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #2307 +/- ##
===========================================
+ Coverage 91.18% 91.20% +0.01%
===========================================
Files 483 483
Lines 46412 46435 +23
===========================================
+ Hits 42323 42352 +29
+ Misses 4089 4083 -6
... and 4 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more.
|
input_low = opset.constant(value=fq_params.input_low.data, dtype=dtype) | ||
input_high = opset.constant(value=fq_params.input_high.data, dtype=dtype) | ||
output_low = opset.constant(value=fq_params.output_low.data, dtype=dtype) | ||
output_high = opset.constant(value=fq_params.output_high.data, dtype=dtype) |
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.
Are you sure that we don't need clip FQ params before creating the constant node?
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.
Good catch. I'll look at this.
@l-bat, @alexsu52, @andrey-churkin, review, please. |
if node_output.get_element_type() != outputs_type: | ||
node_output = opset.convert(output, destination_type=outputs_type) |
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 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.
I would suggest to add flexibility. I mean the insert output transformation command should has dtype
parameter to specify return type. By default the return type is FP32.
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.
Done.
Compression time comparison. Numbers were collected on local i9-10980XE.
No degradations were observed. |
@@ -102,16 +97,16 @@ def _get_activation_node_names(model: ov.Model) -> List[str]: | |||
return list(activation_nodes) | |||
|
|||
@staticmethod | |||
def _update_tensor_name(tensors: List[DescriptorTensor], name: str) -> None: | |||
def _update_tensor_name(tensors: List[DescriptorTensor], names: List[str]) -> None: |
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.
def _update_tensor_name(tensors: List[DescriptorTensor], names: List[str]) -> None: | |
def _update_tensor_names(tensors: List[DescriptorTensor], names: List[str]) -> None: |
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.
Done.
@@ -162,7 +161,7 @@ def transform_model( | |||
should_add_convert_node = True | |||
break | |||
|
|||
weight = Tensor(get_const_value(const_node, np.float32 if const_dtype == ov.Type.bf16 else None)) | |||
weight = Tensor(get_const_value(const_node, const_dtype)) |
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.
If I'm not mistaken, then you removed the bf16 to fp32 conversion.
weight = Tensor(get_const_value(const_node, const_dtype)) | |
weight = Tensor(get_const_value(const_node)) |
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.
Done.
Changes
ov.Tensor
Reason for changes
Related tickets
Tests