# ValueError: Quantization range (min, max) not supported for op 'CONV_2D' with input type float32 and output type uint8

- **ID:** `tensorflow/tflite-quantization-range`
- **Domain:** tensorflow
- **Category:** build_error
- **Error Code:** `TQR`
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

During TFLite conversion, the quantization parameters (min/max) for a CONV_2D op are either missing or out of the valid range for uint8 quantization, typically because calibration data did not cover the full activation range.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| tensorflow>=2.12.0 | active | — | — |
| tflite>=2.12 | active | — | — |
| python>=3.9 | active | — | — |

## Workarounds

1. **Ensure the calibration dataset includes diverse inputs that trigger both minimum and maximum activation values for the CONV_2D layer. For example, use a balanced subset of training data: representative_dataset = lambda: [tf.random.normal([1, 224, 224, 3]) for _ in range(100)] (but with real data).** (80% success)
   ```
   Ensure the calibration dataset includes diverse inputs that trigger both minimum and maximum activation values for the CONV_2D layer. For example, use a balanced subset of training data: representative_dataset = lambda: [tf.random.normal([1, 224, 224, 3]) for _ in range(100)] (but with real data).
   ```
2. **Switch to per-channel quantization or use tf.lite.TFLiteConverter with optimizations=[tf.lite.Optimize.DEFAULT] and specify supported_ops=[tf.lite.OpsSet.TFLITE_BUILTINS_INT8] after ensuring full integer quantization is possible.** (75% success)
   ```
   Switch to per-channel quantization or use tf.lite.TFLiteConverter with optimizations=[tf.lite.Optimize.DEFAULT] and specify supported_ops=[tf.lite.OpsSet.TFLITE_BUILTINS_INT8] after ensuring full integer quantization is possible.
   ```

## Dead Ends

- **Increasing the number of calibration steps arbitrarily without verifying data diversity.** — More steps of the same data does not improve range coverage; the error persists if the calibration set lacks extreme values. (70% fail)
- **Manually setting min/max to [-128, 127] in the converter options.** — TFLite converter ignores manual override for per-op ranges; it expects calibration to provide them. (90% fail)
