Skip to content

Fix broken Min/Max Tracking Across Calibration Batches#2705

Open
Ebraheem1 wants to merge 2 commits into
apple:mainfrom
Ebraheem1:fix/activation-calibration-range-overwrite
Open

Fix broken Min/Max Tracking Across Calibration Batches#2705
Ebraheem1 wants to merge 2 commits into
apple:mainfrom
Ebraheem1:fix/activation-calibration-range-overwrite

Conversation

@Ebraheem1
Copy link
Copy Markdown

Fixed Bug

When you run activation quantization with multi-batch calibration, the min/max are picked from the last batch's tensor. This is a faulty behavior that produces wrong quantization ranges.

Tests

  • Added coverage tests for the multi-batch calibration case coremltools/test/optimize/test_utils.py and coremltools/optimize/coreml/experimental/test_post_training_quantization.py .

Issue

Fixes #2704

Copy link
Copy Markdown
Collaborator

@TobyRoseman TobyRoseman left a comment

Choose a reason for hiding this comment

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

Please write unit tests that fail without your fix and pass with your fix. Also avoid writing your unit tests directly against underscore/private method.

Comment thread coremltools/test/optimize/test_utils.py Outdated
Comment thread coremltools/optimize/coreml/experimental/test_post_training_quantization.py Outdated
@Ebraheem1
Copy link
Copy Markdown
Author

I only included breaking tests without the modifications.

@Ebraheem1
Copy link
Copy Markdown
Author

@TobyRoseman do you have other comments here?

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.

fix(calibration): _update_tensor_range should not pick only last batch min/max

2 participants