Concrete ML
WebsiteLibrariesProducts & ServicesDevelopersSupport
1.1
1.1
  • What is Concrete ML?
  • Getting Started
    • Installation
    • Key Concepts
    • Inference in the Cloud
    • Demos and Tutorials
  • Built-in Models
    • Linear Models
    • Tree-based Models
    • Neural Networks
    • Pandas
    • Built-in Model Examples
  • Deep Learning
    • Using Torch
    • Using ONNX
    • Step-by-step Guide
    • Deep Learning Examples
    • Debugging Models
    • Optimizing Inference
  • Advanced topics
    • Quantization
    • Pruning
    • Compilation
    • Prediction with FHE
    • Production Deployment
    • Advanced Features
    • Serialization
  • Developer Guide
    • Workflow
      • Set Up the Project
      • Set Up Docker
      • Documentation
      • Support and Issues
      • Contributing
    • Inner Workings
      • Importing ONNX
      • Quantization Tools
      • FHE Op-graph Design
      • External Libraries
    • API
      • concrete.ml.common.check_inputs.md
      • concrete.ml.common.debugging.custom_assert.md
      • concrete.ml.common.debugging.md
      • concrete.ml.common.md
      • concrete.ml.common.serialization.decoder.md
      • concrete.ml.common.serialization.dumpers.md
      • concrete.ml.common.serialization.encoder.md
      • concrete.ml.common.serialization.loaders.md
      • concrete.ml.common.serialization.md
      • concrete.ml.common.utils.md
      • concrete.ml.deployment.deploy_to_aws.md
      • concrete.ml.deployment.deploy_to_docker.md
      • concrete.ml.deployment.fhe_client_server.md
      • concrete.ml.deployment.md
      • concrete.ml.deployment.server.md
      • concrete.ml.deployment.utils.md
      • concrete.ml.onnx.convert.md
      • concrete.ml.onnx.md
      • concrete.ml.onnx.onnx_impl_utils.md
      • concrete.ml.onnx.onnx_model_manipulations.md
      • concrete.ml.onnx.onnx_utils.md
      • concrete.ml.onnx.ops_impl.md
      • concrete.ml.pytest.md
      • concrete.ml.pytest.torch_models.md
      • concrete.ml.pytest.utils.md
      • concrete.ml.quantization.base_quantized_op.md
      • concrete.ml.quantization.md
      • concrete.ml.quantization.post_training.md
      • concrete.ml.quantization.quantized_module.md
      • concrete.ml.quantization.quantized_ops.md
      • concrete.ml.quantization.quantizers.md
      • concrete.ml.search_parameters.md
      • concrete.ml.search_parameters.p_error_search.md
      • concrete.ml.sklearn.base.md
      • concrete.ml.sklearn.glm.md
      • concrete.ml.sklearn.linear_model.md
      • concrete.ml.sklearn.md
      • concrete.ml.sklearn.qnn.md
      • concrete.ml.sklearn.qnn_module.md
      • concrete.ml.sklearn.rf.md
      • concrete.ml.sklearn.svm.md
      • concrete.ml.sklearn.tree.md
      • concrete.ml.sklearn.tree_to_numpy.md
      • concrete.ml.sklearn.xgb.md
      • concrete.ml.torch.compile.md
      • concrete.ml.torch.md
      • concrete.ml.torch.numpy_module.md
      • concrete.ml.version.md
Powered by GitBook

Libraries

  • TFHE-rs
  • Concrete
  • Concrete ML
  • fhEVM

Developers

  • Blog
  • Documentation
  • Github
  • FHE resources

Company

  • About
  • Introduction to FHE
  • Media
  • Careers
On this page
  • module concrete.ml.deployment.fhe_client_server
  • Global Variables
  • class FHEModelServer
  • class FHEModelDev
  • class FHEModelClient

Was this helpful?

Export as PDF
  1. Developer Guide
  2. API

concrete.ml.deployment.fhe_client_server.md

Previousconcrete.ml.deployment.deploy_to_docker.mdNextconcrete.ml.deployment.md

Last updated 1 year ago

Was this helpful?

module concrete.ml.deployment.fhe_client_server

APIs for FHE deployment.

Global Variables

  • CML_VERSION


class FHEModelServer

Server API to load and run the FHE circuit.

method __init__

__init__(path_dir: str)

Initialize the FHE API.

Args:

  • path_dir (str): the path to the directory where the circuit is saved


method load

load()

Load the circuit.

Raises:

  • ValueError: if mismatch in versions between serialized file and runtime


method run

run(
    serialized_encrypted_quantized_data: bytes,
    serialized_evaluation_keys: bytes
) → bytes

Run the model on the server over encrypted data.

Args:

  • serialized_encrypted_quantized_data (bytes): the encrypted, quantized and serialized data

  • serialized_evaluation_keys (bytes): the serialized evaluation keys

Returns:

  • bytes: the result of the model


class FHEModelDev

Dev API to save the model and then load and run the FHE circuit.

method __init__

__init__(path_dir: str, model: Any = None)

Initialize the FHE API.

Args:

  • path_dir (str): the path to the directory where the circuit is saved

  • model (Any): the model to use for the FHE API


method save

save(via_mlir: bool = False)

Export all needed artifacts for the client and server.

Arguments:

  • via_mlir (bool): serialize with via_mlir option from Concrete-Python. For more details on the topic please refer to Concrete-Python's documentation.

Raises:

  • Exception: path_dir is not empty


class FHEModelClient

Client API to encrypt and decrypt FHE data.

method __init__

__init__(path_dir: str, key_dir: Optional[str] = None)

Initialize the FHE API.

Args:

  • path_dir (str): the path to the directory where the circuit is saved

  • key_dir (str): the path to the directory where the keys are stored


method deserialize_decrypt

deserialize_decrypt(serialized_encrypted_quantized_result: bytes) → ndarray

Deserialize and decrypt the values.

Args:

  • serialized_encrypted_quantized_result (bytes): the serialized, encrypted and quantized result

Returns:

  • numpy.ndarray: the decrypted and deserialized values


method deserialize_decrypt_dequantize

deserialize_decrypt_dequantize(
    serialized_encrypted_quantized_result: bytes
) → ndarray

Deserialize, decrypt and de-quantize the values.

Args:

  • serialized_encrypted_quantized_result (bytes): the serialized, encrypted and quantized result

Returns:

  • numpy.ndarray: the decrypted (de-quantized) values


method generate_private_and_evaluation_keys

generate_private_and_evaluation_keys(force=False)

Generate the private and evaluation keys.

Args:

  • force (bool): if True, regenerate the keys even if they already exist


method get_serialized_evaluation_keys

get_serialized_evaluation_keys() → bytes

Get the serialized evaluation keys.

Returns:

  • bytes: the evaluation keys


method load

load()

Load the quantizers along with the FHE specs.

Raises:

  • ValueError: if mismatch in versions between serialized file and runtime


method quantize_encrypt_serialize

quantize_encrypt_serialize(x: ndarray) → bytes

Quantize, encrypt and serialize the values.

Args:

  • x (numpy.ndarray): the values to quantize, encrypt and serialize

Returns:

  • bytes: the quantized, encrypted and serialized values