fix(quantize_registry): compare activation_attrs against other, not self, in QuantizeConfig.__eq__ - #1300
Open
Anai-Guo wants to merge 1 commit into
Conversation
Default8BitQuantizeConfig.__eq__ and DefaultNBitQuantizeConfig.__eq__ compare `self.activation_attrs == self.activation_attrs`, which is always True. Every other term in the same expression compares against `other`, so this one term silently drops out of the comparison and two configs that differ only in activation_attrs compare equal. Signed-off-by: Tai An <antai12232931@outlook.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Problem
Default8BitQuantizeConfig.__eq__andDefaultNBitQuantizeConfig.__eq__compareactivation_attrsagainstselfinstead ofother:self.activation_attrs == self.activation_attrsis alwaysTrue, so the term contributes nothing to theandchain:activation_attrsis effectively excluded from equality, and two configs that differ only in which activations they quantize compare equal (and__ne__, which delegates to__eq__, reports them as not-unequal).Every one of the four sibling terms in the same expression compares
self.X == other.X, and every other__eq__in the package follows that idiom — e.g.LastValueQuantizer.__eq__inquantizers.py:The same line is duplicated verbatim in the
default_n_bitcopy, so both are fixed here.default_8bit/default_8bit_quantize_registry.py:369experimental/default_n_bit/default_n_bit_quantize_registry.py:415Fix
self.activation_attrs == self.activation_attrs→self.activation_attrs == other.activation_attrs, in both files. Two lines, no other change.Verification
I don't have a TF runtime on this box, so I verified behaviourally by extracting
__eq__verbatim from the file withast.get_source_segment,exec-ing it against a minimal stand-in that only holds the five compared attributes, and running the current line against the patched one:activation_attrsFalseTrue❌False✅TrueTrueTrueweight_attrs(control)FalseFalseFalseactivation_attrsFalseTrue❌False✅The control row is there to show the check isn't vacuous:
weight_attrs, which is compared correctly, already discriminates on master, and the patch leaves it alone. Only the two rows that isolateactivation_attrschange.A concrete pair that is wrongly equal on master:
🤖 Generated with Claude Code