You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These models only support _Concrete_ ciphertexts. See [the ciphertexts format](../getting-started/concepts.md#ciphertext-formats) documentation for more details.
32
+
29
33
## Quantization parameters
30
34
31
35
The `n_bits` parameter controls the bit-width of the inputs and weights of the linear models. Linear models do not use table lookups and thus allows weight and inputs to be high precision integers.
These models only support _Concrete_ ciphertexts. See [the ciphertexts format](../getting-started/concepts.md#ciphertext-formats) documentation for more details.
Copy file name to clipboardExpand all lines: docs/built-in-models/neural-networks.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,10 @@ Good quantization parameter values are critical to make models [respect FHE cons
23
23
Using `nn.ReLU` as the activation function benefits from an optimization where [quantization uses powers-of-two scales](../explanations/quantization.md#quantization-special-cases). This results in much faster inference times in FHE, thanks to a TFHE primitive that performs fast division by powers of two.
24
24
{% endhint %}
25
25
26
+
## Ciphertext format compatibility
27
+
28
+
These models only support _Concrete_ ciphertexts. See [the ciphertexts format](../getting-started/concepts.md#ciphertext-formats) documentation for more details.
29
+
26
30
## Example
27
31
28
32
To create an instance of a Fully Connected Neural Network (FCNN), you need to instantiate one of the `NeuralNetClassifier` and `NeuralNetRegressor` classes and configure a number of parameters that are passed to their constructor.
Copy file name to clipboardExpand all lines: docs/built-in-models/training.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,10 @@ See the [deployment](#deployment) section for more details.
17
17
Training on encrypted data provides the highest level of privacy but is slower than training on clear data. Federated learning is an alternative approach, where data privacy can be ensured by using a trusted gradient aggregator, coupled with optional _differential privacy_ instead of encryption. Concrete ML can import models trained through federated learning using 3rd party tools. All model types are supported - linear, tree-based and neural networks - through the [`from_sklearn_model` function](linear.md#pre-trained-models) and the [`compile_torch_model`](../deep-learning/torch_support.md) function.
18
18
{% endhint %}
19
19
20
+
## Ciphertext format compatibility
21
+
22
+
These models only support _Concrete_ ciphertexts. See [the ciphertexts format](../getting-started/concepts.md#ciphertext-formats) documentation for more details.
23
+
20
24
## Example
21
25
22
26
The [logistic regression training](../advanced_examples/LogisticRegressionTraining.ipynb) example shows logistic regression training on encrypted data in action.
Copy file name to clipboardExpand all lines: docs/built-in-models/tree.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,12 @@ For a formal explanation of the mechanisms that enable FHE-compatible decision t
26
26
Using the maximum depth parameter of decision trees and tree-ensemble models strongly increases the number of nodes in the trees. Therefore, we recommend using the XGBoost models which achieve better performance with lower depth.
27
27
{% endhint %}
28
28
29
+
## Ciphertext format compatibility
30
+
31
+
The `DecisionTreeClassifier`, `RandomForestClassifier`, and `XGBClassifier` support [TFHE-rs radix ciphertexts](../getting-started/concepts.md#ciphertext-formats) when `n_bits` is set to 8. The other tree-based models, or different `n_bits` configurations only support _Concrete_ ciphertexts.
32
+
33
+
To compile a model to use _TFHE-rs ciphertexts_ as inputs and outputs, set `ciphertext_mode=CiphertextFormat.TFHE-RS` in the `compile` call.
34
+
29
35
## Pre-trained models
30
36
31
37
You can convert an already trained scikit-learn tree-based model to a Concrete ML one by using the [`from_sklearn_model`](../references/api/concrete.ml.sklearn.base.md#classmethod-from_sklearn_model) method.
Copy file name to clipboardExpand all lines: docs/getting-started/README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,13 @@
5
5
Concrete ML is an open source, privacy-preserving, machine learning framework based on Fully Homomorphic Encryption (FHE). It enables data scientists without any prior knowledge of cryptography to perform:
6
6
7
7
-**Automatic model conversion**: Use familiar APIs from scikit-learn and PyTorch to convert machine learning models to their FHE equivalent. This is applicable for [linear models](../built-in-models/linear.md), [tree-based models](../built-in-models/tree.md), and [neural networks](../built-in-models/neural-networks.md)).
8
-
-**Encrypted data training**: [Train models](../built-in-models/training.md) directly on encrypted data to maintain privacy.
8
+
-**Encrypted data training**: [Train linear models](../built-in-models/training.md) or [fine-tune LLMs](../llm/lora_training.md) directly on encrypted data to maintain privacy.
9
9
-**Encrypted data pre-processing**: [Pre-process encrypted data](../built-in-models/encrypted_dataframe.md) using a DataFrame paradigm.
10
10
11
11
## Key features
12
12
13
+
-**Model inference on encrypted data**: Concrete ML converts models such as decision trees, LLMs, neural networks, etc.. to predict on encrypted data. Those models can be trained either on clear data or on encrypted data.
14
+
13
15
-**Training on encrypted data**: FHE is an encryption technique that allows computing directly on encrypted data, without needing to decrypt it. With FHE, you can build private-by-design applications without compromising on features. Learn more about FHE in [this introduction](https://www.zama.ai/post/tfhe-deep-dive-part-1) or join the [FHE.org](https://fhe.org) community.
14
16
15
17
-**Federated learning**: Training on encrypted data provides the highest level of privacy but is slower than training on clear data. Federated learning is an alternative approach, where data privacy can be ensured by using a trusted gradient aggregator, coupled with optional _differential privacy_ instead of encryption. Concrete ML can import all types of models: linear, tree-based and neural networks, that are trained using federated learning using the [`from_sklearn_model` function](../built-in-models/linear.md#pre-trained-models) and the [`compile_torch_model`](../deep-learning/torch_support.md) function.
Copy file name to clipboardExpand all lines: docs/getting-started/concepts.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,13 @@ This document explains the essential cryptographic terms and the important conce
4
4
5
5
Concrete ML is built on top of Concrete, which enables the conversion from NumPy programs into FHE circuits.
6
6
7
+
## Table of Contents
8
+
9
+
1.[Lifecycle of a Concrete ML model](#lifecycle-of-a-concrete-ml-model)
10
+
1.[Cryptography concepts](#cryptography-concepts)
11
+
1.[Ciphertext formats](#ciphertext-formats)
12
+
1.[Model accuracy considerations under FHE constraints](#model-accuracy-considerations-under-fhe-constraints)
13
+
7
14
## Lifecycle of a Concrete ML model
8
15
9
16
With Concrete ML, you can train a model on clear or encrypted data, then deploy it to predict on encrypted inputs. During deployment, data can be pre-processed while being encrypted. Therefore, data stay encrypted during the entire lifecycle of the machine learning model, with some limitations.
@@ -39,6 +46,8 @@ You can find examples of the model development workflow [here](../tutorials/ml_e
39
46
- A private encryption key to encrypt/decrypt their data and results
40
47
- A public evaluation key for the model's FHE evaluation on the server.
41
48
49
+
1.**Ciphertext formats** The server-side application can be configured to accept different types of ciphertexts from the client, depending on the type of application. See [Ciphertext formats](#ciphertext-formats) for more details.
50
+
42
51
You can find an example of the model deployment workflow [here](../advanced_examples/ClientServer.ipynb).
43
52
44
53
## Cryptography concepts
@@ -59,8 +68,30 @@ Concrete ML and Concrete abstract the details of the underlying cryptography sch
59
68
60
69
-**Programmable Boostrapping (PBS)** : Programmable Bootstrapping enables the homomorphic evaluation of any function of a ciphertext, with a controlled level of noise. Learn more about PBS in [this paper](https://eprint.iacr.org/2021/091).
61
70
71
+
-**Ciphertext formats**: To represent encrypted values, Concrete ML offers two options: the default Concrete ciphertext format, which is supported by all ML models and highly optimized for performance, or the block-based TFHE-rs radix format, which supports larger values, is forward-compatible, and suitable for Blockchain applications, but is limited to certain types of ML models.
72
+
62
73
For a deeper understanding of the cryptography behind the Concrete stack, refer to the [whitepaper on TFHE and Programmable Boostrapping](https://whitepaper.zama.ai/) or [this series of blogs](https://www.zama.ai/post/tfhe-deep-dive-part-1).
63
74
75
+
## Ciphertext formats
76
+
77
+
Two different types of ciphertexts are usable by Concrete ML for model input/outputs.
78
+
79
+
1._Concrete_ LWE ciphertexts (default):
80
+
81
+
By default, Concrete ML uses Concrete LWE ciphertexts with crypto-system parameters that are tailored to each ML model. These parameters may vary between different versions of Concrete ML. Thus, the encryption crypto-parameters may change at any point. Some implications are:
82
+
83
+
- Typically, a server-side application provides the client with its encryption cryptographic parameters.
84
+
- When the application is updated, the client downloads the new cryptographic parameters.
85
+
- Ciphertexts encrypted with a set of cryptographic parameters can not be re-used for a model compiled with different cryptographic parameters
86
+
87
+
2._TFHE-rs radix_ ciphertexts:
88
+
89
+
Concrete ML also supports \_TFHE-rs radix _ ciphertexts, which rely on a universal and forward-compatible parameter set. Therefore:
90
+
In this setting, a conversion layer is added to the ML model, potentially resulting in a 4–5× latency overhead.
91
+
92
+
- Ciphertexts encrypted with the universal cryptographic parameters can be used at any point in the future with any ML model.
93
+
- In this setting, a conversion layer is added to the ML model. This conversion may imply a 4-5x slowdown for model latency.
94
+
64
95
## Model accuracy considerations under FHE constraints
65
96
66
97
FHE requires all inputs, constants, and intermediate values to be integers of maximum 16 bits. To make machine learning models compatible with FHE, Concrete ML implements some techniques with accuracy considerations:
Copy file name to clipboardExpand all lines: docs/guides/client_server.md
+38-1Lines changed: 38 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ import numpy as np
62
62
fhe_directory ='/tmp/fhe_client_server_files/'
63
63
64
64
# Initialize the Decision Tree model
65
-
model = DecisionTreeClassifier()
65
+
model = DecisionTreeClassifier(n_bits=8)
66
66
67
67
# Generate some random data for training
68
68
X = np.random.rand(100, 20)
@@ -102,6 +102,43 @@ result = client.deserialize_decrypt_dequantize(encrypted_result)
102
102
103
103
These objects are serialized into bytes to streamline the data transfer between the client and server.
104
104
105
+
#### Ciphertext formats and keys
106
+
107
+
Two types of ciphertext formats are [available in Concrete ML](../getting-started/concepts.md#ciphertext-formats) and both are available for deployment. To use the _TFHE-rs radix_ format, pass the `ciphertext_format` option to the compilation call as follows:
108
+
109
+
<!--pytest-codeblocks:cont-->
110
+
111
+
```python
112
+
from concrete.ml.common.utils import CiphertextFormat
result = client.deserialize_decrypt_dequantize(encrypted_result[0])
138
+
```
139
+
140
+
In the example above, a second evaluation key is obtained in the `tfhers_evaluation_keys` variable. This key can be loaded by TFHE-rs Rust programs to perform further computation on the model output ciphertexts.
141
+
105
142
## Serving
106
143
107
144
The client-side deployment of a secured inference machine learning model is illustrated as follows:
When compiling a model for GPU, the model is assigned GPU-specific crypto-system parameters. These parameters are more constrained than the CPU-specific ones.
@@ -29,6 +29,10 @@ on a desktop CPU.
29
29
30
30
## Prerequisites
31
31
32
+
### Built-in models and deep NNs
33
+
34
+
This section pertains to models that are compiled using the `sklearn`-style built-in model classes or that are compiled using `compile_torch_model` or `compile_brevitas_qat_model`.
35
+
32
36
To use the CUDA-enabled backend, install the GPU-enabled Concrete compiler:
33
37
34
38
```bash
@@ -65,3 +69,12 @@ To compile a model for CUDA, simply supply the `device='cuda'` argument to its c
65
69
66
70
- For built-in models, use `.compile` function.
67
71
- For custom models, use either`compile_torch_model` or `compile_brevitas_qat_model`.
72
+
73
+
## LLMs
74
+
75
+
This section pertains to models that are compiled with `HybridFHEModel`.
76
+
77
+
The models compiled as described in [the LLM section](../llm/inference.md) will
78
+
use GPU acceleration if a GPU is available on the machine where the models
79
+
are executed. No specific compilation configuration is required to enable GPU
0 commit comments