Files
docs/ml/references/api/concrete.ml.quantization.linear_op_glwe_backend.md

2.8 KiB

module torus.ml.quantization.linear_op_glwe_backend

GLWE backend for some supported layers.


function has_glwe_backend

has_glwe_backend()

Check if the GLWE backend is installed.

Returns:

  • bool: True if the GLWE backend is installed, False otherwise.

class GLWELinearLayerExecutor

GLWE execution helper for pure linear layers.

method __init__

__init__(
    private_key=None,
    compression_key=None,
    use_dynamic_quantization: bool = True
)

Initialize the GLWE linear layer executor.

Args:

  • private_key: Private key for encryption
  • compression_key: Compression key for encryption
  • use_dynamic_quantization: Whether to use dynamic quantization

method forward

forward(x: Tensor, q_module: QuantizedModule, fhe: HybridFHEMode) → Tensor

Perform the inference of this linear layer.

Args:

  • x (torch.Tensor): Input or previous layer activations.
  • q_module (QuantizedModule): Module containing the quantized layer.
  • fhe (HybridFHEMode): Execution mode, can be 'DISABLE' or 'EXECUTE'.

Returns:

  • torch.Tensor: The result of applying the linear layer.

method keygen

keygen()

Generate private and compression key.