From 0b931e38d58fd642612299e65afb744f9c12599a Mon Sep 17 00:00:00 2001 From: Tai An Date: Sat, 5 Sep 2026 15:14:02 -0700 Subject: [PATCH] fix(quantize_registry): compare activation_attrs against other, not self 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 --- .../keras/default_8bit/default_8bit_quantize_registry.py | 2 +- .../default_n_bit/default_n_bit_quantize_registry.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_model_optimization/python/core/quantization/keras/default_8bit/default_8bit_quantize_registry.py b/tensorflow_model_optimization/python/core/quantization/keras/default_8bit/default_8bit_quantize_registry.py index 244a6c027..2fe5027fe 100644 --- a/tensorflow_model_optimization/python/core/quantization/keras/default_8bit/default_8bit_quantize_registry.py +++ b/tensorflow_model_optimization/python/core/quantization/keras/default_8bit/default_8bit_quantize_registry.py @@ -366,7 +366,7 @@ def __eq__(self, other): return False return (self.weight_attrs == other.weight_attrs and - self.activation_attrs == self.activation_attrs and + self.activation_attrs == other.activation_attrs and self.weight_quantizer == other.weight_quantizer and self.activation_quantizer == other.activation_quantizer and self.quantize_output == other.quantize_output) diff --git a/tensorflow_model_optimization/python/core/quantization/keras/experimental/default_n_bit/default_n_bit_quantize_registry.py b/tensorflow_model_optimization/python/core/quantization/keras/experimental/default_n_bit/default_n_bit_quantize_registry.py index b7bf8c569..2c2007dad 100644 --- a/tensorflow_model_optimization/python/core/quantization/keras/experimental/default_n_bit/default_n_bit_quantize_registry.py +++ b/tensorflow_model_optimization/python/core/quantization/keras/experimental/default_n_bit/default_n_bit_quantize_registry.py @@ -412,7 +412,7 @@ def __eq__(self, other): return False return (self.weight_attrs == other.weight_attrs and - self.activation_attrs == self.activation_attrs and + self.activation_attrs == other.activation_attrs and self.weight_quantizer == other.weight_quantizer and self.activation_quantizer == other.activation_quantizer and self.quantize_output == other.quantize_output)