mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 03:25:05 -05:00
4.5 KiB
4.5 KiB
Configure
Concrete can be customized using Configurations:
from concrete import fhe
import numpy as np
configuration = fhe.Configuration(p_error=0.01, dataflow_parallelize=True)
@fhe.compiler({"x": "encrypted"})
def f(x):
return x + 42
inputset = range(10)
circuit = f.compile(inputset, configuration=configuration)
You can overwrite individual options as kwargs to the compile method:
from concrete import fhe
import numpy as np
@fhe.compiler({"x": "encrypted"})
def f(x):
return x + 42
inputset = range(10)
circuit = f.compile(inputset, p_error=0.01, dataflow_parallelize=True)
Or you can combine both:
from concrete import fhe
import numpy as np
configuration = fhe.Configuration(p_error=0.01)
@fhe.compiler({"x": "encrypted"})
def f(x):
return x + 42
inputset = range(10)
circuit = f.compile(inputset, configuration=configuration, loop_parallelize=True)
{% hint style="info" %}
Additional kwargs to compile functions take higher precedence. So if you set the option in both configuration and compile methods, the value in the compile method will be used.
{% endhint %}
Options
- show_graph: Optional[bool] = None
- Print computation graph during compilation.
Truemeans always print,Falsemeans never print,Nonemeans print depending on verbose configuration below.
- Print computation graph during compilation.
- show_mlir: Optional[bool] = None
- Print MLIR during compilation.
Truemeans always print,Falsemeans never print,Nonemeans print depending on verbose configuration below.
- Print MLIR during compilation.
- show_optimizer: Optional[bool] = None
- Print optimizer output during compilation.
Truemeans always print,Falsemeans never print,Nonemeans print depending on verbose configuration below.
- Print optimizer output during compilation.
- show_statistics: Optional[bool] = None
- Print circuit statistics during compilation.
Truemeans always print,Falsemeans never print,Nonemeans print depending on verbose configuration below.
- Print circuit statistics during compilation.
- verbose: bool = False
- Print details related to compilation.
- dump_artifacts_on_unexpected_failures: bool = True
- Export debugging artifacts automatically on compilation failures.
- auto_adjust_rounders: bool = False
- Adjust rounders automatically.
- p_error: Optional[float] = None
- Error probability for individual table lookups. If set, all table lookups will have the probability of a non-exact result smaller than the set value. See Exactness to learn more.
- global_p_error: Optional[float] = None
- Global error probability for the whole circuit. If set, the whole circuit will have the probability of a non-exact result smaller than the set value. See Exactness to learn more.
- single_precision: bool = True
- Use single precision for the whole circuit.
- parameter_selection_strategy: (fhe.ParameterSelectionStrategy) = fhe.ParameterSelectionStrategy.MONO
- Set how cryptographic parameters are selected.
- jit: bool = False
- Enable JIT compilation.
- loop_parallelize: bool = True
- Enable loop parallelization in the compiler.
- dataflow_parallelize: bool = False
- Enable dataflow parallelization in the compiler.
- auto_parallelize: bool = False
- Enable auto parallelization in the compiler.
- enable_unsafe_features: bool = False
- Enable unsafe features.
- use_insecure_key_cache: bool = False (Unsafe)
- Use the insecure key cache.
- insecure_key_cache_location: Optional[Union[Path, str]] = None
- Location of insecure key cache.
- show_progress: bool = False,
- Display a progress bar during circuit execution
- progress_title: str = "",
- Title of the progress bar
- progress_tag: Union[bool, int] = False,
- How many nested tag elements to display with the progress bar.
Truemeans all tag elements andFalsedisables the display.2will displayelmt1.elmt2
- How many nested tag elements to display with the progress bar.
- fhe_simulation: bool = False
- Enable FHE simulation. Can be enabled later using
circuit.enable_fhe_simulation().
- Enable FHE simulation. Can be enabled later using
- fhe_execution: bool = True
- Enable FHE execution. Can be enabled later using
circuit.enable_fhe_execution().
- Enable FHE execution. Can be enabled later using
- compiler_debug_mode: bool = False,
- Enable/disable debug mode of the compiler. This can show a lot of information, including passes and pattern rewrites.
- compiler_verbose_mode: bool = False,
- Enable/disable verbose mode of the compiler. This mainly show logs from the compiler, and is less verbose than the debug mode.