tensorflow/models · error · ValueError
Variable name is not supported on CustomLayerQuantize( )…
Error message
Variable name {} is not supported on CustomLayerQuantize({}) transform. What it means
Guard in the nlp CustomLayerQuantize transform's _is_quantization_weight_name: during pattern replacement every TransformerEncoderBlock weight must be either a QAT weight or a whitelisted model weight; an unrecognized variable name cannot be mapped to the quantized layer, so this ValueError names the variable and the transform.
Solutions
- Add the new weight name to the supported weight-name sets in the scheme
- Check for a renamed variable in the updated TransformerEncoderBlock
- Update the quantized layer class to consume the unknown weight
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at official/projects/qat/nlp/quantization/schemes.py:82 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/0b5c7b41afdc8e8a.
Report an issue: GitHub.
Appendix: source
Thrown at official/projects/qat/nlp/quantization/schemes.py:82
'embeddings'
})
def __init__(self):
super().__init__()
self._original_layer_pattern = 'modeling>TransformerEncoderBlock'
self._quantized_layer_class = transformer_encoder_block.TransformerEncoderBlockQuantized
def pattern(self) -> LayerPattern:
"""See base class."""
return LayerPattern(self._original_layer_pattern)
def _is_quantization_weight_name(self, name):
simple_name = name.split('/')[-1].split(':')[0]
if simple_name in self._QUANTIZATION_AWARE_TRAINING_WEIGHT_NAMES:
return True
if simple_name in self._SUPPOTRED_MODEL_WEIGHT_NAMES:
return False
raise ValueError('Variable name {} is not supported on '
'CustomLayerQuantize({}) transform.'.format(
simple_name,
self._original_layer_pattern))
def replacement(self, match_layer: LayerNode) -> LayerNode:
"""See base class."""
bottleneck_layer = match_layer.layer
bottleneck_config = bottleneck_layer['config']
bottleneck_names_and_weights = list(match_layer.names_and_weights)
quantized_layer = self._quantized_layer_class(
**bottleneck_config)
quantized_layer_config = quantized_layer.get_config()
if 'hidden_size' in quantized_layer_config:
dummy_input_shape = [
1, 1, quantized_layer_config['hidden_size']]
quantized_layer.compute_output_shape(dummy_input_shape)
elif 'num_attention_heads' in quantized_layer_config:View on GitHub (pinned to e006f5f0d5)