fix: use less confusing defaults for p error configurations

This commit is contained in:
Umut
2023-01-05 13:02:40 +01:00
parent 0c470852c3
commit 0c4dbe7e8e
6 changed files with 23 additions and 7 deletions

View File

@@ -5,6 +5,8 @@ Export everything that users might need.
from concrete.compiler import EvaluationKeys, PublicArguments, PublicResult
from .compilation import (
DEFAULT_GLOBAL_P_ERROR,
DEFAULT_P_ERROR,
Circuit,
Client,
ClientSpecs,

View File

@@ -6,6 +6,6 @@ from .artifacts import DebugArtifacts
from .circuit import Circuit
from .client import Client
from .compiler import Compiler, EncryptionStatus
from .configuration import Configuration
from .configuration import DEFAULT_GLOBAL_P_ERROR, DEFAULT_P_ERROR, Configuration
from .server import Server
from .specs import ClientSpecs

View File

@@ -6,6 +6,9 @@ from copy import deepcopy
from pathlib import Path
from typing import Optional, Union, get_type_hints
DEFAULT_P_ERROR = None
DEFAULT_GLOBAL_P_ERROR = 1 / 100_000
class Configuration:
"""
@@ -70,7 +73,7 @@ class Configuration:
auto_parallelize: bool = False,
jit: bool = False,
p_error: Optional[float] = None,
global_p_error: Optional[float] = (1 / 100_000),
global_p_error: Optional[float] = None,
auto_adjust_rounders: bool = False,
):
self.verbose = verbose

View File

@@ -23,7 +23,7 @@ from concrete.compiler import (
)
from ..internal.utils import assert_that
from .configuration import Configuration
from .configuration import DEFAULT_GLOBAL_P_ERROR, DEFAULT_P_ERROR, Configuration
from .specs import ClientSpecs
@@ -110,6 +110,17 @@ class Server:
options.set_global_p_error(1.0)
options.set_p_error(configuration.p_error)
else: # pragma: no cover
if DEFAULT_GLOBAL_P_ERROR is not None:
options.set_global_p_error(DEFAULT_GLOBAL_P_ERROR)
else:
options.set_global_p_error(1.0)
if DEFAULT_P_ERROR is not None:
options.set_p_error(DEFAULT_P_ERROR)
else:
options.set_p_error(1.0)
show_optimizer = (
configuration.show_optimizer
if configuration.show_optimizer is not None

View File

@@ -18,7 +18,7 @@ However, if you set `global_p_error` to `0.01`, the whole circuit will have 1% p
If you set both of them, both will be satisfied. Essentially, the stricter one will be used.
By default, `p_error` is set to `None` and `global_p_error` is set to `1 / 100_000`. Feel free to play with these configuration options to pick the one best suited for your needs! For example, in some machine learning use cases, off-by-one or off-by-two errors doesn't affect the result much, in such cases `p_error` could be set to increase performance without losing accuracy.
By default, both `p_error` and `global_p_error` is set to `None`, which results in `global_p_error` of `1 / 100_000` being used. Feel free to play with these configuration options to pick the one best suited for your needs! For example, in some machine learning use cases, off-by-one or off-by-two errors doesn't affect the result much, in such cases `p_error` could be set to increase performance without losing accuracy.
See [How to Configure](../howto/configure.md) to learn how you can set a custom `p_error` and/or `global_p_error`.

View File

@@ -74,10 +74,10 @@ Additional kwarg to `compile` function have higher precedence. So if you set an
* Whether to adjust rounders automatically.
* **p_error**: Optional[float] = None
* Error probability for individual table lookups. If set, all table lookups will have the probability of non-exact result smaller than the set value.
* Error probability for individual table lookups. If set, all table lookups will have the probability of non-exact result smaller than the set value. See [Exactness](../getting-started/exactness.md) to learn more.
* **global_p_error**: Optional[float] = (1 / 100_000)
* Global error probability for the whole circuit. If set, the whole circuit will have the probability of non-exact result smaller than the set value.
* **global_p_error**: Optional[float] = None
* Global error probability for the whole circuit. If set, the whole circuit will have the probability of non-exact result smaller than the set value. See [Exactness](../getting-started/exactness.md) to learn more.
* **jit**: bool = False
* Whether to use JIT compilation.