From f324816e841610a6960a35aadb26ac3e5ba97775 Mon Sep 17 00:00:00 2001 From: Quentin Bourgerie Date: Wed, 27 Nov 2024 17:30:57 +0100 Subject: [PATCH] docs(frontend-python): Update API documentation --- .github/workflows/scripts/make_apidocs.sh | 4 +- docs/dev/api/README.md | 58 +- .../concrete.compiler.client_parameters.md | 238 ------ .../api/concrete.compiler.client_support.md | 196 ----- .../concrete.compiler.compilation_context.md | 49 +- .../concrete.compiler.compilation_feedback.md | 124 +-- .../concrete.compiler.compilation_options.md | 723 ------------------ .../api/concrete.compiler.evaluation_keys.md | 90 --- docs/dev/api/concrete.compiler.key_set.md | 141 ---- .../api/concrete.compiler.key_set_cache.md | 75 -- .../api/concrete.compiler.lambda_argument.md | 449 ----------- ...ete.compiler.library_compilation_result.md | 71 -- .../api/concrete.compiler.library_lambda.md | 42 - .../api/concrete.compiler.library_support.md | 360 --------- .../api/concrete.compiler.lwe_secret_key.md | 199 ----- docs/dev/api/concrete.compiler.md | 66 +- docs/dev/api/concrete.compiler.parameter.md | 32 - .../api/concrete.compiler.public_arguments.md | 109 --- .../api/concrete.compiler.public_result.md | 119 --- .../api/concrete.compiler.server_circuit.md | 106 --- .../api/concrete.compiler.server_program.md | 98 --- ...rete.compiler.simulated_value_decrypter.md | 76 -- ...crete.compiler.simulated_value_exporter.md | 105 --- docs/dev/api/concrete.compiler.tfhers_int.md | 199 +---- docs/dev/api/concrete.compiler.value.md | 85 -- .../api/concrete.compiler.value_decrypter.md | 80 -- .../api/concrete.compiler.value_exporter.md | 106 --- docs/dev/api/concrete.compiler.wrapper.md | 82 -- .../api/concrete.fhe.compilation.circuit.md | 28 +- .../api/concrete.fhe.compilation.client.md | 84 +- .../concrete.fhe.compilation.composition.md | 2 +- .../concrete.fhe.compilation.configuration.md | 266 ------- ...oncrete.fhe.compilation.evaluation_keys.md | 44 ++ docs/dev/api/concrete.fhe.compilation.keys.md | 40 +- docs/dev/api/concrete.fhe.compilation.md | 1 + .../api/concrete.fhe.compilation.module.md | 34 +- ...oncrete.fhe.compilation.module_compiler.md | 2 +- .../api/concrete.fhe.compilation.server.md | 138 ++-- .../dev/api/concrete.fhe.compilation.specs.md | 2 +- .../api/concrete.fhe.compilation.status.md | 2 +- .../dev/api/concrete.fhe.compilation.utils.md | 8 +- .../dev/api/concrete.fhe.compilation.value.md | 33 +- .../api/concrete.fhe.compilation.wiring.md | 4 +- docs/dev/api/concrete.fhe.extensions.tag.md | 2 +- docs/dev/api/concrete.fhe.mlir.context.md | 10 +- docs/dev/api/concrete.fhe.mlir.converter.md | 130 ++-- docs/dev/api/concrete.fhe.mlir.utils.md | 2 +- .../api/concrete.fhe.representation.graph.md | 2 +- docs/dev/api/concrete.fhe.tfhers.bridge.md | 26 +- docs/dev/api/concrete.fhe.tfhers.dtypes.md | 2 +- docs/dev/api/concrete.fhe.tfhers.md | 30 + docs/dev/api/concrete.fhe.tracing.tracer.md | 8 +- docs/dev/api/concrete.fhe.version.md | 4 +- 53 files changed, 451 insertions(+), 4535 deletions(-) delete mode 100644 docs/dev/api/concrete.compiler.client_parameters.md delete mode 100644 docs/dev/api/concrete.compiler.client_support.md delete mode 100644 docs/dev/api/concrete.compiler.compilation_options.md delete mode 100644 docs/dev/api/concrete.compiler.evaluation_keys.md delete mode 100644 docs/dev/api/concrete.compiler.key_set.md delete mode 100644 docs/dev/api/concrete.compiler.key_set_cache.md delete mode 100644 docs/dev/api/concrete.compiler.lambda_argument.md delete mode 100644 docs/dev/api/concrete.compiler.library_compilation_result.md delete mode 100644 docs/dev/api/concrete.compiler.library_lambda.md delete mode 100644 docs/dev/api/concrete.compiler.library_support.md delete mode 100644 docs/dev/api/concrete.compiler.lwe_secret_key.md delete mode 100644 docs/dev/api/concrete.compiler.parameter.md delete mode 100644 docs/dev/api/concrete.compiler.public_arguments.md delete mode 100644 docs/dev/api/concrete.compiler.public_result.md delete mode 100644 docs/dev/api/concrete.compiler.server_circuit.md delete mode 100644 docs/dev/api/concrete.compiler.server_program.md delete mode 100644 docs/dev/api/concrete.compiler.simulated_value_decrypter.md delete mode 100644 docs/dev/api/concrete.compiler.simulated_value_exporter.md delete mode 100644 docs/dev/api/concrete.compiler.value.md delete mode 100644 docs/dev/api/concrete.compiler.value_decrypter.md delete mode 100644 docs/dev/api/concrete.compiler.value_exporter.md delete mode 100644 docs/dev/api/concrete.compiler.wrapper.md delete mode 100644 docs/dev/api/concrete.fhe.compilation.configuration.md create mode 100644 docs/dev/api/concrete.fhe.compilation.evaluation_keys.md diff --git a/.github/workflows/scripts/make_apidocs.sh b/.github/workflows/scripts/make_apidocs.sh index 053656261f..7332d3e4f6 100755 --- a/.github/workflows/scripts/make_apidocs.sh +++ b/.github/workflows/scripts/make_apidocs.sh @@ -31,8 +31,8 @@ fi # Fixing the path issues, to point on files in GitHub WHICH_PYTHON_VERSION=$(${PYTHON} --version | cut -f 2 -d " " | cut -f 1-2 -d ".") -sed $SED_OPT -e "s@../../.venvtrash/lib.*/python$WHICH_PYTHON_VERSION/site-packages/@../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/@g" docs/dev/api/concrete.compiler*.md docs/dev/api/concrete.lang*.md -sed $SED_OPT -e "s@../../.venvtrash/lib.*/python$WHICH_PYTHON_VERSION/site-packages/@../../frontends/concrete-python/@g" docs/dev/api/concrete.fhe*.md +sed $SED_OPT -e "s@../../.venv-docs/lib.*/python$WHICH_PYTHON_VERSION/site-packages/@../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/@g" docs/dev/api/concrete.compiler*.md docs/dev/api/concrete.lang*.md +sed $SED_OPT -e "s@../../.venv-docs/lib.*/python$WHICH_PYTHON_VERSION/site-packages/@../../frontends/concrete-python/@g" docs/dev/api/concrete.fhe*.md # Fixing the links in README.md, which fails (missing .'s for some reason): remove the #headers sed $SED_OPT -e "s@.md#module-.*)@.md)@g" docs/dev/api/README.md diff --git a/docs/dev/api/README.md b/docs/dev/api/README.md index a00f552548..11a36aaabc 100644 --- a/docs/dev/api/README.md +++ b/docs/dev/api/README.md @@ -5,32 +5,10 @@ ## Modules - [`concrete.compiler`](./concrete.compiler.md): Compiler submodule. -- [`concrete.compiler.client_parameters`](./concrete.compiler.client_parameters.md): Client parameters. -- [`concrete.compiler.client_support`](./concrete.compiler.client_support.md): Client support. - [`concrete.compiler.compilation_context`](./concrete.compiler.compilation_context.md): CompilationContext. - [`concrete.compiler.compilation_feedback`](./concrete.compiler.compilation_feedback.md): Compilation feedback. -- [`concrete.compiler.compilation_options`](./concrete.compiler.compilation_options.md): CompilationOptions. -- [`concrete.compiler.evaluation_keys`](./concrete.compiler.evaluation_keys.md): EvaluationKeys. -- [`concrete.compiler.key_set`](./concrete.compiler.key_set.md): KeySet. -- [`concrete.compiler.key_set_cache`](./concrete.compiler.key_set_cache.md): KeySetCache. -- [`concrete.compiler.lambda_argument`](./concrete.compiler.lambda_argument.md): LambdaArgument. -- [`concrete.compiler.library_compilation_result`](./concrete.compiler.library_compilation_result.md): LibraryCompilationResult. -- [`concrete.compiler.library_lambda`](./concrete.compiler.library_lambda.md): LibraryLambda. -- [`concrete.compiler.library_support`](./concrete.compiler.library_support.md): LibrarySupport. -- [`concrete.compiler.lwe_secret_key`](./concrete.compiler.lwe_secret_key.md): LweSecretKey. -- [`concrete.compiler.parameter`](./concrete.compiler.parameter.md): Parameter. -- [`concrete.compiler.public_arguments`](./concrete.compiler.public_arguments.md): PublicArguments. -- [`concrete.compiler.public_result`](./concrete.compiler.public_result.md): PublicResult. -- [`concrete.compiler.server_circuit`](./concrete.compiler.server_circuit.md): ServerCircuit. -- [`concrete.compiler.server_program`](./concrete.compiler.server_program.md): ServerProgram. -- [`concrete.compiler.simulated_value_decrypter`](./concrete.compiler.simulated_value_decrypter.md): SimulatedValueDecrypter. -- [`concrete.compiler.simulated_value_exporter`](./concrete.compiler.simulated_value_exporter.md): SimulatedValueExporter. - [`concrete.compiler.tfhers_int`](./concrete.compiler.tfhers_int.md): Import and export TFHErs integers into Concrete. - [`concrete.compiler.utils`](./concrete.compiler.utils.md): Common utils for the compiler submodule. -- [`concrete.compiler.value`](./concrete.compiler.value.md): Value. -- [`concrete.compiler.value_decrypter`](./concrete.compiler.value_decrypter.md): ValueDecrypter. -- [`concrete.compiler.value_exporter`](./concrete.compiler.value_exporter.md): ValueExporter. -- [`concrete.compiler.wrapper`](./concrete.compiler.wrapper.md): Wrapper for native Cpp objects. - [`concrete.fhe`](./concrete.fhe.md): Concrete. - [`concrete.fhe.compilation`](./concrete.fhe.compilation.md): Glue the compilation process together. - [`concrete.fhe.compilation.artifacts`](./concrete.fhe.compilation.artifacts.md): Declaration of `DebugArtifacts` class. @@ -40,6 +18,7 @@ - [`concrete.fhe.compilation.composition`](./concrete.fhe.compilation.composition.md): Declaration of classes related to composition. - [`concrete.fhe.compilation.configuration`](./concrete.fhe.compilation.configuration.md): Declaration of `Configuration` class. - [`concrete.fhe.compilation.decorators`](./concrete.fhe.compilation.decorators.md): Declaration of `circuit` and `compiler` decorators. +- [`concrete.fhe.compilation.evaluation_keys`](./concrete.fhe.compilation.evaluation_keys.md): Declaration of `EvaluationKeys`. - [`concrete.fhe.compilation.keys`](./concrete.fhe.compilation.keys.md): Declaration of `Keys` class. - [`concrete.fhe.compilation.module`](./concrete.fhe.compilation.module.md): Declaration of `FheModule` classes. - [`concrete.fhe.compilation.module_compiler`](./concrete.fhe.compilation.module_compiler.md): Declaration of `MultiCompiler` class. @@ -101,7 +80,7 @@ - [`concrete.fhe.values.scalar`](./concrete.fhe.values.scalar.md): Declaration of `ClearScalar` and `EncryptedScalar` wrappers. - [`concrete.fhe.values.tensor`](./concrete.fhe.values.tensor.md): Declaration of `ClearTensor` and `EncryptedTensor` wrappers. - [`concrete.fhe.values.value_description`](./concrete.fhe.values.value_description.md): Declaration of `ValueDescription` class. -- [`concrete.fhe.version`](./concrete.fhe.version.md) +- [`concrete.fhe.version`](./concrete.fhe.version.md): Version of the project, which is updated automatically by the CI right before releasing. - [`concrete.lang`](./concrete.lang.md): Concretelang python module - [`concrete.lang.dialects`](./concrete.lang.dialects.md) - [`concrete.lang.dialects.fhe`](./concrete.lang.dialects.fhe.md): FHE dialect module @@ -110,34 +89,9 @@ ## Classes -- [`client_parameters.ClientParameters`](./concrete.compiler.client_parameters.md): ClientParameters are public parameters used for key generation. -- [`client_support.ClientSupport`](./concrete.compiler.client_support.md): Client interface for doing key generation and encryption. -- [`compilation_context.CompilationContext`](./concrete.compiler.compilation_context.md): Support class for compilation context. -- [`compilation_feedback.CircuitCompilationFeedback`](./concrete.compiler.compilation_feedback.md): CircuitCompilationFeedback is a set of hint computed by the compiler engine for a circuit. -- [`compilation_feedback.ProgramCompilationFeedback`](./concrete.compiler.compilation_feedback.md): CompilationFeedback is a set of hint computed by the compiler engine. -- [`compilation_options.CompilationOptions`](./concrete.compiler.compilation_options.md): CompilationOptions holds different flags and options of the compilation process. -- [`evaluation_keys.EvaluationKeys`](./concrete.compiler.evaluation_keys.md): EvaluationKeys required for execution. -- [`key_set.KeySet`](./concrete.compiler.key_set.md): KeySet stores the different keys required for an encrypted computation. -- [`key_set_cache.KeySetCache`](./concrete.compiler.key_set_cache.md): KeySetCache is a cache for KeySet to avoid generating similar keys multiple times. -- [`lambda_argument.LambdaArgument`](./concrete.compiler.lambda_argument.md): LambdaArgument holds scalar or tensor values. -- [`library_compilation_result.LibraryCompilationResult`](./concrete.compiler.library_compilation_result.md): LibraryCompilationResult holds the result of the library compilation. -- [`library_lambda.LibraryLambda`](./concrete.compiler.library_lambda.md): LibraryLambda reference a compiled library and can be ran using LibrarySupport. -- [`library_support.LibrarySupport`](./concrete.compiler.library_support.md): Support class for library compilation and execution. -- [`lwe_secret_key.LweSecretKey`](./concrete.compiler.lwe_secret_key.md): An LweSecretKey. -- [`lwe_secret_key.LweSecretKeyParam`](./concrete.compiler.lwe_secret_key.md): LWE Secret Key Parameters -- [`parameter.Parameter`](./concrete.compiler.parameter.md): An FHE parameter. -- [`public_arguments.PublicArguments`](./concrete.compiler.public_arguments.md): PublicArguments holds encrypted and plain arguments, as well as public materials. -- [`public_result.PublicResult`](./concrete.compiler.public_result.md): PublicResult holds the result of an encrypted execution and can be decrypted using ClientSupport. -- [`server_circuit.ServerCircuit`](./concrete.compiler.server_circuit.md): ServerCircuit references a circuit that can be called for execution and simulation. -- [`server_program.ServerProgram`](./concrete.compiler.server_program.md): ServerProgram references compiled circuit objects. -- [`simulated_value_decrypter.SimulatedValueDecrypter`](./concrete.compiler.simulated_value_decrypter.md): A helper class to decrypt `Value`s. -- [`simulated_value_exporter.SimulatedValueExporter`](./concrete.compiler.simulated_value_exporter.md): A helper class to create `Value`s. +- [`compilation_context.CompilationContext`](./concrete.compiler.compilation_context.md): Compilation context. +- [`compilation_feedback.MoreCircuitCompilationFeedback`](./concrete.compiler.compilation_feedback.md): Helper class for compilation feedback. - [`tfhers_int.TfhersExporter`](./concrete.compiler.tfhers_int.md): A helper class to import and export TFHErs big integers. -- [`tfhers_int.TfhersFheIntDescription`](./concrete.compiler.tfhers_int.md): A helper class to create `TfhersFheIntDescription`s. -- [`value.Value`](./concrete.compiler.value.md): An encrypted/clear value which can be scalar/tensor. -- [`value_decrypter.ValueDecrypter`](./concrete.compiler.value_decrypter.md): A helper class to decrypt `Value`s. -- [`value_exporter.ValueExporter`](./concrete.compiler.value_exporter.md): A helper class to create `Value`s. -- [`wrapper.WrapperCpp`](./concrete.compiler.wrapper.md): Wrapper base class for native Cpp objects. - [`artifacts.DebugArtifacts`](./concrete.fhe.compilation.artifacts.md): DebugArtifacts class, to export information about the compilation process for single function. - [`artifacts.DebugManager`](./concrete.fhe.compilation.artifacts.md): A debug manager, allowing streamlined debugging. - [`artifacts.FunctionDebugArtifacts`](./concrete.fhe.compilation.artifacts.md): An object containing debug artifacts for a certain function in an fhe module. @@ -150,6 +104,7 @@ - [`composition.CompositionRule`](./concrete.fhe.compilation.composition.md): A raw composition rule. - [`configuration.ApproximateRoundingConfig`](./concrete.fhe.compilation.configuration.md): Controls the behavior of approximate rounding. - [`decorators.Compilable`](./concrete.fhe.compilation.decorators.md): Compilable class, to wrap a function and provide methods to trace and compile it. +- [`evaluation_keys.EvaluationKeys`](./concrete.fhe.compilation.evaluation_keys.md): EvaluationKeys required for execution. - [`keys.Keys`](./concrete.fhe.compilation.keys.md): Keys class, to manage generate/reuse keys. - [`module.ExecutionRt`](./concrete.fhe.compilation.module.md): Runtime object class for execution. - [`module.FheFunction`](./concrete.fhe.compilation.module.md): Fhe function class, allowing to run or simulate one function of an fhe module. @@ -161,7 +116,7 @@ - [`specs.ClientSpecs`](./concrete.fhe.compilation.specs.md): ClientSpecs class, to create Client objects. - [`status.EncryptionStatus`](./concrete.fhe.compilation.status.md): EncryptionStatus enum, to represent encryption status of parameters. - [`utils.Lazy`](./concrete.fhe.compilation.utils.md): A lazyly initialized value. -- [`value.Value`](./concrete.fhe.compilation.value.md): Value class, to store scalar or tensor values which can be encrypted or clear. +- [`value.Value`](./concrete.fhe.compilation.value.md): A public value object that can be sent between client and server. - [`wiring.AllComposable`](./concrete.fhe.compilation.wiring.md): Composition policy that allows to forward any output of the module to any of its input. - [`wiring.AllInputs`](./concrete.fhe.compilation.wiring.md): All the encrypted inputs of a given function of a module. - [`wiring.AllOutputs`](./concrete.fhe.compilation.wiring.md): All the encrypted outputs of a given function of a module. @@ -399,6 +354,7 @@ - [`utils.flood_replace_none_values`](./concrete.fhe.mlir.utils.md): Use flooding algorithm to replace `None` values. - [`utils.format_constant`](./concrete.fhe.representation.utils.md): Get the textual representation of a constant. - [`utils.format_indexing_element`](./concrete.fhe.representation.utils.md): Format an indexing element. +- [`tfhers.get_type_from_params`](./concrete.fhe.tfhers.md): Get a TFHE-rs integer type from TFHE-rs parameters in JSON format. - [`bridge.new_bridge`](./concrete.fhe.tfhers.bridge.md): Create a TFHErs bridge from a circuit. - [`tracing.from_native`](./concrete.fhe.tfhers.tracing.md): Convert a Concrete integer to the tfhers representation. - [`tracing.to_native`](./concrete.fhe.tfhers.tracing.md): Convert a tfhers integer to the Concrete representation. diff --git a/docs/dev/api/concrete.compiler.client_parameters.md b/docs/dev/api/concrete.compiler.client_parameters.md deleted file mode 100644 index 1efa2ba1db..0000000000 --- a/docs/dev/api/concrete.compiler.client_parameters.md +++ /dev/null @@ -1,238 +0,0 @@ - - - - -# module `concrete.compiler.client_parameters` -Client parameters. - - - ---- - - - -## class `ClientParameters` -ClientParameters are public parameters used for key generation. - -It's a compilation artifact that describes which and how public and private keys should be generated, and used to encrypt arguments of the compiled function. - - - -### method `__init__` - -```python -__init__(client_parameters: ClientParameters) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `client_parameters` (_ClientParameters): object to wrap - - - -**Raises:** - - - `TypeError`: if client_parameters is not of type _ClientParameters - - - - ---- - - - -### method `deserialize` - -```python -deserialize(serialized_params: bytes) → ClientParameters -``` - -Unserialize ClientParameters from bytes of serialized_params. - - - -**Args:** - - - `serialized_params` (bytes): previously serialized ClientParameters - - - -**Raises:** - - - `TypeError`: if serialized_params is not of type bytes - - - -**Returns:** - - - `ClientParameters`: deserialized object - ---- - - - -### method `function_list` - -```python -function_list() → List[str] -``` - -Return the list of function names. - - - -**Returns:** - - - `List[str]`: list of the names of the functions. - ---- - - - -### method `input_keyid_at` - -```python -input_keyid_at(input_idx: int, circuit_name: str = '') → int -``` - -Get the keyid of a selected encrypted input in a given circuit. - - - -**Args:** - - - `input_idx` (int): index of the input in the circuit. - - `circuit_name` (str): name of the circuit containing the desired input. - - - -**Raises:** - - - `TypeError`: if arguments aren't of expected types - - - -**Returns:** - - - `int`: keyid - ---- - - - -### method `input_signs` - -```python -input_signs() → List[bool] -``` - -Return the sign information of inputs. - - - -**Returns:** - - - `List[bool]`: list of booleans to indicate whether the inputs are signed or not - ---- - - - -### method `input_variance_at` - -```python -input_variance_at(input_idx: int, circuit_name: str) → float -``` - -Get the variance of a selected encrypted input in a given circuit. - - - -**Args:** - - - `input_idx` (int): index of the input in the circuit. - - `circuit_name` (str): name of the circuit containing the desired input. - - - -**Raises:** - - - `TypeError`: if arguments aren't of expected types - - - -**Returns:** - - - `float`: variance - ---- - - - -### method `lwe_secret_key_param` - -```python -lwe_secret_key_param(key_id: int) → LweSecretKeyParam -``` - -Get the parameters of a selected LWE secret key. - - - -**Args:** - - - `key_id` (int): keyid to get parameters from - - - -**Raises:** - - - `TypeError`: if arguments aren't of expected types - - - -**Returns:** - - - `LweSecretKeyParam`: LWE secret key parameters - ---- - - - -### method `output_signs` - -```python -output_signs() → List[bool] -``` - -Return the sign information of outputs. - - - -**Returns:** - - - `List[bool]`: list of booleans to indicate whether the outputs are signed or not - ---- - - - -### method `serialize` - -```python -serialize() → bytes -``` - -Serialize the ClientParameters. - - - -**Returns:** - - - `bytes`: serialized object - - diff --git a/docs/dev/api/concrete.compiler.client_support.md b/docs/dev/api/concrete.compiler.client_support.md deleted file mode 100644 index abab746f1d..0000000000 --- a/docs/dev/api/concrete.compiler.client_support.md +++ /dev/null @@ -1,196 +0,0 @@ - - - - -# module `concrete.compiler.client_support` -Client support. - -**Global Variables** ---------------- -- **ACCEPTED_INTS** -- **ACCEPTED_NUMPY_UINTS** -- **ACCEPTED_TYPES** - - ---- - - - -## class `ClientSupport` -Client interface for doing key generation and encryption. - -It provides features that are needed on the client side: -- Generation of public and private keys required for the encrypted computation -- Encryption and preparation of public arguments, used later as input to the computation -- Decryption of public result returned after execution - - - -### method `__init__` - -```python -__init__(client_support: ClientSupport) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `client_support` (_ClientSupport): object to wrap - - - -**Raises:** - - - `TypeError`: if client_support is not of type _ClientSupport - - - - ---- - - - -### method `decrypt_result` - -```python -decrypt_result( - client_parameters: ClientParameters, - keyset: KeySet, - public_result: PublicResult, - circuit_name: str -) → Union[int, ndarray] -``` - -Decrypt a public result using the keyset. - - - -**Args:** - - - `client_parameters` (ClientParameters): client parameters for decryption - - `keyset` (KeySet): keyset used for decryption - - `public_result` (PublicResult): public result to decrypt - - `circuit_name` (str): name of the circuit for which to decrypt - - - -**Raises:** - - - `TypeError`: if keyset is not of type KeySet - - `TypeError`: if public_result is not of type PublicResult - - `TypeError`: if circuit_name is not of type str - - `RuntimeError`: if the result is of an unknown type - - - -**Returns:** - - - `Union[int, np.ndarray]`: plain result - ---- - - - -### method `encrypt_arguments` - -```python -encrypt_arguments( - client_parameters: ClientParameters, - keyset: KeySet, - args: List[Union[int, ndarray]], - circuit_name: str -) → PublicArguments -``` - -Prepare arguments for encrypted computation. - -Pack public arguments by encrypting the ones that requires encryption, and leaving the rest as plain. It also pack public materials (public keys) that are required during the computation. - - - -**Args:** - - - `client_parameters` (ClientParameters): client parameters specification - - `keyset` (KeySet): keyset used to encrypt arguments that require encryption - - `args` (List[Union[int, np.ndarray]]): list of scalar or tensor arguments - - `circuit_name` (str): the name of the circuit for which to encrypt - - - -**Raises:** - - - `TypeError`: if client_parameters is not of type ClientParameters - - `TypeError`: if keyset is not of type KeySet - - `TypeError`: if circuit_name is not of type str - - - -**Returns:** - - - `PublicArguments`: public arguments for execution - ---- - - - -### method `key_set` - -```python -key_set( - client_parameters: ClientParameters, - keyset_cache: Optional[KeySetCache] = None, - secret_seed: Optional[int] = None, - encryption_seed: Optional[int] = None, - initial_lwe_secret_keys: Optional[Dict[int, LweSecretKey]] = None -) → KeySet -``` - -Generate a key set according to the client parameters. - -If the cache is set, and include equivalent keys as specified by the client parameters, the keyset is loaded, otherwise, a new keyset is generated and saved in the cache. If keygen is required, it will first initialize the secret keys provided, if any. - - - -**Args:** - - - `client_parameters` (ClientParameters): client parameters specification - - `keyset_cache` (Optional[KeySetCache], optional): keyset cache. Defaults to None. - - `secret_seed` (Optional[int]): secret seed, must be a positive 128 bits integer - - `encryption_seed` (Optional[int]): encryption seed, must be a positive 128 bits integer - - `initial_lwe_secret_keys` (Optional[Dict[int, LweSecretKey]]): keys to init the keyset with before keygen. It maps keyid to secret key - - - -**Raises:** - - - `TypeError`: if client_parameters is not of type ClientParameters - - `TypeError`: if keyset_cache is not of type KeySetCache - - `AssertionError`: if seed components is not uint64 - - - -**Returns:** - - - `KeySet`: generated or loaded keyset - ---- - - - -### method `new` - -```python -new() → ClientSupport -``` - -Build a ClientSupport. - - - -**Returns:** - ClientSupport - - diff --git a/docs/dev/api/concrete.compiler.compilation_context.md b/docs/dev/api/concrete.compiler.compilation_context.md index 184c624518..9ec81c3ca4 100644 --- a/docs/dev/api/concrete.compiler.compilation_context.md +++ b/docs/dev/api/concrete.compiler.compilation_context.md @@ -11,41 +11,17 @@ CompilationContext holds the MLIR Context supposed to be used during IR generati --- - + ## class `CompilationContext` -Support class for compilation context. - -CompilationContext is meant to outlive mlir_context(). Do not use the mlir_context after deleting the CompilationContext. - - - -### method `__init__` - -```python -__init__(compilation_context: CompilationContext) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `compilation_context` (_CompilationContext): object to wrap - - - -**Raises:** - - - `TypeError`: if compilation_context is not of type _CompilationContext +Compilation context. --- - + ### method `mlir_context` @@ -53,19 +29,11 @@ Wrap the native Cpp object. mlir_context() → Context ``` -Get the MLIR context used by the compilation context. - -The Compilation Context should outlive the mlir_context. - - - -**Returns:** - - - `MlirContext`: MLIR context of the compilation context +Returns the associated mlir context. --- - + ### method `new` @@ -73,11 +41,6 @@ The Compilation Context should outlive the mlir_context. new() → CompilationContext ``` -Build a CompilationContext. - - - -**Returns:** - CompilationContext +Creates a new CompilationContext. diff --git a/docs/dev/api/concrete.compiler.compilation_feedback.md b/docs/dev/api/concrete.compiler.compilation_feedback.md index 3b6afbebfc..6cccb1c5e9 100644 --- a/docs/dev/api/concrete.compiler.compilation_feedback.md +++ b/docs/dev/api/concrete.compiler.compilation_feedback.md @@ -11,7 +11,7 @@ Compilation feedback. --- - + ## function `tag_from_location` @@ -24,44 +24,25 @@ Extract tag of the operation from its location. --- - - -## class `CircuitCompilationFeedback` -CircuitCompilationFeedback is a set of hint computed by the compiler engine for a circuit. - - - -### method `__init__` - -```python -__init__(circuit_compilation_feedback: CircuitCompilationFeedback) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `circuit_compilation_feeback` (_CircuitCompilationFeedback): object to wrap - - + -**Raises:** - - - `TypeError`: if circuit_compilation_feedback is not of type _CircuitCompilationFeedback +## class `MoreCircuitCompilationFeedback` +Helper class for compilation feedback. --- - + ### method `count` ```python -count(operations: Set[PrimitiveOperation]) → int +count( + circuit_feedback: CircuitCompilationFeedback, + operations: Set[PrimitiveOperation] +) → int ``` Count the amount of specified operations in the program. @@ -78,16 +59,17 @@ Count the amount of specified operations in the program. --- - + ### method `count_per_parameter` ```python count_per_parameter( + circuit_feedback: CircuitCompilationFeedback, operations: Set[PrimitiveOperation], key_types: Set[KeyType], - client_parameters: ClientParameters -) → Dict[Parameter, int] + program_info: ProgramInfo +) → Dict[ForwardRef('Parameter'), int] ``` Count the amount of specified operations in the program and group by parameters. @@ -99,7 +81,7 @@ Count the amount of specified operations in the program and group by parameters. key_types (Set[KeyType]): set of key types used to filter the statistics - client_parameters (ClientParameters): client parameters required for grouping by parameters + program_info (ProgramInfo): program info required for grouping by parameters @@ -108,12 +90,15 @@ Count the amount of specified operations in the program and group by parameters. --- - + ### method `count_per_tag` ```python -count_per_tag(operations: Set[PrimitiveOperation]) → Dict[str, int] +count_per_tag( + circuit_feedback: CircuitCompilationFeedback, + operations: Set[PrimitiveOperation] +) → Dict[str, int] ``` Count the amount of specified operations in the program and group by tags. @@ -130,16 +115,17 @@ Count the amount of specified operations in the program and group by tags. --- - + ### method `count_per_tag_per_parameter` ```python count_per_tag_per_parameter( + circuit_feedback: CircuitCompilationFeedback, operations: Set[PrimitiveOperation], key_types: Set[KeyType], - client_parameters: ClientParameters -) → Dict[str, Dict[Parameter, int]] + program_info: ProgramInfo +) → Dict[str, Dict[ForwardRef('Parameter'), int]] ``` Count the amount of specified operations in the program and group by tags and parameters. @@ -151,7 +137,7 @@ Count the amount of specified operations in the program and group by tags and pa key_types (Set[KeyType]): set of key types used to filter the statistics - client_parameters (ClientParameters): client parameters required for grouping by parameters + program_info (ProgramInfo): program info required for grouping by parameters @@ -159,65 +145,3 @@ Count the amount of specified operations in the program and group by tags and pa Dict[str, Dict[Parameter, int]]: number of specified operations per tag per parameter in the program ---- - - - -## class `ProgramCompilationFeedback` -CompilationFeedback is a set of hint computed by the compiler engine. - - - -### method `__init__` - -```python -__init__(program_compilation_feedback: ProgramCompilationFeedback) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `compilation_feeback` (_CompilationFeedback): object to wrap - - - -**Raises:** - - - `TypeError`: if program_compilation_feedback is not of type _CompilationFeedback - - - - ---- - - - -### method `circuit` - -```python -circuit(circuit_name: str) → CircuitCompilationFeedback -``` - -Returns the feedback for the circuit circuit_name. - - - -**Args:** - circuit_name (str): the name of the circuit. - - - -**Returns:** - CircuitCompilationFeedback: the feedback for the circuit. - - - -**Raises:** - - - `TypeError`: if the circuit_name is not a string - - `ValueError`: if there is no circuit with name circuit_name - - diff --git a/docs/dev/api/concrete.compiler.compilation_options.md b/docs/dev/api/concrete.compiler.compilation_options.md deleted file mode 100644 index cecdff2d22..0000000000 --- a/docs/dev/api/concrete.compiler.compilation_options.md +++ /dev/null @@ -1,723 +0,0 @@ - - - - -# module `concrete.compiler.compilation_options` -CompilationOptions. - - - ---- - - - -## class `CompilationOptions` -CompilationOptions holds different flags and options of the compilation process. - -It controls different parallelization flags, diagnostic verification, and also the name of entrypoint function. - - - -### method `__init__` - -```python -__init__(compilation_options: CompilationOptions) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `compilation_options` (_CompilationOptions): object to wrap - - - -**Raises:** - - - `TypeError`: if compilation_options is not of type _CompilationOptions - - - - ---- - - - -### method `add_composition` - -```python -add_composition(from_func: str, from_pos: int, to_func: str, to_pos: int) -``` - -Adds a composition rule. - - - -**Args:** - - - `from_func` (str): the name of the circuit the output comes from. - - `from_pos` (int): the return position of the output. - - `to_func` (str): the name of the circuit the input targets. - - `to_pos` (int): the argument position of the input. - - - -**Raises:** - - - `TypeError`: if the inputs do not have the proper type. - ---- - - - -### method `force_encoding` - -```python -force_encoding(encoding: Encoding) -``` - -Force the compiler to use a specific encoding. - - - -**Args:** - - - `encoding` (Encoding): the encoding to force the compiler to use - - - -**Raises:** - - - `TypeError`: if encoding is not of type Encoding - ---- - - - -### method `new` - -```python -new(backend=) → CompilationOptions -``` - -Build a CompilationOptions. - - - -**Args:** - - - `backend` (_Backend): backend to use. - - - -**Raises:** - - - `TypeError`: if function_name is not an str - - - -**Returns:** - CompilationOptions - ---- - - - -### method `set_all_v0_parameter` - -```python -set_all_v0_parameter( - glwe_dim: int, - log_poly_size: int, - n_small: int, - br_level: int, - br_log_base: int, - ks_level: int, - ks_log_base: int, - crt_decomp: List[int], - cbs_level: int, - cbs_log_base: int, - pks_level: int, - pks_log_base: int, - pks_input_lwe_dim: int, - pks_output_poly_size: int -) -``` - -Set all the V0 parameters. - - - -**Args:** - - - `glwe_dim` (int): GLWE dimension - - `log_poly_size` (int): log of polynomial size - - `n_small` (int): n - - `br_level` (int): bootstrap level - - `br_log_base` (int): bootstrap base log - - `ks_level` (int): keyswitch level - - `ks_log_base` (int): keyswitch base log - - `crt_decomp` (List[int]): CRT decomposition vector - - `cbs_level` (int): circuit bootstrap level - - `cbs_log_base` (int): circuit bootstrap base log - - `pks_level` (int): packing keyswitch level - - `pks_log_base` (int): packing keyswitch base log - - `pks_input_lwe_dim` (int): packing keyswitch input LWE dimension - - `pks_output_poly_size` (int): packing keyswitch output polynomial size - - - -**Raises:** - - - `TypeError`: if parameters are not of type int - ---- - - - -### method `set_auto_parallelize` - -```python -set_auto_parallelize(auto_parallelize: bool) -``` - -Set option for auto parallelization. - - - -**Args:** - - - `auto_parallelize` (bool): whether to turn it on or off - - - -**Raises:** - - - `TypeError`: if the value to set is not boolean - ---- - - - -### method `set_batch_tfhe_ops` - -```python -set_batch_tfhe_ops(batch_tfhe_ops: bool) -``` - -Set flag that triggers the batching of scalar TFHE operations. - - - -**Args:** - - - `batch_tfhe_ops` (bool): whether to batch tfhe ops. - - - -**Raises:** - - - `TypeError`: if the value to set is not bool - ---- - - - -### method `set_composable` - -```python -set_composable(composable: bool) -``` - -Set composable flag. - - - -**Args:** - - - `composable` (bool): the composable flag. - - - -**Raises:** - - - `TypeError`: if the inputs do not have the proper type. - ---- - - - -### method `set_compress_evaluation_keys` - -```python -set_compress_evaluation_keys(compress_evaluation_keys: bool) -``` - -Set option for compression of evaluation keys. - - - -**Args:** - - - `compress_evaluation_keys` (bool): whether to turn it on or off - - - -**Raises:** - - - `TypeError`: if the value to set is not boolean - ---- - - - -### method `set_compress_input_ciphertexts` - -```python -set_compress_input_ciphertexts(compress_input_ciphertexts: bool) -``` - -Set option for compression of input ciphertexts. - - - -**Args:** - - - `compress_input_ciphertexts` (bool): whether to turn it on or off - - - -**Raises:** - - - `TypeError`: if the value to set is not boolean - ---- - - - -### method `set_dataflow_parallelize` - -```python -set_dataflow_parallelize(dataflow_parallelize: bool) -``` - -Set option for dataflow parallelization. - - - -**Args:** - - - `dataflow_parallelize` (bool): whether to turn it on or off - - - -**Raises:** - - - `TypeError`: if the value to set is not boolean - ---- - - - -### method `set_display_optimizer_choice` - -```python -set_display_optimizer_choice(display: bool) -``` - -Set display flag of optimizer choices. - - - -**Args:** - - - `display` (bool): if true the compiler display optimizer choices - - - -**Raises:** - - - `TypeError`: if the value is not a bool - ---- - - - -### method `set_emit_gpu_ops` - -```python -set_emit_gpu_ops(emit_gpu_ops: bool) -``` - -Set flag that allows gpu ops to be emitted. - - - -**Args:** - - - `emit_gpu_ops` (bool): whether to emit gpu ops. - - - -**Raises:** - - - `TypeError`: if the value to set is not bool - ---- - - - -### method `set_enable_overflow_detection_in_simulation` - -```python -set_enable_overflow_detection_in_simulation(enable_overflow_detection: bool) -``` - -Enable or disable overflow detection during simulation. - - - -**Args:** - - - `enable_overflow_detection` (bool): flag to enable or disable overflow detection - - - -**Raises:** - - - `TypeError`: if the value to set is not bool - ---- - - - -### method `set_enable_tlu_fusing` - -```python -set_enable_tlu_fusing(enable_tlu_fusing: bool) -``` - -Enable or disable tlu fusing. - - - -**Args:** - - - `enable_tlu_fusing` (bool): flag to enable or disable tlu fusing - - - -**Raises:** - - - `TypeError`: if the value to set is not bool - ---- - - - -### method `set_funcname` - -```python -set_funcname(funcname: str) -``` - -Set entrypoint function name. - - - -**Args:** - - - `funcname` (str): name of the entrypoint function - - - -**Raises:** - - - `TypeError`: if the value to set is not str - ---- - - - -### method `set_global_p_error` - -```python -set_global_p_error(global_p_error: float) -``` - -Set global error probability for the full circuit. - - - -**Args:** - - - `global_p_error` (float): probability of error for the full circuit - - - -**Raises:** - - - `TypeError`: if the value to set is not float - - `ValueError`: if the value to set is not in interval ]0; 1] - ---- - - - -### method `set_loop_parallelize` - -```python -set_loop_parallelize(loop_parallelize: bool) -``` - -Set option for loop parallelization. - - - -**Args:** - - - `loop_parallelize` (bool): whether to turn it on or off - - - -**Raises:** - - - `TypeError`: if the value to set is not boolean - ---- - - - -### method `set_optimize_concrete` - -```python -set_optimize_concrete(optimize: bool) -``` - -Set flag to enable/disable optimization of concrete intermediate representation. - - - -**Args:** - - - `optimize` (bool): whether to turn it on or off - - - -**Raises:** - - - `TypeError`: if the value to set is not boolean - ---- - - - -### method `set_optimizer_multi_parameter_strategy` - -```python -set_optimizer_multi_parameter_strategy( - strategy: OptimizerMultiParameterStrategy -) -``` - -Set the strategy of the optimizer for multi-parameter. - - - -**Args:** - - - `strategy` (OptimizerMultiParameterStrategy): Use the specified optmizer multi-parameter strategy. - - - -**Raises:** - - - `TypeError`: if the value is not a OptimizerMultiParameterStrategy - ---- - - - -### method `set_optimizer_strategy` - -```python -set_optimizer_strategy(strategy: OptimizerStrategy) -``` - -Set the strategy of the optimizer. - - - -**Args:** - - - `strategy` (OptimizerStrategy): Use the specified optmizer strategy. - - - -**Raises:** - - - `TypeError`: if the value is not an OptimizerStrategy - ---- - - - -### method `set_p_error` - -```python -set_p_error(p_error: float) -``` - -Set error probability for shared by each pbs. - - - -**Args:** - - - `p_error` (float): probability of error for each lut - - - -**Raises:** - - - `TypeError`: if the value to set is not float - - `ValueError`: if the value to set is not in interval ]0; 1] - ---- - - - -### method `set_print_tlu_fusing` - -```python -set_print_tlu_fusing(print_tlu_fusing: bool) -``` - -Enable or disable printing tlu fusing. - - - -**Args:** - - - `print_tlu_fusing` (bool): flag to enable or disable printing tlu fusing - - - -**Raises:** - - - `TypeError`: if the value to set is not bool - ---- - - - -### method `set_security_level` - -```python -set_security_level(security_level: int) -``` - -Set security level. - - - -**Args:** - - - `security_level` (int): the target number of bits of security to compile the circuit - - - -**Raises:** - - - `TypeError`: if the value to set is not int - - `ValueError`: if the value to set is not in interval ]0; 1] - ---- - - - -### method `set_v0_parameter` - -```python -set_v0_parameter( - glwe_dim: int, - log_poly_size: int, - n_small: int, - br_level: int, - br_log_base: int, - ks_level: int, - ks_log_base: int -) -``` - -Set the basic V0 parameters. - - - -**Args:** - - - `glwe_dim` (int): GLWE dimension - - `log_poly_size` (int): log of polynomial size - - `n_small` (int): n - - `br_level` (int): bootstrap level - - `br_log_base` (int): bootstrap base log - - `ks_level` (int): keyswitch level - - `ks_log_base` (int): keyswitch base log - - - -**Raises:** - - - `TypeError`: if parameters are not of type int - ---- - - - -### method `set_verify_diagnostics` - -```python -set_verify_diagnostics(verify_diagnostics: bool) -``` - -Set option for diagnostics verification. - - - -**Args:** - - - `verify_diagnostics` (bool): whether to turn it on or off - - - -**Raises:** - - - `TypeError`: if the value to set is not boolean - ---- - - - -### method `simulation` - -```python -simulation(simulate: bool) -``` - -Enable or disable simulation. - - - -**Args:** - - - `simulate` (bool): flag to enable or disable simulation - - - -**Raises:** - - - `TypeError`: if the value to set is not bool - - diff --git a/docs/dev/api/concrete.compiler.evaluation_keys.md b/docs/dev/api/concrete.compiler.evaluation_keys.md deleted file mode 100644 index 6f3d1137fc..0000000000 --- a/docs/dev/api/concrete.compiler.evaluation_keys.md +++ /dev/null @@ -1,90 +0,0 @@ - - - - -# module `concrete.compiler.evaluation_keys` -EvaluationKeys. - - - ---- - - - -## class `EvaluationKeys` -EvaluationKeys required for execution. - - - -### method `__init__` - -```python -__init__(evaluation_keys: EvaluationKeys) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `evaluation_keys` (_EvaluationKeys): object to wrap - - - -**Raises:** - - - `TypeError`: if evaluation_keys is not of type _EvaluationKeys - - - - ---- - - - -### method `deserialize` - -```python -deserialize(serialized_evaluation_keys: bytes) → EvaluationKeys -``` - -Unserialize EvaluationKeys from bytes. - - - -**Args:** - - - `serialized_evaluation_keys` (bytes): previously serialized EvaluationKeys - - - -**Raises:** - - - `TypeError`: if serialized_evaluation_keys is not of type bytes - - - -**Returns:** - - - `EvaluationKeys`: deserialized object - ---- - - - -### method `serialize` - -```python -serialize() → bytes -``` - -Serialize the EvaluationKeys. - - - -**Returns:** - - - `bytes`: serialized object - - diff --git a/docs/dev/api/concrete.compiler.key_set.md b/docs/dev/api/concrete.compiler.key_set.md deleted file mode 100644 index db568fb66d..0000000000 --- a/docs/dev/api/concrete.compiler.key_set.md +++ /dev/null @@ -1,141 +0,0 @@ - - - - -# module `concrete.compiler.key_set` -KeySet. - -Store for the different keys required for an encrypted computation. - - - ---- - - - -## class `KeySet` -KeySet stores the different keys required for an encrypted computation. - -Holds private keys (secret key) used for encryption/decryption, and public keys used for computation. - - - -### method `__init__` - -```python -__init__(keyset: KeySet) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `keyset` (_KeySet): object to wrap - - - -**Raises:** - - - `TypeError`: if keyset is not of type _KeySet - - - - ---- - - - -### method `deserialize` - -```python -deserialize(serialized_key_set: bytes) → KeySet -``` - -Deserialize KeySet from bytes. - - - -**Args:** - - - `serialized_key_set` (bytes): previously serialized KeySet - - - -**Raises:** - - - `TypeError`: if serialized_key_set is not of type bytes - - - -**Returns:** - - - `KeySet`: deserialized object - ---- - - - -### method `get_evaluation_keys` - -```python -get_evaluation_keys() → EvaluationKeys -``` - -Get evaluation keys for execution. - - - -**Returns:** - EvaluationKeys: evaluation keys for execution - ---- - - - -### method `get_lwe_secret_key` - -```python -get_lwe_secret_key(keyid: int) → LweSecretKey -``` - -Get a specific LweSecretKey. - - - -**Args:** - - - `keyid` (int): id of the key to get - - - -**Raises:** - - - `TypeError`: if wrong types for input arguments - - - -**Returns:** - - - `bytes`: LweSecretKey - ---- - - - -### method `serialize` - -```python -serialize() → bytes -``` - -Serialize the KeySet. - - - -**Returns:** - - - `bytes`: serialized object - - diff --git a/docs/dev/api/concrete.compiler.key_set_cache.md b/docs/dev/api/concrete.compiler.key_set_cache.md deleted file mode 100644 index 4a96f97061..0000000000 --- a/docs/dev/api/concrete.compiler.key_set_cache.md +++ /dev/null @@ -1,75 +0,0 @@ - - - - -# module `concrete.compiler.key_set_cache` -KeySetCache. - -Cache for keys to avoid generating similar keys multiple times. - - - ---- - - - -## class `KeySetCache` -KeySetCache is a cache for KeySet to avoid generating similar keys multiple times. - -Keys get cached and can be later used instead of generating a new keyset which can take a lot of time. - - - -### method `__init__` - -```python -__init__(keyset_cache: KeySetCache) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `keyset_cache` (_KeySetCache): object to wrap - - - -**Raises:** - - - `TypeError`: if keyset_cache is not of type _KeySetCache - - - - ---- - - - -### method `new` - -```python -new(cache_path: str) → KeySetCache -``` - -Build a KeySetCache located at cache_path. - - - -**Args:** - - - `cache_path` (str): path to the cache - - - -**Raises:** - - - `TypeError`: if the path is not of type str. - - - -**Returns:** - KeySetCache - - diff --git a/docs/dev/api/concrete.compiler.lambda_argument.md b/docs/dev/api/concrete.compiler.lambda_argument.md deleted file mode 100644 index ceb7885e67..0000000000 --- a/docs/dev/api/concrete.compiler.lambda_argument.md +++ /dev/null @@ -1,449 +0,0 @@ - - - - -# module `concrete.compiler.lambda_argument` -LambdaArgument. - -**Global Variables** ---------------- -- **ACCEPTED_INTS** - - ---- - - - -## class `LambdaArgument` -LambdaArgument holds scalar or tensor values. - - - -### method `__init__` - -```python -__init__(lambda_argument: LambdaArgument) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `lambda_argument` (_LambdaArgument): object to wrap - - - -**Raises:** - - - `TypeError`: if lambda_argument is not of type _LambdaArgument - - - - ---- - - - -### method `from_scalar` - -```python -from_scalar(scalar: int) → LambdaArgument -``` - -Build a LambdaArgument containing the given scalar value. - - - -**Args:** - - - `scalar` (int or numpy.uint): scalar value to embed in LambdaArgument - - - -**Raises:** - - - `TypeError`: if scalar is not of type int or numpy.uint - - - -**Returns:** - LambdaArgument - ---- - - - -### method `from_signed_scalar` - -```python -from_signed_scalar(scalar: int) → LambdaArgument -``` - -Build a LambdaArgument containing the given scalar value. - - - -**Args:** - - - `scalar` (int or numpy.int): scalar value to embed in LambdaArgument - - - -**Raises:** - - - `TypeError`: if scalar is not of type int or numpy.uint - - - -**Returns:** - LambdaArgument - ---- - - - -### method `from_tensor_i16` - -```python -from_tensor_i16(data: List[int], shape: List[int]) → LambdaArgument -``` - -Build a LambdaArgument containing the given tensor. - - - -**Args:** - - - `data` (List[int]): flattened tensor data - - `shape` (List[int]): shape of original tensor before flattening - - - -**Returns:** - LambdaArgument - ---- - - - -### method `from_tensor_i32` - -```python -from_tensor_i32(data: List[int], shape: List[int]) → LambdaArgument -``` - -Build a LambdaArgument containing the given tensor. - - - -**Args:** - - - `data` (List[int]): flattened tensor data - - `shape` (List[int]): shape of original tensor before flattening - - - -**Returns:** - LambdaArgument - ---- - - - -### method `from_tensor_i64` - -```python -from_tensor_i64(data: List[int], shape: List[int]) → LambdaArgument -``` - -Build a LambdaArgument containing the given tensor. - - - -**Args:** - - - `data` (List[int]): flattened tensor data - - `shape` (List[int]): shape of original tensor before flattening - - - -**Returns:** - LambdaArgument - ---- - - - -### method `from_tensor_i8` - -```python -from_tensor_i8(data: List[int], shape: List[int]) → LambdaArgument -``` - -Build a LambdaArgument containing the given tensor. - - - -**Args:** - - - `data` (List[int]): flattened tensor data - - `shape` (List[int]): shape of original tensor before flattening - - - -**Returns:** - LambdaArgument - ---- - - - -### method `from_tensor_u16` - -```python -from_tensor_u16(data: List[int], shape: List[int]) → LambdaArgument -``` - -Build a LambdaArgument containing the given tensor. - - - -**Args:** - - - `data` (List[int]): flattened tensor data - - `shape` (List[int]): shape of original tensor before flattening - - - -**Returns:** - LambdaArgument - ---- - - - -### method `from_tensor_u32` - -```python -from_tensor_u32(data: List[int], shape: List[int]) → LambdaArgument -``` - -Build a LambdaArgument containing the given tensor. - - - -**Args:** - - - `data` (List[int]): flattened tensor data - - `shape` (List[int]): shape of original tensor before flattening - - - -**Returns:** - LambdaArgument - ---- - - - -### method `from_tensor_u64` - -```python -from_tensor_u64(data: List[int], shape: List[int]) → LambdaArgument -``` - -Build a LambdaArgument containing the given tensor. - - - -**Args:** - - - `data` (List[int]): flattened tensor data - - `shape` (List[int]): shape of original tensor before flattening - - - -**Returns:** - LambdaArgument - ---- - - - -### method `from_tensor_u8` - -```python -from_tensor_u8(data: List[int], shape: List[int]) → LambdaArgument -``` - -Build a LambdaArgument containing the given tensor. - - - -**Args:** - - - `data` (List[int]): flattened tensor data - - `shape` (List[int]): shape of original tensor before flattening - - - -**Returns:** - LambdaArgument - ---- - - - -### method `get_scalar` - -```python -get_scalar() → int -``` - -Return the contained scalar value. - - - -**Returns:** - int - ---- - - - -### method `get_signed_scalar` - -```python -get_signed_scalar() → int -``` - -Return the contained scalar value. - - - -**Returns:** - int - ---- - - - -### method `get_signed_tensor_data` - -```python -get_signed_tensor_data() → List[int] -``` - -Return the contained flattened tensor data. - - - -**Returns:** - List[int] - ---- - - - -### method `get_tensor_data` - -```python -get_tensor_data() → List[int] -``` - -Return the contained flattened tensor data. - - - -**Returns:** - List[int] - ---- - - - -### method `get_tensor_shape` - -```python -get_tensor_shape() → List[int] -``` - -Return the shape of the contained tensor. - - - -**Returns:** - - - `List[int]`: tensor shape - ---- - - - -### method `is_scalar` - -```python -is_scalar() → bool -``` - -Check if the contained argument is a scalar. - - - -**Returns:** - bool - ---- - - - -### method `is_signed` - -```python -is_signed() → bool -``` - -Check if the contained argument is signed. - - - -**Returns:** - bool - ---- - - - -### method `is_tensor` - -```python -is_tensor() → bool -``` - -Check if the contained argument is a tensor. - - - -**Returns:** - bool - ---- - - - -### method `new` - -```python -new(*args, **kwargs) -``` - -Use from_scalar or from_tensor instead. - - - -**Raises:** - RuntimeError - - diff --git a/docs/dev/api/concrete.compiler.library_compilation_result.md b/docs/dev/api/concrete.compiler.library_compilation_result.md deleted file mode 100644 index 0e04307b8a..0000000000 --- a/docs/dev/api/concrete.compiler.library_compilation_result.md +++ /dev/null @@ -1,71 +0,0 @@ - - - - -# module `concrete.compiler.library_compilation_result` -LibraryCompilationResult. - - - ---- - - - -## class `LibraryCompilationResult` -LibraryCompilationResult holds the result of the library compilation. - - - -### method `__init__` - -```python -__init__(library_compilation_result: LibraryCompilationResult) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `library_compilation_result` (_LibraryCompilationResult): object to wrap - - - -**Raises:** - - - `TypeError`: if library_compilation_result is not of type _LibraryCompilationResult - - - - ---- - - - -### method `new` - -```python -new(output_dir_path: str) → LibraryCompilationResult -``` - -Build a LibraryCompilationResult at output_dir_path. - - - -**Args:** - - - `output_dir_path` (str): path to the compilation artifacts - - - -**Raises:** - - - `TypeError`: if output_dir_path is not of type str - - - -**Returns:** - LibraryCompilationResult - - diff --git a/docs/dev/api/concrete.compiler.library_lambda.md b/docs/dev/api/concrete.compiler.library_lambda.md deleted file mode 100644 index 89422e0e67..0000000000 --- a/docs/dev/api/concrete.compiler.library_lambda.md +++ /dev/null @@ -1,42 +0,0 @@ - - - - -# module `concrete.compiler.library_lambda` -LibraryLambda. - - - ---- - - - -## class `LibraryLambda` -LibraryLambda reference a compiled library and can be ran using LibrarySupport. - - - -### method `__init__` - -```python -__init__(library_lambda: LibraryLambda) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `library_lambda` (_LibraryLambda): object to wrap - - - -**Raises:** - - - `TypeError`: if library_lambda is not of type _LibraryLambda - - - - - diff --git a/docs/dev/api/concrete.compiler.library_support.md b/docs/dev/api/concrete.compiler.library_support.md deleted file mode 100644 index 65cc7c001e..0000000000 --- a/docs/dev/api/concrete.compiler.library_support.md +++ /dev/null @@ -1,360 +0,0 @@ - - - - -# module `concrete.compiler.library_support` -LibrarySupport. - -Library support provides a way to compile an MLIR program into a library that can be later loaded to execute the compiled code. - -**Global Variables** ---------------- -- **DEFAULT_OUTPUT_PATH** - - ---- - - - -## class `LibrarySupport` -Support class for library compilation and execution. - - - -### method `__init__` - -```python -__init__(library_support: LibrarySupport) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `library_support` (_LibrarySupport): object to wrap - - - -**Raises:** - - - `TypeError`: if library_support is not of type _LibrarySupport - - ---- - -#### property output_dir_path - -Path where to store compilation artifacts. - - - ---- - - - -### method `compile` - -```python -compile( - mlir_program: Union[str, Module], - options: CompilationOptions = , - compilation_context: Optional[CompilationContext] = None -) → LibraryCompilationResult -``` - -Compile an MLIR program using Concrete dialects into a library. - - - -**Args:** - - - `mlir_program` (Union[str, MlirModule]): mlir program to compile (textual or in-memory) - - `options` (CompilationOptions): compilation options - - - -**Raises:** - - - `TypeError`: if mlir_program is not of type str or MlirModule - - `TypeError`: if options is not of type CompilationOptions - - - -**Returns:** - - - `LibraryCompilationResult`: the result of the library compilation - ---- - - - -### method `get_program_info_path` - -```python -get_program_info_path() → str -``` - -Get the path where the program info file is expected to be. - - - -**Returns:** - - - `str`: path to the program info file - ---- - - - -### method `get_shared_lib_path` - -```python -get_shared_lib_path() → str -``` - -Get the path where the shared library is expected to be. - - - -**Returns:** - - - `str`: path to the shared library - ---- - - - -### method `load_client_parameters` - -```python -load_client_parameters( - library_compilation_result: LibraryCompilationResult -) → ClientParameters -``` - -Load the client parameters from the library compilation result. - - - -**Args:** - - - `library_compilation_result` (LibraryCompilationResult): compilation result of the library - - - -**Raises:** - - - `TypeError`: if library_compilation_result is not of type LibraryCompilationResult - - - -**Returns:** - - - `ClientParameters`: appropriate client parameters for the compiled library - ---- - - - -### method `load_compilation_feedback` - -```python -load_compilation_feedback( - compilation_result: LibraryCompilationResult -) → ProgramCompilationFeedback -``` - -Load the compilation feedback from the compilation result. - - - -**Args:** - - - `compilation_result` (LibraryCompilationResult): result of the compilation - - - -**Raises:** - - - `TypeError`: if compilation_result is not of type LibraryCompilationResult - - - -**Returns:** - - - `ProgramCompilationFeedback`: the compilation feedback for the compiled program - ---- - - - -### method `load_server_lambda` - -```python -load_server_lambda( - library_compilation_result: LibraryCompilationResult, - simulation: bool, - circuit_name: str -) → LibraryLambda -``` - -Load the server lambda for a given circuit from the library compilation result. - - - -**Args:** - - - `library_compilation_result` (LibraryCompilationResult): compilation result of the library - - `simulation` (bool): use simulation for execution - - `circuit_name` (str): name of the circuit to be loaded - - - -**Raises:** - - - `TypeError`: if library_compilation_result is not of type LibraryCompilationResult, if circuit_name is not of type str or - - - -**Returns:** - - - `LibraryLambda`: executable reference to the library - ---- - - - -### method `new` - -```python -new( - output_path: str = './concrete-compiler_compilation_artifacts', - runtime_library_path: Optional[str] = None, - generateSharedLib: bool = True, - generateStaticLib: bool = False, - generateClientParameters: bool = True, - generateCompilationFeedback: bool = True, - generateCppHeader: bool = False -) → LibrarySupport -``` - -Build a LibrarySupport. - - - -**Args:** - - - `output_path` (str, optional): path where to store compilation artifacts. Defaults to DEFAULT_OUTPUT_PATH. - - `runtime_library_path` (Optional[str], optional): path to the runtime library. Defaults to None. - - `generateSharedLib` (bool): whether to emit shared library or not. Default to True. - - `generateStaticLib` (bool): whether to emit static library or not. Default to False. - - `generateClientParameters` (bool): whether to emit client parameters or not. Default to True. - - `generateCppHeader` (bool): whether to emit cpp header or not. Default to False. - - - -**Raises:** - - - `TypeError`: if output_path is not of type str - - `TypeError`: if runtime_library_path is not of type str - - `TypeError`: if one of the generation flags is not of type bool - - - -**Returns:** - LibrarySupport - ---- - - - -### method `reload` - -```python -reload() → LibraryCompilationResult -``` - -Reload the library compilation result from the output_dir_path. - - - -**Returns:** - - - `LibraryCompilationResult`: loaded library - ---- - - - -### method `server_call` - -```python -server_call( - library_lambda: LibraryLambda, - public_arguments: PublicArguments, - evaluation_keys: EvaluationKeys -) → PublicResult -``` - -Call the library with public_arguments. - - - -**Args:** - - - `library_lambda` (LibraryLambda): reference to the compiled library - - `public_arguments` (PublicArguments): arguments to use for execution - - `evaluation_keys` (EvaluationKeys): evaluation keys to use for execution - - - -**Raises:** - - - `TypeError`: if library_lambda is not of type LibraryLambda - - `TypeError`: if public_arguments is not of type PublicArguments - - `TypeError`: if evaluation_keys is not of type EvaluationKeys - - - -**Returns:** - - - `PublicResult`: result of the execution - ---- - - - -### method `simulate` - -```python -simulate( - library_lambda: LibraryLambda, - public_arguments: PublicArguments -) → PublicResult -``` - -Call the library with public_arguments in simulation mode. - - - -**Args:** - - - `library_lambda` (LibraryLambda): reference to the compiled library - - `public_arguments` (PublicArguments): arguments to use for execution - - - -**Raises:** - - - `TypeError`: if library_lambda is not of type LibraryLambda - - `TypeError`: if public_arguments is not of type PublicArguments - - - -**Returns:** - - - `PublicResult`: result of the execution - - diff --git a/docs/dev/api/concrete.compiler.lwe_secret_key.md b/docs/dev/api/concrete.compiler.lwe_secret_key.md deleted file mode 100644 index 92ac402694..0000000000 --- a/docs/dev/api/concrete.compiler.lwe_secret_key.md +++ /dev/null @@ -1,199 +0,0 @@ - - - - -# module `concrete.compiler.lwe_secret_key` -LweSecretKey. - - - ---- - - - -## class `LweSecretKeyParam` -LWE Secret Key Parameters - - - -### method `__init__` - -```python -__init__(lwe_secret_key_param: LweSecretKeyParam) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `lwe_secret_key_param` (_LweSecretKeyParam): object to wrap - - - -**Raises:** - - - `TypeError`: if lwe_secret_key_param is not of type _LweSecretKeyParam - - ---- - -#### property dimension - -LWE dimension - - - - ---- - - - -## class `LweSecretKey` -An LweSecretKey. - - - -### method `__init__` - -```python -__init__(lwe_secret_key: LweSecretKey) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `lwe_secret_key` (_LweSecretKey): object to wrap - - - -**Raises:** - - - `TypeError`: if lwe_secret_key is not of type _LweSecretKey - - ---- - -#### property param - -LWE Secret Key Parameters - - - ---- - - - -### method `deserialize` - -```python -deserialize(serialized_key: bytes, param: LweSecretKeyParam) → LweSecretKey -``` - -Deserialize LweSecretKey from bytes. - - - -**Args:** - - - `serialized_key` (bytes): previously serialized secret key - - - -**Raises:** - - - `TypeError`: if wrong types for input arguments - - - -**Returns:** - - - `LweSecretKey`: deserialized object - ---- - - - -### method `deserialize_from_glwe` - -```python -deserialize_from_glwe( - serialized_glwe_key: bytes, - param: LweSecretKeyParam -) → LweSecretKey -``` - -Deserialize LweSecretKey from glwe secret key bytes. - - - -**Args:** - - - `serialized_glwe_key` (bytes): previously serialized glwe secret key - - - -**Raises:** - - - `TypeError`: if wrong types for input arguments - - - -**Returns:** - - - `LweSecretKey`: deserialized object - ---- - - - -### method `serialize` - -```python -serialize() → bytes -``` - -Serialize key. - - - -**Returns:** - - - `bytes`: serialized key - ---- - - - -### method `serialize_as_glwe` - -```python -serialize_as_glwe(glwe_dim: int, poly_size: int) → bytes -``` - -Serialize key as a glwe secret key. - - - -**Args:** - - - `glwe_dim` (int): glwe dimension of the key - - `poly_size` (int): polynomial size of the key - - - -**Raises:** - - - `TypeError`: if wrong types for input arguments - - - -**Returns:** - - - `bytes`: serialized key - - diff --git a/docs/dev/api/concrete.compiler.md b/docs/dev/api/concrete.compiler.md index 418798c2ee..795a420aa6 100644 --- a/docs/dev/api/concrete.compiler.md +++ b/docs/dev/api/concrete.compiler.md @@ -7,74 +7,20 @@ Compiler submodule. **Global Variables** --------------- -- **wrapper**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **compilation_options**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **compilation_context**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **key_set_cache**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **lwe_secret_key**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **client_parameters**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **parameter** -- **compilation_feedback**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **evaluation_keys**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **key_set**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **value** -- **public_result**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **public_arguments**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - - **utils**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. # See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. -- **lambda_argument**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **library_compilation_result**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **library_lambda**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **client_support**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. +- **compilation_feedback**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. # See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. -- **library_support**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. +- **compilation_context**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. # See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - **tfhers_int** -- **value_decrypter** -- **value_exporter** -- **simulated_value_decrypter** -- **simulated_value_exporter** -- **server_circuit**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - -- **server_program**: # Part of the Concrete Compiler Project, under the BSD3 License with Zama Exceptions. -# See https://github.com/zama-ai/concrete/blob/main/LICENSE.txt for license information. - --- - + ## function `init_dfr` @@ -89,7 +35,7 @@ It is not always required to initialize the dataflow runtime as it can be implic --- - + ## function `check_gpu_enabled` @@ -104,7 +50,7 @@ GPU offloading is not always available, in particular in non-GPU wheels. --- - + ## function `check_gpu_available` @@ -117,7 +63,7 @@ Check whether a CUDA device is available and online. --- - + ## function `round_trip` diff --git a/docs/dev/api/concrete.compiler.parameter.md b/docs/dev/api/concrete.compiler.parameter.md deleted file mode 100644 index 87c3404050..0000000000 --- a/docs/dev/api/concrete.compiler.parameter.md +++ /dev/null @@ -1,32 +0,0 @@ - - - - -# module `concrete.compiler.parameter` -Parameter. - - - ---- - - - -## class `Parameter` -An FHE parameter. - - - -### method `__init__` - -```python -__init__(client_parameters: ClientParameters, key_type: KeyType, key_index: int) -``` - - - - - - - - - diff --git a/docs/dev/api/concrete.compiler.public_arguments.md b/docs/dev/api/concrete.compiler.public_arguments.md deleted file mode 100644 index 31531c3de4..0000000000 --- a/docs/dev/api/concrete.compiler.public_arguments.md +++ /dev/null @@ -1,109 +0,0 @@ - - - - -# module `concrete.compiler.public_arguments` -PublicArguments. - - - ---- - - - -## class `PublicArguments` -PublicArguments holds encrypted and plain arguments, as well as public materials. - -An encrypted computation may require both encrypted and plain arguments, PublicArguments holds both types, but also other public materials, such as public keys, which are required for private computation. - - - -### method `__init__` - -```python -__init__(public_arguments: PublicArguments) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `public_arguments` (_PublicArguments): object to wrap - - - -**Raises:** - - - `TypeError`: if public_arguments is not of type _PublicArguments - - - - ---- - - - -### method `deserialize` - -```python -deserialize( - client_parameters: ClientParameters, - serialized_args: bytes -) → PublicArguments -``` - -Unserialize PublicArguments from bytes of serialized_args. - - - -**Args:** - - - `client_parameters` (ClientParameters): client parameters of the compiled circuit - - `serialized_args` (bytes): previously serialized PublicArguments - - - -**Raises:** - - - `TypeError`: if client_parameters is not of type ClientParameters - - `TypeError`: if serialized_args is not of type bytes - - - -**Returns:** - - - `PublicArguments`: deserialized object - ---- - - - -### method `new` - -```python -new(client_parameters: ClientParameters, values: List[Value]) → PublicArguments -``` - -Create public arguments from individual values. - ---- - - - -### method `serialize` - -```python -serialize() → bytes -``` - -Serialize the PublicArguments. - - - -**Returns:** - - - `bytes`: serialized object - - diff --git a/docs/dev/api/concrete.compiler.public_result.md b/docs/dev/api/concrete.compiler.public_result.md deleted file mode 100644 index 3acb97b463..0000000000 --- a/docs/dev/api/concrete.compiler.public_result.md +++ /dev/null @@ -1,119 +0,0 @@ - - - - -# module `concrete.compiler.public_result` -PublicResult. - - - ---- - - - -## class `PublicResult` -PublicResult holds the result of an encrypted execution and can be decrypted using ClientSupport. - - - -### method `__init__` - -```python -__init__(public_result: PublicResult) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `public_result` (_PublicResult): object to wrap - - - -**Raises:** - - - `TypeError`: if public_result is not of type _PublicResult - - - - ---- - - - -### method `deserialize` - -```python -deserialize( - client_parameters: ClientParameters, - serialized_result: bytes -) → PublicResult -``` - -Unserialize PublicResult from bytes of serialized_result. - - - -**Args:** - - - `client_parameters` (ClientParameters): client parameters of the compiled circuit - - `serialized_result` (bytes): previously serialized PublicResult - - - -**Raises:** - - - `TypeError`: if client_parameters is not of type ClientParameters - - `TypeError`: if serialized_result is not of type bytes - - - -**Returns:** - - - `PublicResult`: deserialized object - ---- - - - -### method `get_value` - -```python -get_value(position: int) → Value -``` - -Get a specific value in the result. - ---- - - - -### method `n_values` - -```python -n_values() → int -``` - -Get number of values in the result. - ---- - - - -### method `serialize` - -```python -serialize() → bytes -``` - -Serialize the PublicResult. - - - -**Returns:** - - - `bytes`: serialized object - - diff --git a/docs/dev/api/concrete.compiler.server_circuit.md b/docs/dev/api/concrete.compiler.server_circuit.md deleted file mode 100644 index 75030036ca..0000000000 --- a/docs/dev/api/concrete.compiler.server_circuit.md +++ /dev/null @@ -1,106 +0,0 @@ - - - - -# module `concrete.compiler.server_circuit` -ServerCircuit. - - - ---- - - - -## class `ServerCircuit` -ServerCircuit references a circuit that can be called for execution and simulation. - - - -### method `__init__` - -```python -__init__(server_circuit: ServerCircuit) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `server_circuit` (_ServerCircuit): object to wrap - - - -**Raises:** - - - `TypeError`: if server_circuit is not of type _ServerCircuit - - - - ---- - - - -### method `call` - -```python -call( - public_arguments: PublicArguments, - evaluation_keys: EvaluationKeys -) → PublicResult -``` - -Executes the circuit on the public arguments. - - - -**Args:** - - - `public_arguments` (PublicArguments): public arguments to execute on - - `execution_keys` (EvaluationKeys): evaluation keys to use for execution. - - - -**Raises:** - - - `TypeError`: if public_arguments is not of type PublicArguments, or if evaluation_keys is not of type EvaluationKeys - - - -**Returns:** - - - `PublicResult`: A public result object containing the results. - ---- - - - -### method `simulate` - -```python -simulate(public_arguments: PublicArguments) → PublicResult -``` - -Simulates the circuit on the public arguments. - - - -**Args:** - - - `public_arguments` (PublicArguments): public arguments to execute on - - - -**Raises:** - - - `TypeError`: if public_arguments is not of type PublicArguments - - - -**Returns:** - - - `PublicResult`: A public result object containing the results. - - diff --git a/docs/dev/api/concrete.compiler.server_program.md b/docs/dev/api/concrete.compiler.server_program.md deleted file mode 100644 index 960b6b27ff..0000000000 --- a/docs/dev/api/concrete.compiler.server_program.md +++ /dev/null @@ -1,98 +0,0 @@ - - - - -# module `concrete.compiler.server_program` -ServerProgram. - - - ---- - - - -## class `ServerProgram` -ServerProgram references compiled circuit objects. - - - -### method `__init__` - -```python -__init__(server_program: ServerProgram) -``` - -Wrap the native Cpp object. - - - -**Args:** - - - `server_program` (_ServerProgram): object to wrap - - - -**Raises:** - - - `TypeError`: if server_program is not of type _ServerProgram - - - - ---- - - - -### method `get_server_circuit` - -```python -get_server_circuit(circuit_name: str) → ServerCircuit -``` - -Returns a given circuit if it is part of the program. - - - -**Args:** - - - `circuit_name` (str): name of the circuit to retrieve. - - - -**Raises:** - - - `TypeError`: if circuit_name is not of type str - - `RuntimeError`: if the circuit is not part of the program - ---- - - - -### method `load` - -```python -load(library_support: LibrarySupport, simulation: bool) → ServerProgram -``` - -Loads the server program from a library support. - - - -**Args:** - - - `library_support` (LibrarySupport): library support - - `simulation` (bool): use simulation for execution - - - -**Raises:** - - - `TypeError`: if library_support is not of type LibrarySupport, or if simulation is not of type bool - - - -**Returns:** - - - `ServerProgram`: A server program object containing references to circuits for calls. - - diff --git a/docs/dev/api/concrete.compiler.simulated_value_decrypter.md b/docs/dev/api/concrete.compiler.simulated_value_decrypter.md deleted file mode 100644 index 835088a2ca..0000000000 --- a/docs/dev/api/concrete.compiler.simulated_value_decrypter.md +++ /dev/null @@ -1,76 +0,0 @@ - - - - -# module `concrete.compiler.simulated_value_decrypter` -SimulatedValueDecrypter. - - - ---- - - - -## class `SimulatedValueDecrypter` -A helper class to decrypt `Value`s. - - - -### method `__init__` - -```python -__init__(value_decrypter: SimulatedValueDecrypter) -``` - -Wrap the native C++ object. - - - -**Args:** - value_decrypter (_SimulatedValueDecrypter): object to wrap - - - -**Raises:** - TypeError: if `value_decrypter` is not of type `_SimulatedValueDecrypter` - - - - ---- - - - -### method `decrypt` - -```python -decrypt(position: int, value: Value) → Union[int, ndarray] -``` - -Decrypt value. - - - -**Args:** - position (int): position of the argument within the circuit - - value (Value): value to decrypt - - - -**Returns:** - Union[int, np.ndarray]: decrypted value - ---- - - - -### method `new` - -```python -new(client_parameters: ClientParameters, circuit_name: str) -``` - -Create a value decrypter. - - diff --git a/docs/dev/api/concrete.compiler.simulated_value_exporter.md b/docs/dev/api/concrete.compiler.simulated_value_exporter.md deleted file mode 100644 index 5c7f031ae6..0000000000 --- a/docs/dev/api/concrete.compiler.simulated_value_exporter.md +++ /dev/null @@ -1,105 +0,0 @@ - - - - -# module `concrete.compiler.simulated_value_exporter` -SimulatedValueExporter. - - - ---- - - - -## class `SimulatedValueExporter` -A helper class to create `Value`s. - - - -### method `__init__` - -```python -__init__(value_exporter: SimulatedValueExporter) -``` - -Wrap the native C++ object. - - - -**Args:** - value_exporter (_SimulatedValueExporter): object to wrap - - - -**Raises:** - TypeError: if `value_exporter` is not of type `_SimulatedValueExporter` - - - - ---- - - - -### method `export_scalar` - -```python -export_scalar(position: int, value: int) → Value -``` - -Export scalar. - - - -**Args:** - position (int): position of the argument within the circuit - - value (int): scalar to export - - - -**Returns:** - Value: exported scalar - ---- - - - -### method `export_tensor` - -```python -export_tensor(position: int, values: List[int], shape: List[int]) → Value -``` - -Export tensor. - - - -**Args:** - position (int): position of the argument within the circuit - - values (List[int]): tensor elements to export - - shape (List[int]): tensor shape to export - - - -**Returns:** - Value: exported tensor - ---- - - - -### method `new` - -```python -new( - client_parameters: ClientParameters, - circuitName: str -) → SimulatedValueExporter -``` - -Create a value exporter. - - diff --git a/docs/dev/api/concrete.compiler.tfhers_int.md b/docs/dev/api/concrete.compiler.tfhers_int.md index a4fe6bad33..50a1b57b96 100644 --- a/docs/dev/api/concrete.compiler.tfhers_int.md +++ b/docs/dev/api/concrete.compiler.tfhers_int.md @@ -11,181 +11,6 @@ Import and export TFHErs integers into Concrete. -## class `TfhersFheIntDescription` -A helper class to create `TfhersFheIntDescription`s. - - - -### method `__init__` - -```python -__init__(desc: TfhersFheIntDescription) -``` - -Wrap the native C++ object. - - - -**Args:** - desc (_TfhersFheIntDescription): object to wrap - - - -**Raises:** - TypeError: if `desc` is not of type `_TfhersFheIntDescription` - - ---- - -#### property carry_modulus - -Modulus of the carry part in each ciphertext - ---- - -#### property degree - -Tracks the number of operations that have been done - ---- - -#### property is_signed - -Is the integer signed - ---- - -#### property ks_first - -Keyswitch placement relative to the bootsrap in a PBS - ---- - -#### property lwe_size - -LWE size - ---- - -#### property message_modulus - -Modulus of the message part in each ciphertext - ---- - -#### property n_cts - -Number of ciphertexts - ---- - -#### property noise_level - -Noise level - ---- - -#### property width - -Total integer bitwidth - - - ---- - - - -### method `from_serialized_fheuint8` - -```python -from_serialized_fheuint8(buffer: bytes) → TfhersFheIntDescription -``` - -Get the description of a serialized TFHErs fheuint8. - - - -**Args:** - - - `buffer` (bytes): serialized fheuint8 - - - -**Raises:** - - - `TypeError`: buffer is not of type bytes - - - -**Returns:** - - - `TfhersFheIntDescription`: description of the serialized fheuint8 - ---- - - - -### method `get_unknown_noise_level` - -```python -get_unknown_noise_level() → int -``` - -Get unknow noise level value. - - - -**Returns:** - - - `int`: unknown noise level value - ---- - - - -### method `new` - -```python -new( - width: int, - is_signed: bool, - message_modulus: int, - carry_modulus: int, - degree: int, - lwe_size: int, - n_cts: int, - noise_level: int, - ks_first: bool -) → TfhersFheIntDescription -``` - -Create a TfhersFheIntDescription. - - - -**Args:** - - - `width` (int): integer width - - `is_signed` (bool): signed or unsigned - - `message_modulus` (int): message modulus (not its log2) - - `carry_modulus` (int): carry modulus (not its log2) - - `degree` (int): degree - - `lwe_size` (int): LWE size - - `n_cts` (int): number of ciphertexts - - `noise_level` (int): noise level - - `ks_first` (bool): PBS order (keyswitch first, or bootstrap first) - - - -**Returns:** - - - `TfhersFheIntDescription`: TFHErs integer description - - ---- - - - ## class `TfhersExporter` A helper class to import and export TFHErs big integers. @@ -194,12 +19,12 @@ A helper class to import and export TFHErs big integers. --- - + -### method `export_fheuint8` +### method `export_int` ```python -export_fheuint8(value: Value, info: TfhersFheIntDescription) → bytes +export_int(value: TransportValue, info: TfhersFheIntDescription) → bytes ``` Convert Concrete value to TFHErs and serialize it. @@ -221,21 +46,22 @@ Convert Concrete value to TFHErs and serialize it. **Returns:** - - `bytes`: converted and serialized fheuint8 + - `bytes`: converted and serialized TFHErs integer --- - + -### method `import_fheuint8` +### method `import_int` ```python -import_fheuint8( +import_int( buffer: bytes, info: TfhersFheIntDescription, keyid: int, - variance: float -) → Value + variance: float, + shape: Tuple[int, ] +) → TransportValue ``` Unserialize and convert from TFHErs to Concrete value. @@ -244,10 +70,11 @@ Unserialize and convert from TFHErs to Concrete value. **Args:** - - `buffer` (bytes): serialized fheuint8 + - `buffer` (bytes): serialized TFHErs integer - `info` (TfhersFheIntDescription): description of the TFHErs integer to import - `keyid` (int): id of the key used for encryption - `variance` (float): variance used for encryption + - `shape` (Tuple[int, ...]): expected shape @@ -259,6 +86,6 @@ Unserialize and convert from TFHErs to Concrete value. **Returns:** - - `Value`: unserialized and converted value + - `TransportValue`: unserialized and converted value diff --git a/docs/dev/api/concrete.compiler.value.md b/docs/dev/api/concrete.compiler.value.md deleted file mode 100644 index 2f57d3c466..0000000000 --- a/docs/dev/api/concrete.compiler.value.md +++ /dev/null @@ -1,85 +0,0 @@ - - - - -# module `concrete.compiler.value` -Value. - - - ---- - - - -## class `Value` -An encrypted/clear value which can be scalar/tensor. - - - -### method `__init__` - -```python -__init__(value: Value) -``` - -Wrap the native C++ object. - - - -**Args:** - value (_Value): object to wrap - - - -**Raises:** - TypeError: if `value` is not of type `_Value` - - - - ---- - - - -### method `deserialize` - -```python -deserialize(serialized_value: bytes) → Value -``` - -Deserialize value from bytes. - - - -**Args:** - serialized_value (bytes): previously serialized value - - - -**Returns:** - Value: deserialized value - - - -**Raises:** - TypeError: if `serialized_value` is not of type `bytes` - ---- - - - -### method `serialize` - -```python -serialize() → bytes -``` - -Serialize value into bytes. - - - -**Returns:** - - - `bytes`: serialized value - - diff --git a/docs/dev/api/concrete.compiler.value_decrypter.md b/docs/dev/api/concrete.compiler.value_decrypter.md deleted file mode 100644 index 6cbac38a76..0000000000 --- a/docs/dev/api/concrete.compiler.value_decrypter.md +++ /dev/null @@ -1,80 +0,0 @@ - - - - -# module `concrete.compiler.value_decrypter` -ValueDecrypter. - - - ---- - - - -## class `ValueDecrypter` -A helper class to decrypt `Value`s. - - - -### method `__init__` - -```python -__init__(value_decrypter: ValueDecrypter) -``` - -Wrap the native C++ object. - - - -**Args:** - value_decrypter (_ValueDecrypter): object to wrap - - - -**Raises:** - TypeError: if `value_decrypter` is not of type `_ValueDecrypter` - - - - ---- - - - -### method `decrypt` - -```python -decrypt(position: int, value: Value) → Union[int, ndarray] -``` - -Decrypt value. - - - -**Args:** - position (int): position of the argument within the circuit - - value (Value): value to decrypt - - - -**Returns:** - Union[int, np.ndarray]: decrypted value - ---- - - - -### method `new` - -```python -new( - keyset: KeySet, - client_parameters: ClientParameters, - circuit_name: str = 'main' -) -``` - -Create a value decrypter. - - diff --git a/docs/dev/api/concrete.compiler.value_exporter.md b/docs/dev/api/concrete.compiler.value_exporter.md deleted file mode 100644 index a13d5a3b00..0000000000 --- a/docs/dev/api/concrete.compiler.value_exporter.md +++ /dev/null @@ -1,106 +0,0 @@ - - - - -# module `concrete.compiler.value_exporter` -ValueExporter. - - - ---- - - - -## class `ValueExporter` -A helper class to create `Value`s. - - - -### method `__init__` - -```python -__init__(value_exporter: ValueExporter) -``` - -Wrap the native C++ object. - - - -**Args:** - value_exporter (_ValueExporter): object to wrap - - - -**Raises:** - TypeError: if `value_exporter` is not of type `_ValueExporter` - - - - ---- - - - -### method `export_scalar` - -```python -export_scalar(position: int, value: int) → Value -``` - -Export scalar. - - - -**Args:** - position (int): position of the argument within the circuit - - value (int): scalar to export - - - -**Returns:** - Value: exported scalar - ---- - - - -### method `export_tensor` - -```python -export_tensor(position: int, values: List[int], shape: List[int]) → Value -``` - -Export tensor. - - - -**Args:** - position (int): position of the argument within the circuit - - values (List[int]): tensor elements to export - - shape (List[int]): tensor shape to export - - - -**Returns:** - Value: exported tensor - ---- - - - -### method `new` - -```python -new( - keyset: KeySet, - client_parameters: ClientParameters, - circuit_name: str -) → ValueExporter -``` - -Create a value exporter. - - diff --git a/docs/dev/api/concrete.compiler.wrapper.md b/docs/dev/api/concrete.compiler.wrapper.md deleted file mode 100644 index d871e9f74e..0000000000 --- a/docs/dev/api/concrete.compiler.wrapper.md +++ /dev/null @@ -1,82 +0,0 @@ - - - - -# module `concrete.compiler.wrapper` -Wrapper for native Cpp objects. - - - ---- - - - -## class `WrapperCpp` -Wrapper base class for native Cpp objects. - -Initialization should mainly store the wrapped object, and future calls to the wrapper will be forwarded to it. A static wrap method is provided to be more explicit. Wrappers should always be constructed using the new method, which construct the Cpp object using the provided arguments, then wrap it. Classes that inherit from this class should preferably type check the wrapped object during calls to init, and reimplement the new method if the class is meant to be constructed. - - - -### method `__init__` - -```python -__init__(cpp_obj) -``` - - - - - - - - ---- - - - -### method `cpp` - -```python -cpp() -``` - -Return the Cpp wrapped object. - ---- - - - -### method `new` - -```python -new(*args, **kwargs) -``` - -Create a new wrapper by building the underlying object with a specific set of arguments. - ---- - - - -### classmethod `wrap` - -```python -wrap(cpp_obj) → WrapperCpp -``` - -Wrap the Cpp object into a Python object. - - - -**Args:** - - - `cpp_obj`: object to wrap - - - -**Returns:** - - - `WrapperCpp`: wrapper - - diff --git a/docs/dev/api/concrete.fhe.compilation.circuit.md b/docs/dev/api/concrete.fhe.compilation.circuit.md index 8e9848d7ad..d54af5f51c 100644 --- a/docs/dev/api/concrete.fhe.compilation.circuit.md +++ b/docs/dev/api/concrete.fhe.compilation.circuit.md @@ -151,9 +151,7 @@ Get the number of encrypted negations per tag per parameter in the circuit. #### property function_name - - - +Return the name of the circuit. --- @@ -327,7 +325,7 @@ Get all statistics of the circuit. --- - + ### method `cleanup` @@ -339,7 +337,7 @@ Cleanup the temporary library output directory. --- - + ### method `decrypt` @@ -363,7 +361,7 @@ Decrypt result(s) of evaluation. --- - + ### method `draw` @@ -397,7 +395,7 @@ That this function requires the python `pygraphviz` package which itself require --- - + ### method `enable_fhe_execution` @@ -409,7 +407,7 @@ Enable FHE execution. --- - + ### method `enable_fhe_simulation` @@ -421,14 +419,14 @@ Enable FHE simulation. --- - + ### method `encrypt` ```python encrypt( *args: Optional[int, ndarray, List] -) → Union[Value, Tuple[Optional[Value], ], NoneType] +) → Union[Value, Tuple[Union[Value, NoneType], ], NoneType] ``` Encrypt argument(s) to for evaluation. @@ -445,7 +443,7 @@ Encrypt argument(s) to for evaluation. --- - + ### method `encrypt_run_decrypt` @@ -467,7 +465,7 @@ Encrypt inputs, run the circuit, and decrypt the outputs in one go. --- - + ### method `keygen` @@ -495,13 +493,13 @@ Generate keys required for homomorphic evaluation. --- - + ### method `run` ```python run( - *args: Optional[Value, Tuple[Optional[Value], ]] + *args: Optional[Value, Tuple[Union[Value], ], NoneType] ) → Union[Value, Tuple[Value, ]] ``` @@ -519,7 +517,7 @@ Evaluate the circuit. --- - + ### method `simulate` diff --git a/docs/dev/api/concrete.fhe.compilation.client.md b/docs/dev/api/concrete.fhe.compilation.client.md index 951ddd28f2..4fd0b4dae5 100644 --- a/docs/dev/api/concrete.fhe.compilation.client.md +++ b/docs/dev/api/concrete.fhe.compilation.client.md @@ -9,19 +9,20 @@ Declaration of `Client` class. --- - + ## class `Client` Client class, which can be used to manage keys, encrypt arguments and decrypt results. - + ### method `__init__` ```python __init__( client_specs: ClientSpecs, - keyset_cache_directory: Optional[Path, str] = None + keyset_cache_directory: Optional[Path, str] = None, + is_simulated: bool = False ) ``` @@ -47,11 +48,17 @@ Get evaluation keys for encrypted computation. Get the keys for the client. +--- + +#### property specs + +Get the client specs for the client. + --- - + ### method `decrypt` @@ -76,7 +83,7 @@ Decrypt result(s) of evaluation. --- - + ### method `encrypt` @@ -84,7 +91,7 @@ Decrypt result(s) of evaluation. encrypt( *args: Optional[int, ndarray, List], function_name: Optional[str] = None -) → Union[Value, Tuple[Optional[Value], ], NoneType] +) → Union[Value, Tuple[Union[Value, NoneType], ], NoneType] ``` Encrypt argument(s) to for evaluation. @@ -101,14 +108,14 @@ Encrypt argument(s) to for evaluation. --- - + ### method `keygen` ```python keygen( force: bool = False, - seed: Optional[int] = None, + secret_seed: Optional[int] = None, encryption_seed: Optional[int] = None, initial_keys: Optional[Dict[int, LweSecretKey]] = None ) @@ -121,7 +128,7 @@ Generate keys required for homomorphic evaluation. **Args:** force (bool, default = False): whether to generate new keys even if keys are already generated - seed (Optional[int], default = None): seed for private keys randomness + secret_seed (Optional[int], default = None): seed for private keys randomness encryption_seed (Optional[int], default = None): seed for encryption randomness @@ -129,14 +136,15 @@ Generate keys required for homomorphic evaluation. --- - + ### method `load` ```python load( path: Union[str, Path], - keyset_cache_directory: Optional[Path, str] = None + keyset_cache_directory: Optional[Path, str] = None, + is_simulated: bool = False ) → Client ``` @@ -149,6 +157,8 @@ Load the client from the given path in zip format. keyset_cache_directory (Optional[Union[str, Path]], default = None): keyset cache directory to use + is_simulated (bool, default = False): should perform + **Returns:** @@ -156,7 +166,7 @@ Load the client from the given path in zip format. --- - + ### method `save` @@ -171,4 +181,54 @@ Save the client into the given path in zip format. **Args:** path (Union[str, Path]): path to save the client +--- + + + +### method `simulate_decrypt` + +```python +simulate_decrypt( + *results: Union[Value, Tuple[Value, ]], + function_name: Optional[str] = None +) → Union[int, ndarray, Tuple[Union[int, ndarray, NoneType], ], NoneType] +``` + +Simulate decryption of result(s) of evaluation. + + + +**Args:** + *results (Union[Value, Tuple[Value, ...]]): result(s) of evaluation function_name (str): name of the function to decrypt for + + + +**Returns:** + Optional[Union[int, np.ndarray, Tuple[Optional[Union[int, np.ndarray]], ...]]]: decrypted result(s) of evaluation + +--- + + + +### method `simulate_encrypt` + +```python +simulate_encrypt( + *args: Optional[int, ndarray, List], + function_name: Optional[str] = None +) → Union[Value, Tuple[Union[Value, NoneType], ], NoneType] +``` + +Simulate encryption of argument(s) for evaluation. + + + +**Args:** + *args (Optional[Union[int, np.ndarray, List]]): argument(s) for evaluation function_name (str): name of the function to encrypt + + + +**Returns:** + Optional[Union[Value, Tuple[Optional[Value], ...]]]: encrypted argument(s) for evaluation + diff --git a/docs/dev/api/concrete.fhe.compilation.composition.md b/docs/dev/api/concrete.fhe.compilation.composition.md index 726bdd44dd..85aa131600 100644 --- a/docs/dev/api/concrete.fhe.compilation.composition.md +++ b/docs/dev/api/concrete.fhe.compilation.composition.md @@ -55,7 +55,7 @@ Create a composition rule from a tuple containing an output clause and an input --- - + ## class `CompositionPolicy` A protocol for composition policies. diff --git a/docs/dev/api/concrete.fhe.compilation.configuration.md b/docs/dev/api/concrete.fhe.compilation.configuration.md deleted file mode 100644 index 0cbc8cb1d5..0000000000 --- a/docs/dev/api/concrete.fhe.compilation.configuration.md +++ /dev/null @@ -1,266 +0,0 @@ - - - - -# module `concrete.fhe.compilation.configuration` -Declaration of `Configuration` class. - -**Global Variables** ---------------- -- **MAXIMUM_TLU_BIT_WIDTH** -- **DEFAULT_P_ERROR** -- **DEFAULT_GLOBAL_P_ERROR** - - ---- - - - -## class `ParameterSelectionStrategy` -ParameterSelectionStrategy, to set optimization strategy. - - - - - ---- - - - -## class `MultiParameterStrategy` -MultiParamStrategy, to set optimization strategy for multi-parameter. - - - - - ---- - - - -## class `Exactness` -Exactness, to specify for specific operator the implementation preference (default and local). - - - - - ---- - - - -## class `ApproximateRoundingConfig` -Controls the behavior of approximate rounding. - -In the following `k` is the ideal rounding output precision. Often the precision used after rounding is `k`+1 to avoid overflow. `logical_clipping`, `approximate_clipping_start_precision` can be used to stay at precision `k`, either logically or physically at the successor TLU. See examples in https://github.com/zama-ai/concrete/blob/main/docs/core-features/rounding.md. - - - -### method `__init__` - -```python -__init__( - logical_clipping: bool = True, - approximate_clipping_start_precision: int = 5, - reduce_precision_after_approximate_clipping: bool = True, - symetrize_deltas: bool = True -) → None -``` - - - - - - - - - ---- - - - -## class `ComparisonStrategy` -ComparisonStrategy, to specify implementation preference for comparisons. - - - - - ---- - - - -## class `BitwiseStrategy` -BitwiseStrategy, to specify implementation preference for bitwise operations. - - - - - ---- - - - -## class `MultivariateStrategy` -MultivariateStrategy, to specify implementation preference for multivariate operations. - - - - - ---- - - - -## class `MinMaxStrategy` -MinMaxStrategy, to specify implementation preference for minimum and maximum operations. - - - - - ---- - - - -## class `Configuration` -Configuration class, to allow the compilation process to be customized. - - - -### method `__init__` - -```python -__init__( - verbose: bool = False, - show_graph: Optional[bool] = None, - show_bit_width_constraints: Optional[bool] = None, - show_bit_width_assignments: Optional[bool] = None, - show_assigned_graph: Optional[bool] = None, - show_mlir: Optional[bool] = None, - show_optimizer: Optional[bool] = None, - show_statistics: Optional[bool] = None, - dump_artifacts_on_unexpected_failures: bool = True, - enable_unsafe_features: bool = False, - use_insecure_key_cache: bool = False, - insecure_key_cache_location: Optional[Path, str] = None, - loop_parallelize: bool = True, - dataflow_parallelize: bool = False, - auto_parallelize: bool = False, - compress_evaluation_keys: bool = False, - compress_input_ciphertexts: bool = False, - p_error: Optional[float] = None, - global_p_error: Optional[float] = None, - auto_adjust_rounders: bool = False, - auto_adjust_truncators: bool = False, - single_precision: bool = False, - parameter_selection_strategy: Union[ParameterSelectionStrategy, str] = , - multi_parameter_strategy: Union[MultiParameterStrategy, str] = , - show_progress: bool = False, - progress_title: str = '', - progress_tag: Union[bool, int] = False, - fhe_simulation: bool = False, - fhe_execution: bool = True, - compiler_debug_mode: bool = False, - compiler_verbose_mode: bool = False, - comparison_strategy_preference: Optional[ComparisonStrategy, str, List[Union[ComparisonStrategy, str]]] = None, - bitwise_strategy_preference: Optional[BitwiseStrategy, str, List[Union[BitwiseStrategy, str]]] = None, - shifts_with_promotion: bool = True, - multivariate_strategy_preference: Optional[MultivariateStrategy, str, List[Union[MultivariateStrategy, str]]] = None, - min_max_strategy_preference: Optional[MinMaxStrategy, str, List[Union[MinMaxStrategy, str]]] = None, - composable: bool = False, - use_gpu: bool = False, - relu_on_bits_threshold: int = 7, - relu_on_bits_chunk_size: int = 3, - if_then_else_chunk_size: int = 3, - additional_pre_processors: Optional[List[GraphProcessor]] = None, - additional_post_processors: Optional[List[GraphProcessor]] = None, - rounding_exactness: Exactness = , - approximate_rounding_config: Optional[ApproximateRoundingConfig] = None, - optimize_tlu_based_on_measured_bounds: bool = False, - enable_tlu_fusing: bool = True, - print_tlu_fusing: bool = False, - optimize_tlu_based_on_original_bit_width: Union[bool, int] = 8, - detect_overflow_in_simulation: bool = False, - dynamic_indexing_check_out_of_bounds: bool = True, - dynamic_assignment_check_out_of_bounds: bool = True, - simulate_encrypt_run_decrypt: bool = False -) -``` - - - - - - - - ---- - - - -### method `fork` - -```python -fork( - verbose: Union[Keep, bool] = , - show_graph: Optional[Keep, bool] = , - show_bit_width_constraints: Optional[Keep, bool] = , - show_bit_width_assignments: Optional[Keep, bool] = , - show_assigned_graph: Optional[Keep, bool] = , - show_mlir: Optional[Keep, bool] = , - show_optimizer: Optional[Keep, bool] = , - show_statistics: Optional[Keep, bool] = , - dump_artifacts_on_unexpected_failures: Union[Keep, bool] = , - enable_unsafe_features: Union[Keep, bool] = , - use_insecure_key_cache: Union[Keep, bool] = , - insecure_key_cache_location: Optional[Keep, Path, str] = , - loop_parallelize: Union[Keep, bool] = , - dataflow_parallelize: Union[Keep, bool] = , - auto_parallelize: Union[Keep, bool] = , - compress_evaluation_keys: Union[Keep, bool] = , - compress_input_ciphertexts: Union[Keep, bool] = , - p_error: Optional[Keep, float] = , - global_p_error: Optional[Keep, float] = , - auto_adjust_rounders: Union[Keep, bool] = , - auto_adjust_truncators: Union[Keep, bool] = , - single_precision: Union[Keep, bool] = , - parameter_selection_strategy: Union[Keep, ParameterSelectionStrategy, str] = , - multi_parameter_strategy: Union[Keep, MultiParameterStrategy, str] = , - show_progress: Union[Keep, bool] = , - progress_title: Union[Keep, str] = , - progress_tag: Union[Keep, bool, int] = , - fhe_simulation: Union[Keep, bool] = , - fhe_execution: Union[Keep, bool] = , - compiler_debug_mode: Union[Keep, bool] = , - compiler_verbose_mode: Union[Keep, bool] = , - comparison_strategy_preference: Optional[Keep, ComparisonStrategy, str, List[Union[ComparisonStrategy, str]]] = , - bitwise_strategy_preference: Optional[Keep, BitwiseStrategy, str, List[Union[BitwiseStrategy, str]]] = , - shifts_with_promotion: Union[Keep, bool] = , - multivariate_strategy_preference: Optional[Keep, MultivariateStrategy, str, List[Union[MultivariateStrategy, str]]] = , - min_max_strategy_preference: Optional[Keep, MinMaxStrategy, str, List[Union[MinMaxStrategy, str]]] = , - composable: Union[Keep, bool] = , - use_gpu: Union[Keep, bool] = , - relu_on_bits_threshold: Union[Keep, int] = , - relu_on_bits_chunk_size: Union[Keep, int] = , - if_then_else_chunk_size: Union[Keep, int] = , - additional_pre_processors: Optional[Keep, List[GraphProcessor]] = , - additional_post_processors: Optional[Keep, List[GraphProcessor]] = , - rounding_exactness: Union[Keep, Exactness] = , - approximate_rounding_config: Optional[Keep, ApproximateRoundingConfig] = , - optimize_tlu_based_on_measured_bounds: Union[Keep, bool] = , - enable_tlu_fusing: Union[Keep, bool] = , - print_tlu_fusing: Union[Keep, bool] = , - optimize_tlu_based_on_original_bit_width: Union[Keep, bool, int] = , - detect_overflow_in_simulation: Union[Keep, bool] = , - dynamic_indexing_check_out_of_bounds: Union[Keep, bool] = , - dynamic_assignment_check_out_of_bounds: Union[Keep, bool] = , - simulate_encrypt_run_decrypt: Union[Keep, bool] = -) → Configuration -``` - -Get a new configuration from another one specified changes. - -See Configuration. - - diff --git a/docs/dev/api/concrete.fhe.compilation.evaluation_keys.md b/docs/dev/api/concrete.fhe.compilation.evaluation_keys.md new file mode 100644 index 0000000000..c39686fd3b --- /dev/null +++ b/docs/dev/api/concrete.fhe.compilation.evaluation_keys.md @@ -0,0 +1,44 @@ + + + + +# module `concrete.fhe.compilation.evaluation_keys` +Declaration of `EvaluationKeys`. + + + +--- + + + +## class `EvaluationKeys` +EvaluationKeys required for execution. + + + + +--- + + + +### method `deserialize` + +```python +deserialize(buffer: bytes) → EvaluationKeys +``` + +Deserialize evaluation keys from bytes. + +--- + + + +### method `serialize` + +```python +serialize() → bytes +``` + +Serialize the evaluation keys. + + diff --git a/docs/dev/api/concrete.fhe.compilation.keys.md b/docs/dev/api/concrete.fhe.compilation.keys.md index a25adec7a3..432ee67be0 100644 --- a/docs/dev/api/concrete.fhe.compilation.keys.md +++ b/docs/dev/api/concrete.fhe.compilation.keys.md @@ -9,20 +9,20 @@ Declaration of `Keys` class. --- - + ## class `Keys` Keys class, to manage generate/reuse keys. Includes encryption keys as well as evaluation keys. Be careful when serializing/saving keys! - + ### method `__init__` ```python __init__( - client_specs: Optional[ClientSpecs], + specs: Optional[ClientSpecs], cache_directory: Optional[Path, str] = None ) ``` @@ -44,24 +44,32 @@ Get if the keys are already generated. Get only evaluation keys. +--- + +#### property specs + +Return the associated client specs if any. + --- - + ### method `deserialize` ```python -deserialize(serialized_keys: bytes) → Keys +deserialize(serialized_keys: Union[Path, bytes]) → Keys ``` -Deserialize keys from bytes. +Deserialize keys from file or buffer. + +Prefer using a Path instead of bytes in case of big Keys. It reduces memory usage. **Args:** - serialized_keys (bytes): previously serialized keys + serialized_keys (Union[Path, bytes]): previously serialized keys (either Path or buffer) @@ -70,14 +78,14 @@ Deserialize keys from bytes. --- - + ### method `generate` ```python generate( force: bool = False, - seed: Optional[int] = None, + secret_seed: Optional[int] = None, encryption_seed: Optional[int] = None, initial_keys: Optional[Dict[int, LweSecretKey]] = None ) @@ -90,7 +98,7 @@ Generate new keys. **Args:** force (bool, default = False): whether to generate new keys even if keys are already generated/loaded - seed (Optional[int], default = None): seed for private keys randomness + secret_seed (Optional[int], default = None): seed for private keys randomness encryption_seed (Optional[int], default = None): seed for encryption randomness @@ -98,7 +106,7 @@ Generate new keys. --- - + ### method `load` @@ -115,14 +123,14 @@ Load keys from a location. --- - + ### method `load_if_exists_generate_and_save_otherwise` ```python load_if_exists_generate_and_save_otherwise( location: Union[str, Path], - seed: Optional[int] = None + secret_seed: Optional[int] = None ) ``` @@ -133,11 +141,11 @@ Load keys from a location if they exist, else generate new keys and save to that **Args:** location (Union[str, Path]): location to load from or save to - seed (Optional[int], default = None): seed for randomness in case keys need to be generated + secret_seed (Optional[int], default = None): seed for randomness in case keys need to be generated --- - + ### method `save` @@ -156,7 +164,7 @@ Saved keys are not encrypted, so be careful how you store/transfer them! --- - + ### method `serialize` diff --git a/docs/dev/api/concrete.fhe.compilation.md b/docs/dev/api/concrete.fhe.compilation.md index 5abb96c2f5..99a2ea95c8 100644 --- a/docs/dev/api/concrete.fhe.compilation.md +++ b/docs/dev/api/concrete.fhe.compilation.md @@ -11,6 +11,7 @@ Glue the compilation process together. - **utils** - **configuration** - **artifacts** +- **evaluation_keys** - **keys** - **value** - **client** diff --git a/docs/dev/api/concrete.fhe.compilation.module.md b/docs/dev/api/concrete.fhe.compilation.module.md index 3433278c0a..7539111d58 100644 --- a/docs/dev/api/concrete.fhe.compilation.module.md +++ b/docs/dev/api/concrete.fhe.compilation.module.md @@ -9,7 +9,7 @@ Declaration of `FheModule` classes. --- - + ## class `ExecutionRt` Runtime object class for execution. @@ -20,7 +20,7 @@ Runtime object class for execution. --- - + ## class `SimulationRt` Runtime object class for simulation. @@ -31,12 +31,12 @@ Runtime object class for simulation. --- - + ## class `FheFunction` Fhe function class, allowing to run or simulate one function of an fhe module. - + ### method `__init__` @@ -245,7 +245,7 @@ Get all statistics of the function. --- - + ### method `decrypt` @@ -269,7 +269,7 @@ Decrypt result(s) of evaluation. --- - + ### method `draw` @@ -303,14 +303,14 @@ That this function requires the python `pygraphviz` package which itself require --- - + ### method `encrypt` ```python encrypt( *args: Optional[int, ndarray, List] -) → Union[Value, Tuple[Optional[Value], ], NoneType] +) → Union[Value, Tuple[Union[Value, NoneType], ], NoneType] ``` Encrypt argument(s) to for evaluation. @@ -327,7 +327,7 @@ Encrypt argument(s) to for evaluation. --- - + ### method `encrypt_run_decrypt` @@ -349,13 +349,13 @@ Encrypt inputs, run the function, and decrypt the outputs in one go. --- - + ### method `run` ```python run( - *args: Optional[Value, Tuple[Optional[Value], ]] + *args: Optional[Value, Tuple[Union[Value], ], NoneType] ) → Union[Value, Tuple[Value, ]] ``` @@ -373,7 +373,7 @@ Evaluate the function. --- - + ### method `simulate` @@ -396,12 +396,12 @@ Simulate execution of the function. --- - + ## class `FheModule` Fhe module class, to combine computation graphs, mlir, runtime objects into a single object. - + ### method `__init__` @@ -508,7 +508,7 @@ Get all statistics of the module. --- - + ### method `cleanup` @@ -520,7 +520,7 @@ Cleanup the temporary library output directory. --- - + ### method `functions` @@ -532,7 +532,7 @@ Return a dictionnary containing all the functions of the module. --- - + ### method `keygen` diff --git a/docs/dev/api/concrete.fhe.compilation.module_compiler.md b/docs/dev/api/concrete.fhe.compilation.module_compiler.md index ffa20075c2..b212671b81 100644 --- a/docs/dev/api/concrete.fhe.compilation.module_compiler.md +++ b/docs/dev/api/concrete.fhe.compilation.module_compiler.md @@ -118,7 +118,7 @@ __init__(functions: List[FunctionDef], composition: CompositionPolicy) ```python compile( - inputsets: Optional[Dict[str, Optional[Iterable[Any], Iterable[Tuple[Any, ]]]]] = None, + inputsets: Optional[Dict[str, Union[Iterable[Any], Iterable[Tuple[Any, ]]]], NoneType] = None, configuration: Optional[Configuration] = None, module_artifacts: Optional[ModuleDebugArtifacts] = None, **kwargs diff --git a/docs/dev/api/concrete.fhe.compilation.server.md b/docs/dev/api/concrete.fhe.compilation.server.md index 48f30ab5ef..06e7c3883b 100644 --- a/docs/dev/api/concrete.fhe.compilation.server.md +++ b/docs/dev/api/concrete.fhe.compilation.server.md @@ -13,22 +13,18 @@ Declaration of `Server` class. --- - + ## class `Server` Server class, which can be used to perform homomorphic computation. - + ### method `__init__` ```python __init__( - client_specs: ClientSpecs, - output_dir: Union[NoneType, str, Path], - support: LibrarySupport, - compilation_result: LibraryCompilationResult, - server_program: ServerProgram, + library: Library, is_simulated: bool, composition_rules: Optional[List[CompositionRule]] ) @@ -39,6 +35,12 @@ __init__( +--- + +#### property client_specs + +Return the associated client specs. + --- #### property complexity @@ -59,6 +61,12 @@ Get the probability of error for each simple TLU (on a scalar). --- +#### property program_info + +The program info associated with the server. + +--- + #### property size_of_bootstrap_keys Get size of the bootstrap keys of the compiled program. @@ -79,7 +87,7 @@ Get size of the secret keys of the compiled program. --- - + ### method `cleanup` @@ -91,7 +99,7 @@ Cleanup the temporary library output directory. --- - + ### method `clear_addition_count` @@ -103,19 +111,21 @@ Get the number of clear additions in the compiled program. --- - + ### method `clear_addition_count_per_parameter` ```python -clear_addition_count_per_parameter(function: str) → Dict[Parameter, int] +clear_addition_count_per_parameter( + function: str +) → Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int] ``` Get the number of clear additions per parameter in the compiled program. --- - + ### method `clear_addition_count_per_tag` @@ -127,21 +137,21 @@ Get the number of clear additions per tag in the compiled program. --- - + ### method `clear_addition_count_per_tag_per_parameter` ```python clear_addition_count_per_tag_per_parameter( function: str -) → Dict[str, Dict[Parameter, int]] +) → Dict[str, Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int]] ``` Get the number of clear additions per tag per parameter in the compiled program. --- - + ### method `clear_multiplication_count` @@ -153,19 +163,21 @@ Get the number of clear multiplications in the compiled program. --- - + ### method `clear_multiplication_count_per_parameter` ```python -clear_multiplication_count_per_parameter(function: str) → Dict[Parameter, int] +clear_multiplication_count_per_parameter( + function: str +) → Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int] ``` Get the number of clear multiplications per parameter in the compiled program. --- - + ### method `clear_multiplication_count_per_tag` @@ -177,21 +189,21 @@ Get the number of clear multiplications per tag in the compiled program. --- - + ### method `clear_multiplication_count_per_tag_per_parameter` ```python clear_multiplication_count_per_tag_per_parameter( function: str -) → Dict[str, Dict[Parameter, int]] +) → Dict[str, Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int]] ``` Get the number of clear multiplications per tag per parameter in the compiled program. --- - + ### method `create` @@ -222,7 +234,7 @@ Create a server using MLIR and output sign information. --- - + ### method `encrypted_addition_count` @@ -234,19 +246,21 @@ Get the number of encrypted additions in the compiled program. --- - + ### method `encrypted_addition_count_per_parameter` ```python -encrypted_addition_count_per_parameter(function: str) → Dict[Parameter, int] +encrypted_addition_count_per_parameter( + function: str +) → Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int] ``` Get the number of encrypted additions per parameter in the compiled program. --- - + ### method `encrypted_addition_count_per_tag` @@ -258,14 +272,14 @@ Get the number of encrypted additions per tag in the compiled program. --- - + ### method `encrypted_addition_count_per_tag_per_parameter` ```python encrypted_addition_count_per_tag_per_parameter( function: str -) → Dict[str, Dict[Parameter, int]] +) → Dict[str, Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int]] ``` Get the number of encrypted additions per tag per parameter in the compiled program. @@ -284,19 +298,21 @@ Get the number of encrypted negations in the compiled program. --- - + ### method `encrypted_negation_count_per_parameter` ```python -encrypted_negation_count_per_parameter(function: str) → Dict[Parameter, int] +encrypted_negation_count_per_parameter( + function: str +) → Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int] ``` Get the number of encrypted negations per parameter in the compiled program. --- - + ### method `encrypted_negation_count_per_tag` @@ -308,21 +324,21 @@ Get the number of encrypted negations per tag in the compiled program. --- - + ### method `encrypted_negation_count_per_tag_per_parameter` ```python encrypted_negation_count_per_tag_per_parameter( function: str -) → Dict[str, Dict[Parameter, int]] +) → Dict[str, Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int]] ``` Get the number of encrypted negations per tag per parameter in the compiled program. --- - + ### method `key_switch_count` @@ -334,19 +350,21 @@ Get the number of key switches in the compiled program. --- - + ### method `key_switch_count_per_parameter` ```python -key_switch_count_per_parameter(function: str) → Dict[Parameter, int] +key_switch_count_per_parameter( + function: str +) → Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int] ``` Get the number of key switches per parameter in the compiled program. --- - + ### method `key_switch_count_per_tag` @@ -358,21 +376,21 @@ Get the number of key switches per tag in the compiled program. --- - + ### method `key_switch_count_per_tag_per_parameter` ```python key_switch_count_per_tag_per_parameter( function: str -) → Dict[str, Dict[Parameter, int]] +) → Dict[str, Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int]] ``` Get the number of key switches per tag per parameter in the compiled program. --- - + ### method `load` @@ -396,19 +414,19 @@ Load the server from the given path in zip format. --- - + ### method `memory_usage_per_location` ```python -memory_usage_per_location(function: str) → Dict[str, int] +memory_usage_per_location(function: str) → Dict[str, Union[int, NoneType]] ``` Get the memory usage of operations per location. --- - + ### method `packing_key_switch_count` @@ -420,19 +438,21 @@ Get the number of packing key switches in the compiled program. --- - + ### method `packing_key_switch_count_per_parameter` ```python -packing_key_switch_count_per_parameter(function: str) → Dict[Parameter, int] +packing_key_switch_count_per_parameter( + function: str +) → Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int] ``` Get the number of packing key switches per parameter in the compiled program. --- - + ### method `packing_key_switch_count_per_tag` @@ -444,21 +464,21 @@ Get the number of packing key switches per tag in the compiled program. --- - + ### method `packing_key_switch_count_per_tag_per_parameter` ```python packing_key_switch_count_per_tag_per_parameter( function: str -) → Dict[str, Dict[Parameter, int]] +) → Dict[str, Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int]] ``` Get the number of packing key switches per tag per parameter in the compiled program. --- - + ### method `programmable_bootstrap_count` @@ -470,19 +490,21 @@ Get the number of programmable bootstraps in the compiled program. --- - + ### method `programmable_bootstrap_count_per_parameter` ```python -programmable_bootstrap_count_per_parameter(function: str) → Dict[Parameter, int] +programmable_bootstrap_count_per_parameter( + function: str +) → Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int] ``` Get the number of programmable bootstraps per parameter in the compiled program. --- - + ### method `programmable_bootstrap_count_per_tag` @@ -494,27 +516,27 @@ Get the number of programmable bootstraps per tag in the compiled program. --- - + ### method `programmable_bootstrap_count_per_tag_per_parameter` ```python programmable_bootstrap_count_per_tag_per_parameter( function: str -) → Dict[str, Dict[Parameter, int]] +) → Dict[str, Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int]] ``` Get the number of programmable bootstraps per tag per parameter in the compiled program. --- - + ### method `run` ```python run( - *args: Optional[Value, Tuple[Optional[Value], ]], + *args: Optional[Value, Tuple[Union[Value], ], NoneType], evaluation_keys: Optional[EvaluationKeys] = None, function_name: Optional[str] = None ) → Union[Value, Tuple[Value, ]] @@ -538,7 +560,7 @@ Evaluate. --- - + ### method `save` @@ -557,7 +579,7 @@ Save the server into the given path in zip format. --- - + ### method `size_of_inputs` @@ -569,7 +591,7 @@ Get size of the inputs of the compiled program. --- - + ### method `size_of_outputs` diff --git a/docs/dev/api/concrete.fhe.compilation.specs.md b/docs/dev/api/concrete.fhe.compilation.specs.md index 78478cf906..a36cf47ae5 100644 --- a/docs/dev/api/concrete.fhe.compilation.specs.md +++ b/docs/dev/api/concrete.fhe.compilation.specs.md @@ -19,7 +19,7 @@ ClientSpecs class, to create Client objects. ### method `__init__` ```python -__init__(client_parameters: ClientParameters) +__init__(program_info: ProgramInfo) ``` diff --git a/docs/dev/api/concrete.fhe.compilation.status.md b/docs/dev/api/concrete.fhe.compilation.status.md index 96a7d7b1f5..2e760d6569 100644 --- a/docs/dev/api/concrete.fhe.compilation.status.md +++ b/docs/dev/api/concrete.fhe.compilation.status.md @@ -9,7 +9,7 @@ Declaration of `EncryptionStatus` class. --- - + ## class `EncryptionStatus` EncryptionStatus enum, to represent encryption status of parameters. diff --git a/docs/dev/api/concrete.fhe.compilation.utils.md b/docs/dev/api/concrete.fhe.compilation.utils.md index ac6898acf2..83bee50312 100644 --- a/docs/dev/api/concrete.fhe.compilation.utils.md +++ b/docs/dev/api/concrete.fhe.compilation.utils.md @@ -106,7 +106,7 @@ Fuse appropriate subgraphs in a graph to a single Operation.Generic node. find_float_subgraph_with_unique_terminal_node( graph: Graph, processed_terminal_nodes: Set[Node] -) → Optional[Tuple[Dict[Node, NoneType], Dict[Node, NoneType], Node]] +) → Union[Tuple[Dict[Node, NoneType], Dict[Node, NoneType], Node], NoneType] ``` Find a subgraph with float computations that end with an integer output. @@ -134,7 +134,7 @@ Find a subgraph with float computations that end with an integer output. find_tlu_subgraph_with_multiple_variable_inputs_that_has_a_single_common_ancestor( graph: Graph, processed_terminal_nodes: Set[Node] -) → Optional[Tuple[Dict[Node, NoneType], Dict[Node, NoneType], Node]] +) → Union[Tuple[Dict[Node, NoneType], Dict[Node, NoneType], Node], NoneType] ``` Find a subgraph with a tlu computation that has multiple variable inputs where all variable inputs share a common ancestor. @@ -159,7 +159,7 @@ Find a subgraph with a tlu computation that has multiple variable inputs whe ## function `find_single_lca` ```python -find_single_lca(graph: Graph, nodes: List[Node]) → Optional[Node] +find_single_lca(graph: Graph, nodes: List[Node]) → Union[Node, NoneType] ``` Find the single lowest common ancestor of a list of nodes. @@ -281,7 +281,7 @@ convert_subgraph_to_subgraph_node( all_nodes: Dict[Node, NoneType], start_nodes: Dict[Node, NoneType], terminal_node: Node -) → Optional[Tuple[Node, Node]] +) → Union[Tuple[Node, Node], NoneType] ``` Convert a subgraph to Operation.Generic node. diff --git a/docs/dev/api/concrete.fhe.compilation.value.md b/docs/dev/api/concrete.fhe.compilation.value.md index bda9179e0a..53286d7faa 100644 --- a/docs/dev/api/concrete.fhe.compilation.value.md +++ b/docs/dev/api/concrete.fhe.compilation.value.md @@ -9,17 +9,17 @@ Declaration of `Value` class. --- - + ## class `Value` -Value class, to store scalar or tensor values which can be encrypted or clear. +A public value object that can be sent between client and server. - + ### method `__init__` ```python -__init__(inner: Value) +__init__(inner: TransportValue) ``` @@ -31,29 +31,19 @@ __init__(inner: Value) --- - + ### method `deserialize` ```python -deserialize(serialized_data: bytes) → Value +deserialize(buffer: bytes) → Value ``` -Deserialize data from bytes. - - - -**Args:** - serialized_data (bytes): previously serialized data - - - -**Returns:** - Value: deserialized data +Deserialize a Value from bytes. --- - + ### method `serialize` @@ -61,11 +51,6 @@ Deserialize data from bytes. serialize() → bytes ``` -Serialize data into bytes. - - - -**Returns:** - bytes: serialized data +Serialize a Value to bytes. diff --git a/docs/dev/api/concrete.fhe.compilation.wiring.md b/docs/dev/api/concrete.fhe.compilation.wiring.md index c827d62996..eec7a05d59 100644 --- a/docs/dev/api/concrete.fhe.compilation.wiring.md +++ b/docs/dev/api/concrete.fhe.compilation.wiring.md @@ -60,7 +60,7 @@ Return an iterator over composition rules. --- - + ## class `WireOutput` A protocol for wire outputs. @@ -83,7 +83,7 @@ Return an iterator over the possible outputs of the wire output. --- - + ## class `WireInput` A protocol for wire inputs. diff --git a/docs/dev/api/concrete.fhe.extensions.tag.md b/docs/dev/api/concrete.fhe.extensions.tag.md index 039c91bd82..bd0db5a4c4 100644 --- a/docs/dev/api/concrete.fhe.extensions.tag.md +++ b/docs/dev/api/concrete.fhe.extensions.tag.md @@ -11,7 +11,7 @@ Declaration of `tag` context manager, to allow tagging certain nodes. --- - + ## function `tag` diff --git a/docs/dev/api/concrete.fhe.mlir.context.md b/docs/dev/api/concrete.fhe.mlir.context.md index aa245d1704..04f0589384 100644 --- a/docs/dev/api/concrete.fhe.mlir.context.md +++ b/docs/dev/api/concrete.fhe.mlir.context.md @@ -411,8 +411,8 @@ conditional( resulting_type: Optional[ConversionType], condition: Conversion, then_builder: Callable[[], Optional[Conversion]], - else_builder: Optional[Callable[[], Optional[Conversion]]] = None -) → Optional[Conversion] + else_builder: Optional[Callable[[], Union[Conversion]], NoneType] = None +) → Union[Conversion, NoneType] ``` Create an if conditional. @@ -680,10 +680,10 @@ flatten(x: Conversion) → Conversion for_loop( lower_bound: int, upper_bound: int, - body: Union[Callable[[Conversion], Optional[Conversion]], Callable[[Conversion, Conversion], Optional[Conversion]]], + body: Optional[Callable[[Conversion], Union[Conversion]], Callable[[Conversion, Conversion], Optional[Conversion]]], output: Optional[Conversion] = None, step: int = 1 -) → Optional[Conversion] +) → Union[Conversion, NoneType] ``` Create a for loop. @@ -1534,7 +1534,7 @@ try_comparison_with_clipping_trick( x: Conversion, y: Conversion, accept: Set[Comparison] -) → Optional[Conversion] +) → Union[Conversion, NoneType] ``` Compare encrypted values using clipping trick. diff --git a/docs/dev/api/concrete.fhe.mlir.converter.md b/docs/dev/api/concrete.fhe.mlir.converter.md index 52af7f72cc..1e891e602f 100644 --- a/docs/dev/api/concrete.fhe.mlir.converter.md +++ b/docs/dev/api/concrete.fhe.mlir.converter.md @@ -12,12 +12,12 @@ Declaration of `Converter` class. --- - + ## class `Converter` Converter class, to convert a computation graph to MLIR. - + ### method `__init__` @@ -37,7 +37,7 @@ __init__( --- - + ### method `add` @@ -51,7 +51,7 @@ add(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `amax` @@ -65,7 +65,7 @@ amax(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `amin` @@ -79,7 +79,7 @@ amin(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `array` @@ -93,7 +93,7 @@ array(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `assign_dynamic` @@ -107,7 +107,7 @@ assign_dynamic(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `assign_static` @@ -121,7 +121,7 @@ assign_static(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `bitwise_and` @@ -135,7 +135,7 @@ bitwise_and(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `bitwise_or` @@ -149,7 +149,7 @@ bitwise_or(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `bitwise_xor` @@ -163,7 +163,7 @@ bitwise_xor(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `broadcast_to` @@ -177,7 +177,7 @@ broadcast_to(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `concatenate` @@ -191,7 +191,7 @@ concatenate(ctx: Context, node: Node, preds: List[Conversion]) --- - + ### method `constant` @@ -205,7 +205,7 @@ constant(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `conv1d` @@ -219,7 +219,7 @@ conv1d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `conv2d` @@ -233,7 +233,7 @@ conv2d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `conv3d` @@ -247,7 +247,7 @@ conv3d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `convert` @@ -270,7 +270,7 @@ Return: MlirModule: In-memory MLIR module corresponding to the graph --- - + ### method `convert_many` @@ -291,7 +291,7 @@ Return: MlirModule: In-memory MLIR module corresponding to the graph --- - + ### method `copy` @@ -305,7 +305,7 @@ copy(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `dot` @@ -319,7 +319,7 @@ dot(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `dynamic_tlu` @@ -333,7 +333,7 @@ dynamic_tlu(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `equal` @@ -347,7 +347,7 @@ equal(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `expand_dims` @@ -361,7 +361,7 @@ expand_dims(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `extract_bit_pattern` @@ -379,7 +379,7 @@ extract_bit_pattern( --- - + ### method `greater` @@ -393,7 +393,7 @@ greater(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `greater_equal` @@ -407,7 +407,7 @@ greater_equal(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `identity` @@ -421,7 +421,7 @@ identity(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `index_dynamic` @@ -435,7 +435,7 @@ index_dynamic(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `index_static` @@ -449,7 +449,7 @@ index_static(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `left_shift` @@ -463,7 +463,7 @@ left_shift(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `less` @@ -477,7 +477,7 @@ less(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `less_equal` @@ -491,7 +491,7 @@ less_equal(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `matmul` @@ -505,7 +505,7 @@ matmul(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `max` @@ -519,7 +519,7 @@ max(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `maximum` @@ -533,7 +533,7 @@ maximum(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `maxpool1d` @@ -547,7 +547,7 @@ maxpool1d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `maxpool2d` @@ -561,7 +561,7 @@ maxpool2d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `maxpool3d` @@ -575,7 +575,7 @@ maxpool3d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `min` @@ -589,7 +589,7 @@ min(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `minimum` @@ -603,7 +603,7 @@ minimum(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `multiply` @@ -617,7 +617,7 @@ multiply(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `negative` @@ -631,7 +631,7 @@ negative(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `node` @@ -654,7 +654,7 @@ Return: Conversion: conversion object corresponding to node --- - + ### method `not_equal` @@ -668,7 +668,7 @@ not_equal(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `ones` @@ -682,7 +682,7 @@ ones(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `process` @@ -699,7 +699,7 @@ Process a computation graph for MLIR conversion. --- - + ### method `relu` @@ -713,7 +713,7 @@ relu(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `reshape` @@ -727,7 +727,7 @@ reshape(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `right_shift` @@ -741,7 +741,7 @@ right_shift(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `round_bit_pattern` @@ -759,7 +759,7 @@ round_bit_pattern( --- - + ### method `simplify_tag` @@ -771,7 +771,7 @@ Keep only `n` higher tag parts. --- - + ### method `squeeze` @@ -785,7 +785,7 @@ squeeze(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `stdout_with_ansi_support` @@ -797,7 +797,7 @@ Detect if ansi characters can be used (e.g. not the case in notebooks). --- - + ### method `subtract` @@ -811,7 +811,7 @@ subtract(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `sum` @@ -825,7 +825,7 @@ sum(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `tfhers_from_native` @@ -843,7 +843,7 @@ tfhers_from_native( --- - + ### method `tfhers_to_native` @@ -857,7 +857,7 @@ tfhers_to_native(ctx: Context, node: Node, preds: List[Conversion]) → Conversi --- - + ### method `tlu` @@ -871,7 +871,7 @@ tlu(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### classmethod `tlu_adjust` @@ -885,7 +885,7 @@ tlu_adjust(table, variable_input, target_bit_width, clipping, reduce_precision) --- - + ### classmethod `trace_progress` @@ -910,7 +910,7 @@ Add a trace_message for progress. --- - + ### method `transpose` @@ -924,7 +924,7 @@ transpose(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `truncate_bit_pattern` @@ -942,7 +942,7 @@ truncate_bit_pattern( --- - + ### method `where` @@ -956,7 +956,7 @@ where(ctx: Context, node: Node, preds: List[Conversion]) → Conversion --- - + ### method `zeros` diff --git a/docs/dev/api/concrete.fhe.mlir.utils.md b/docs/dev/api/concrete.fhe.mlir.utils.md index 94e5ee4c75..66eb96debe 100644 --- a/docs/dev/api/concrete.fhe.mlir.utils.md +++ b/docs/dev/api/concrete.fhe.mlir.utils.md @@ -94,7 +94,7 @@ construct_deduplicated_tables( node: Node, preds: List[Node], configuration: Configuration -) → Tuple[Tuple[ndarray, Optional[List[Tuple[int, ]]]], ] +) → Tuple[Tuple[ndarray, Union[List[Tuple[int, ]], NoneType]], ] ``` Construct lookup tables for each cell of the input for an Operation.Generic node. diff --git a/docs/dev/api/concrete.fhe.representation.graph.md b/docs/dev/api/concrete.fhe.representation.graph.md index f0cdafcfdd..91428a0b2b 100644 --- a/docs/dev/api/concrete.fhe.representation.graph.md +++ b/docs/dev/api/concrete.fhe.representation.graph.md @@ -204,7 +204,7 @@ integer_range( operation_filter: Optional[str, List[str], Pattern] = None, is_encrypted_filter: Optional[bool] = None, custom_filter: Optional[Callable[[Node], bool]] = None -) → Optional[Tuple[int, int]] +) → Union[Tuple[int, int], NoneType] ``` Get integer range of the graph. diff --git a/docs/dev/api/concrete.fhe.tfhers.bridge.md b/docs/dev/api/concrete.fhe.tfhers.bridge.md index a39a193071..29d6ba6435 100644 --- a/docs/dev/api/concrete.fhe.tfhers.bridge.md +++ b/docs/dev/api/concrete.fhe.tfhers.bridge.md @@ -8,7 +8,7 @@ Declaration of `tfhers.Bridge` class. --- - + ## function `new_bridge` @@ -33,14 +33,14 @@ Create a TFHErs bridge from a circuit. --- - + ## class `Bridge` TFHErs Bridge extend a Circuit with TFHErs functionalities. -input_types (List[Optional[TFHERSIntegerType]]): maps every input to a type. None means a non-tfhers type output_types (List[Optional[TFHERSIntegerType]]): maps every output to a type. None means a non-tfhers type +input_types (List[Optional[TFHERSIntegerType]]): maps every input to a type. None means a non-tfhers type output_types (List[Optional[TFHERSIntegerType]]): maps every output to a type. None means a non-tfhers type input_shapes (List[Optional[Tuple[int, ...]]]): maps every input to a shape. None means a non-tfhers type output_shapes (List[Optional[Tuple[int, ...]]]): maps every output to a shape. None means a non-tfhers type - + ### method `__init__` @@ -48,7 +48,9 @@ input_types (List[Optional[TFHERSIntegerType]]): maps every input to a type. Non __init__( circuit: 'Circuit', input_types: List[Optional[TFHERSIntegerType]], - output_types: List[Optional[TFHERSIntegerType]] + output_types: List[Optional[TFHERSIntegerType]], + input_shapes: List[Optional[Tuple[int, ]]], + output_shapes: List[Optional[Tuple[int, ]]] ) ``` @@ -61,12 +63,12 @@ __init__( --- - + ### method `export_value` ```python -export_value(value: 'Value', output_idx: int) → bytes +export_value(value: Value, output_idx: int) → bytes ``` Export a value as a serialized TFHErs integer. @@ -75,7 +77,7 @@ Export a value as a serialized TFHErs integer. **Args:** - - `value` (fhe.Value): value to export + - `value` (TransportValue): value to export - `output_idx` (int): the index corresponding to this output @@ -86,7 +88,7 @@ Export a value as a serialized TFHErs integer. --- - + ### method `import_value` @@ -107,11 +109,11 @@ Import a serialized TFHErs integer as a Value. **Returns:** - - `fhe.Value`: imported value + - `fhe.TransportValue`: imported value --- - + ### method `keygen_with_initial_keys` @@ -146,7 +148,7 @@ Generate keys using an initial set of secret keys. --- - + ### method `serialize_input_secret_key` diff --git a/docs/dev/api/concrete.fhe.tfhers.dtypes.md b/docs/dev/api/concrete.fhe.tfhers.dtypes.md index 416426c741..95d101f109 100644 --- a/docs/dev/api/concrete.fhe.tfhers.dtypes.md +++ b/docs/dev/api/concrete.fhe.tfhers.dtypes.md @@ -110,7 +110,7 @@ __init__( --- - + ### method `decode` diff --git a/docs/dev/api/concrete.fhe.tfhers.md b/docs/dev/api/concrete.fhe.tfhers.md index e0c6691737..38ace4d5e3 100644 --- a/docs/dev/api/concrete.fhe.tfhers.md +++ b/docs/dev/api/concrete.fhe.tfhers.md @@ -20,4 +20,34 @@ tfhers module to represent, and compute on tfhers integer values. - **values** - **tracing** +--- + + + +## function `get_type_from_params` + +```python +get_type_from_params( + path_to_params_json: str, + is_signed: bool, + precision: int +) → TFHERSIntegerType +``` + +Get a TFHE-rs integer type from TFHE-rs parameters in JSON format. + + + +**Args:** + + - `path_to_params_json` (str): path to the TFHE-rs parameters (JSON format) + - `is_signed` (bool): sign of the result type + - `precision` (int): precision of the result type + + + +**Returns:** + + - `TFHERSIntegerType`: constructed type from the loaded parameters + diff --git a/docs/dev/api/concrete.fhe.tracing.tracer.md b/docs/dev/api/concrete.fhe.tracing.tracer.md index 1db0953895..60f4500133 100644 --- a/docs/dev/api/concrete.fhe.tracing.tracer.md +++ b/docs/dev/api/concrete.fhe.tracing.tracer.md @@ -61,7 +61,7 @@ Trace numpy.ndarray.size. ```python astype( - dtype: Union[dtype[Any], NoneType, type[Any], _SupportsDType[dtype[Any]], str, tuple[Any, int], tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], list[Any], _DTypeDict, tuple[Any, Any], Type[ForwardRef('ScalarAnnotation')]] + dtype: Union[dtype[Any], NoneType, Type[Any], _SupportsDType[dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], _DTypeDict, Tuple[Any, Any], Type[ForwardRef('ScalarAnnotation')]] ) → Tracer ``` @@ -247,7 +247,7 @@ Trace numpy.ndarray.size. ```python astype( - dtype: Union[dtype[Any], NoneType, type[Any], _SupportsDType[dtype[Any]], str, tuple[Any, int], tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], list[Any], _DTypeDict, tuple[Any, Any], Type[ForwardRef('ScalarAnnotation')]] + dtype: Union[dtype[Any], NoneType, Type[Any], _SupportsDType[dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], _DTypeDict, Tuple[Any, Any], Type[ForwardRef('ScalarAnnotation')]] ) → Tracer ``` @@ -433,7 +433,7 @@ Trace numpy.ndarray.size. ```python astype( - dtype: Union[dtype[Any], NoneType, type[Any], _SupportsDType[dtype[Any]], str, tuple[Any, int], tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], list[Any], _DTypeDict, tuple[Any, Any], Type[ForwardRef('ScalarAnnotation')]] + dtype: Union[dtype[Any], NoneType, Type[Any], _SupportsDType[dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], _DTypeDict, Tuple[Any, Any], Type[ForwardRef('ScalarAnnotation')]] ) → Tracer ``` @@ -619,7 +619,7 @@ Trace numpy.ndarray.size. ```python astype( - dtype: Union[dtype[Any], NoneType, type[Any], _SupportsDType[dtype[Any]], str, tuple[Any, int], tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], list[Any], _DTypeDict, tuple[Any, Any], Type[ForwardRef('ScalarAnnotation')]] + dtype: Union[dtype[Any], NoneType, Type[Any], _SupportsDType[dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], _DTypeDict, Tuple[Any, Any], Type[ForwardRef('ScalarAnnotation')]] ) → Tracer ``` diff --git a/docs/dev/api/concrete.fhe.version.md b/docs/dev/api/concrete.fhe.version.md index 374226348a..d6b4955cdc 100644 --- a/docs/dev/api/concrete.fhe.version.md +++ b/docs/dev/api/concrete.fhe.version.md @@ -3,9 +3,7 @@ # module `concrete.fhe.version` - - - +Version of the project, which is updated automatically by the CI right before releasing.