Skip to content

Feat (export/onnx): fallback export to fake quantized weights#1395

Merged
nickfraser merged 5 commits intoXilinx:devfrom
Giuseppe5:export_fake_quantized
Oct 24, 2025
Merged

Feat (export/onnx): fallback export to fake quantized weights#1395
nickfraser merged 5 commits intoXilinx:devfrom
Giuseppe5:export_fake_quantized

Conversation

@Giuseppe5
Copy link
Collaborator

@Giuseppe5 Giuseppe5 commented Oct 16, 2025

Reason for this PR

ONNX's QuantizeLinear node only supports ROUND as rounding function, but there are cases where we might be using FLOOR.

Changes Made in this PR

This PR addresses this issue by falling back to saving and exporting fake quantized weights.
With this trick, we use whatever interal rounding operation to pre-quantize the weights, so that round is basically a no-op during export time.

The drawback of this approach is that we effectively duplicate weights during export.

This could be remedied for example by destructively replacing the original weights with the fake quantized ones, with the obvious drawback that we lose access to the original model's weights.

Testing Summary

Added tests with floor rounding format for weights.
This effectively double the testing configurations and the testing time.

Copy link
Collaborator

@nickfraser nickfraser left a comment

Choose a reason for hiding this comment

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

One comment about a duplicated function, otherwise LGTM!

@Giuseppe5 Giuseppe5 requested a review from nickfraser October 17, 2025 15:10
@nickfraser nickfraser added the next release PRs which should be merged for the next release label Oct 20, 2025
@nickfraser nickfraser mentioned this pull request Oct 21, 2025
34 tasks
@nickfraser
Copy link
Collaborator

FYI, the FINN integration issues are likely fixed in #1400

@nickfraser nickfraser force-pushed the export_fake_quantized branch from 9555e11 to 7e92477 Compare October 23, 2025 09:24
@nickfraser nickfraser requested review from pablomlago and removed request for pablomlago October 23, 2025 09:24
@nickfraser nickfraser merged commit 004479e into Xilinx:dev Oct 24, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next release PRs which should be merged for the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants