Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is independent of the actual bit precision limitation? #114

Closed
maxwellgodv opened this issue Jul 31, 2023 · 4 comments
Closed

is independent of the actual bit precision limitation? #114

maxwellgodv opened this issue Jul 31, 2023 · 4 comments

Comments

@maxwellgodv
Copy link

maxwellgodv commented Jul 31, 2023

1690808205095 is independent of the actual bit precision limitation. May I know how to understand this sentence?What is actual bit precision limitation?
@andrei-stoian-zama
Copy link
Collaborator

1690808205095 is independent of the actual bit precision limitation. May I know how to understand this sentence?What is actual bit precision limitation?

Since Concrete Python 2.0 the simulation itself requires that the circuit respect the bit-width constraint. This constraint is: all inputs and intermediary values in the function to be compiled must be <=16bit if and only if lookup tables are used or univariate functions. If there are no lookup tables or univariate functions, you can exceed 16b with an upper bound determined by the operation that you perform.

If you want to measure maximum bitwidth that the circuit would attain you can use "tracing" like this:

import numpy as np
from concrete import fhe

configuration = fhe.Configuration(
    enable_unsafe_features=True,
    use_insecure_key_cache=True,
    insecure_key_cache_location=".keys",
    single_precision=False,
    parameter_selection_strategy=fhe.ParameterSelectionStrategy.MULTI,
)

@fhe.compiler({"x": "encrypted", "y": "encrypted"})
def f(x, y):
    return x + y

inputset = [
    (
        np.random.randint(0, 10, size=()),
        np.random.randint(0, 10, size=()),
    )
    for _ in range(100)
]
circuit = f.trace(inputset, configuration)

print(circuit.maximum_integer_bit_width())

@RomanBredehoft
Copy link
Collaborator

Just a quick note what @andrei-stoian-zama said above : the current Concrete-ML public version does not use Concrete Python 2.0 yet, but it will soon ! So currently, you might expect different constraints. For example, simulating circuits with 16 bits is possible, which is what is independent of the actual bit precision limitation was referring to. However, this won't be the case in the near future, so I would recommend you not to take this as granted 😉

@maxwellgodv
Copy link
Author

1690888094402 Can I measure maximum bitwidth like this? What are the current constraints?

@RomanBredehoft
Copy link
Collaborator

Yes this is indeed how to measure the maximum bit-width reached in the model ! You cannot execute a model in FHE if the model has a bit-width of 17 bits or more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants