tensorflow/models · error · RuntimeError
Default8BitActivationQuantizeConfig can only be used with…
Error message
Default8BitActivationQuantizeConfig can only be used with `keras.layers.Activation`.
What it means
Assertion helper _assert_activation_layer in Default8BitActivationQuantizeConfig: this QuantizeConfig is written specifically for tf_keras.layers.Activation layers; if quantize_annotate/apply attaches it to any other layer type, a RuntimeError is raised from each QuantizeConfig hook.
Solutions
- Apply this config only to keras.layers.Activation layers
- Use Default8BitQuantizeConfig (or a layer-specific config) for other layer types
- Restrict the quantization annotation scope to Activation layers
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at official/projects/qat/nlp/quantization/configs.py:224 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/094ff34f43c2c269.
Report an issue: GitHub.
Appendix: source
Thrown at official/projects/qat/nlp/quantization/configs.py:224
MovingAverageQuantizer(
num_bits=8, per_axis=False, symmetric=False, narrow_range=False)
]
def get_config(self) -> Dict[str, Any]:
return {}
class Default8BitActivationQuantizeConfig(
tfmot.quantization.keras.QuantizeConfig):
"""QuantizeConfig for keras.layers.Activation.
`keras.layers.Activation` needs a separate `QuantizeConfig` since the
decision to quantize depends on the specific activation type.
"""
def _assert_activation_layer(self, layer: Layer):
if not isinstance(layer, tf_keras.layers.Activation):
raise RuntimeError(
'Default8BitActivationQuantizeConfig can only be used with '
'`keras.layers.Activation`.')
def get_weights_and_quantizers(
self, layer: Layer) -> Sequence[WeightAndQuantizer]:
"""See base class."""
self._assert_activation_layer(layer)
return []
def get_activations_and_quantizers(
self, layer: Layer) -> Sequence[ActivationAndQuantizer]:
"""See base class."""
self._assert_activation_layer(layer)
return []
def set_quantize_weights(
self,
layer: Layer,View on GitHub (pinned to e006f5f0d5)