tf.keras.dtype_policies.AWQDTypePolicy

Quantized dtype policy for AWQ quantization.

Inherits From: QuantizedDTypePolicy, DTypePolicy

This policy helps propagate quantization settings for AWQ when loading an AWQ quantized model in Keras format.

mode The quantization mode. This should be a string in the format "awq/<weight_bits>/<group_size>".

  • "awq": The identifier for the quantization algorithm.
  • <weight_bits>: Number of bits to quantize weights to. AWQ presently only supports 4-bit quantization.
  • <group_size>: The group size for quantization. Supported values are -1 (for per-channel quantization) or any positive integer. Example: "awq/4/128".
source_name The source dtype policy name, e.g. "float32".

compute_dtype The compute dtype of this policy.

This is the dtype layers will do their computations in. Typically layers output tensors with the compute dtype as well.

Note that even if the compute dtype is float16 or bfloat16, hardware devices may not do individual adds, multiplies, and other fundamental operations in float16 or bfloat16, but instead may do some of them in float32 for numeric stability. The compute dtype is the dtype of the inputs and outputs of the ops that the layer executes. Internally, many ops will do certain internal calculations in float32 or some other device-internal intermediate format with higher precision than float16/bfloat16, to increase numeric stability.

name Returns the name of this policy.
quantization_mode The quantization mode of this policy.
variable_dtype The variable dtype of this policy.

This is the dtype layers will create their variables in, unless a layer explicitly chooses a different dtype. If this is different than DTypePolicy.compute_dtype, Layers will cast variables to the compute dtype to avoid type errors.

Variable regularizers are run in the variable dtype, not the compute dtype.

Methods

convert_input

View source

Converts the input dtype based on autocast and dtype.

Note that x can be a tensor, symbolic tensor or numpy array, and this method will keep integer inputs untouched and only apply casting to floats.

from_config

View source

get_config

View source

__eq__

View source

Return self==value.