Files
concrete/docs/dev/api/concrete.fhe.compilation.server.md
2025-01-07 09:17:59 +01:00

19 KiB

module concrete.fhe.compilation.server

Declaration of Server class.

Global Variables

  • DEFAULT_GLOBAL_P_ERROR
  • DEFAULT_P_ERROR

class Server

Server class, which can be used to perform homomorphic computation.

method __init__

__init__(
    library: Library,
    is_simulated: bool,
    composition_rules: Optional[List[CompositionRule]]
)

property client_specs

Return the associated client specs.


property complexity

Get complexity of the compiled program.


property global_p_error

Get the probability of having at least one simple TLU error during the entire execution.


property p_error

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.


property size_of_keyswitch_keys

Get size of the key switch keys of the compiled program.


property size_of_secret_keys

Get size of the secret keys of the compiled program.


method cleanup

cleanup()

Cleanup the temporary library output directory.


method clear_addition_count

clear_addition_count(function: str)  int

Get the number of clear additions in the compiled program.


method clear_addition_count_per_parameter

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

clear_addition_count_per_tag(function: str)  Dict[str, int]

Get the number of clear additions per tag in the compiled program.


method clear_addition_count_per_tag_per_parameter

clear_addition_count_per_tag_per_parameter(
    function: str
)  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

clear_multiplication_count(function: str)  int

Get the number of clear multiplications in the compiled program.


method clear_multiplication_count_per_parameter

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

clear_multiplication_count_per_tag(function: str)  Dict[str, int]

Get the number of clear multiplications per tag in the compiled program.


method clear_multiplication_count_per_tag_per_parameter

clear_multiplication_count_per_tag_per_parameter(
    function: str
)  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

create(
    mlir: Union[str, Module],
    configuration: Configuration,
    is_simulated: bool = False,
    compilation_context: Optional[CompilationContext] = None,
    composition_rules: Optional[Iterable[CompositionRule]] = None
)  Server

Create a server using MLIR and output sign information.

Args: mlir (MlirModule): mlir to compile

is_simulated (bool, default = False): whether to compile in simulation mode or not

configuration (Optional[Configuration]): configuration to use

compilation_context (CompilationContext): context to use for the Compiler

composition_rules (Iterable[Tuple[str, int, str, int]]): composition rules to be applied when compiling


method encrypted_addition_count

encrypted_addition_count(function: str)  int

Get the number of encrypted additions in the compiled program.


method encrypted_addition_count_per_parameter

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

encrypted_addition_count_per_tag(function: str)  Dict[str, int]

Get the number of encrypted additions per tag in the compiled program.


method encrypted_addition_count_per_tag_per_parameter

encrypted_addition_count_per_tag_per_parameter(
    function: str
)  Dict[str, Dict[Union[LweSecretKeyParam, BootstrapKeyParam, KeyswitchKeyParam, PackingKeyswitchKeyParam], int]]

Get the number of encrypted additions per tag per parameter in the compiled program.


method encrypted_negation_count

encrypted_negation_count(function: str)  int

Get the number of encrypted negations in the compiled program.


method encrypted_negation_count_per_parameter

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

encrypted_negation_count_per_tag(function: str)  Dict[str, int]

Get the number of encrypted negations per tag in the compiled program.


method encrypted_negation_count_per_tag_per_parameter

encrypted_negation_count_per_tag_per_parameter(
    function: str
)  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

key_switch_count(function: str)  int

Get the number of key switches in the compiled program.


method key_switch_count_per_parameter

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

key_switch_count_per_tag(function: str)  Dict[str, int]

Get the number of key switches per tag in the compiled program.


method key_switch_count_per_tag_per_parameter

key_switch_count_per_tag_per_parameter(
    function: str
)  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

load(path: Union[str, Path], **kwargs)  Server

Load the server from the given path in zip format.

Args: path (Union[str, Path]): path to load the server from

kwargs (Dict[str, Any]): configuration options to overwrite when loading a server saved with via_mlir if server isn't loaded via mlir, kwargs are ignored

Returns: Server: server loaded from the filesystem


method memory_usage_per_location

memory_usage_per_location(function: str)  Dict[str, Optional[int]]

Get the memory usage of operations per location.


method packing_key_switch_count

packing_key_switch_count(function: str)  int

Get the number of packing key switches in the compiled program.


method packing_key_switch_count_per_parameter

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

packing_key_switch_count_per_tag(function: str)  Dict[str, int]

Get the number of packing key switches per tag in the compiled program.


method packing_key_switch_count_per_tag_per_parameter

packing_key_switch_count_per_tag_per_parameter(
    function: str
)  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

programmable_bootstrap_count(function: str)  int

Get the number of programmable bootstraps in the compiled program.


method programmable_bootstrap_count_per_parameter

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

programmable_bootstrap_count_per_tag(function: str)  Dict[str, int]

Get the number of programmable bootstraps per tag in the compiled program.


method programmable_bootstrap_count_per_tag_per_parameter

programmable_bootstrap_count_per_tag_per_parameter(
    function: str
)  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

run(
    *args: Optional[Value, Tuple[Optional[Value], ]],
    evaluation_keys: Optional[EvaluationKeys] = None,
    function_name: Optional[str] = None
)  Union[Value, Tuple[Value, ]]

Evaluate.

Args: *args (Optional[Union[Value, Tuple[Optional[Value], ...]]]): argument(s) for evaluation

evaluation_keys (Optional[EvaluationKeys], default = None): evaluation keys required for fhe execution

function_name (str): The name of the function to run

Returns: Union[Value, Tuple[Value, ...]]: result(s) of evaluation


method save

save(path: Union[str, Path], via_mlir: bool = False)

Save the server into the given path in zip format.

Args: path (Union[str, Path]): path to save the server

via_mlir (bool, default = False): export using the MLIR code of the program, this will make the export cross-platform


method size_of_inputs

size_of_inputs(function: str)  int

Get size of the inputs of the compiled program.


method size_of_outputs

size_of_outputs(function: str)  int

Get size of the outputs of the compiled program.