Natural Language Processing#

Modules#

class archai.quantization.nlp.modules.FakeDynamicQuantHFConv1D(*args, dynamic_weight: bool | None = True, activation_reduce_range: bool | None = True, bits: int | None = 8, onnx_compatible: bool | None = False, qconfig: Dict[Module, Any] | None = None, **kwargs)[source]#

Translate a huggingface/transformers Conv1D layer into a QAT-ready Conv1D layer.

property fake_quant_weight: Tensor#

Return a fake quantization over the weight matrix.

forward(x: Tensor) Tensor[source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

classmethod from_float(mod: Module, qconfig: Dict[Module, Any] | None = None, activation_reduce_range: bool | None = True, **kwargs) FakeDynamicQuantHFConv1D[source]#

Map module from float to QAT-ready.

Parameters:
  • mod – Module to be mapped.

  • qconfig – Quantization configuration.

  • activation_reduce_range – Whether to reduce the range of activations.

Returns:

QAT-ready module.

to_float() Module[source]#

Map module from QAT-ready to float.

Returns:

Float-based module.

training: bool#
class archai.quantization.nlp.modules.FakeDynamicQuantHFConv1DForOnnx(*args, **kwargs)[source]#

Allow a QAT-ready huggingface/transformers Conv1D layer to be exported with ONNX.

training: bool#