# tf.tpu.experimental.embedding.QuantizationConfig

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/tpu/tpu_embedding_v2_utils.py#L905-L966) |

Settings for simulated quantization of the tpu embedding table.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.tpu.experimental.embedding.QuantizationConfig`](https://www.tensorflow.org/api_docs/python/tf/tpu/experimental/embedding/QuantizationConfig)

<br />

    tf.tpu.experimental.embedding.QuantizationConfig(
        num_buckets: int, lower: float, upper: float
    )

When simulated quantization is enabled, the results of the embedding lookup
are clipped and quantized according to the settings here before the combiner
is applied.

For example, to quantize `input` the following is done:

    if input < lower
      input = lower
    if input > upper
      input = upper
    quantum = (upper - lower) / (num_buckets - 1)
    input = math.floor((input - lower) / quantum + 0.5) * quantium + lower

See tensorflow/core/protobuf/tpu/optimization_parameters.proto for more
details.

> [!NOTE]
> **Note:** This does not change the storage type of the embedding table, that will continue to be float32 as will the saved variable in the checkpoint. You will have to manually quantize the variable (typically with the same algorithm and settings as above) manually.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `num_buckets` | The number of quantization buckets, must be atleast 2. |
| `lower` | The lower bound for the quantization range. |
| `upper` | The upper bound for the quantization range. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | if `num_buckets` is less than 2. |

<br />