Commit Graph

278 Commits

Author SHA1 Message Date
Alexandre Péré
e8ef48ffd8 feat(compiler): introduce concrete-protocol
This commit:
 + Adds support for a protocol which enables inter-op between concrete,
   tfhe-rs and potentially other contributors to the fhe ecosystem.
 + Gets rid of hand-made serialization in the compiler, and
   client/server libs.
 + Refactors client/server libs to allow more pre/post processing of
   circuit inputs/outputs.

The protocol is supported by a definition in the shape of a capnp file,
which defines different types of objects among which:
 + ProgramInfo object, which is a precise description of a set of fhe
   circuit coming from the same compilation (understand function type
   information), and the associated key set.
 + *Key objects, which represent secret/public keys used to
   encrypt/execute fhe circuits.
 + Value object, which represent values that can be transferred between
   client and server to support calls to fhe circuits.

The hand-rolled serialization that was previously used is completely
dropped in favor of capnp in the whole codebase.

The client/server libs, are refactored to introduce a modular design for
pre-post processing. Reading the ProgramInfo file associated with a
compilation, the client and server libs assemble a pipeline of
transformers (functions) for pre and post processing of values coming in
and out of a circuit. This design properly decouples various aspects of
the processing, and allows these capabilities to be safely extended.

In practice this commit includes the following:
 + Defines the specification in a concreteprotocol package
 + Integrate the compilation of this package as a compiler dependency
   via cmake
 + Modify the compiler to use the Encodings objects defined in the
   protocol
 + Modify the compiler to emit ProgramInfo files as compilation
   artifact, and gets rid of the bloated ClientParameters.
 + Introduces a new Common library containing the functionalities shared
   between the compiler and the client/server libs.
 + Introduces a functional pre-post processing pipeline to this common
   library
 + Modify the client/server libs to support loading ProgramInfo objects,
   and calling circuits using Value messages.
 + Drops support of JIT.
 + Drops support of C-api.
 + Drops support of Rust bindings.

Co-authored-by: Nikita Frolov <nf@mkmks.org>
2023-11-09 17:09:04 +01:00
Alexandre Péré
211dcd0ad7 fix(backend-cpu): fix rust lint error
See https://github.com/zama-ai/concrete/actions/runs/6690310177/job/18175401058#step:9:94
2023-11-03 12:04:16 +01:00
rudy
c67da66d86 feat(optimizer): multi-parameters, variance and cost value and coefficient compression 2023-10-31 14:00:27 +01:00
youben11
76b72b7feb fix(optimizer): avoid asserting on manp >= 1
zero tensor ops now use a MANP of 0
2023-10-03 16:17:27 +01:00
youben11
6a41c31370 fix(compiler): revert to old MANP values
this commit need to be reverted when we start computing the MANP on
linalg.genric ops
2023-10-03 16:17:27 +01:00
youben11
48b2d884c6 fix(compiler): use args to have an init MANP of 1
As the MANP value of zero tensors becomes 0 (instead of 1 previously) we
switch to using argument
2023-10-03 16:17:27 +01:00
youben11
64d0741c1b feat(compiler): support linalg.genric instead of FHELinalg ops in DF parallelization 2023-10-03 16:17:27 +01:00
youben11
88dd13756a feat(compiler): support linalg.generic in the MANP Analysis 2023-10-03 16:17:27 +01:00
youben11
e4835bd002 feat(compiler): support woppbs in simulation 2023-09-28 09:29:48 +01:00
youben11
cd0f02d99c feat(compiler): support crt encoding in scalars during simulation 2023-09-28 09:29:48 +01:00
youben11
4f2b44c9d8 feat(compiler): support compilation of CRT in simulation 2023-09-28 09:29:48 +01:00
rudy
c84372ec1f feat(optimizer): multi-parameters, direct variance and cost operation bound 2023-09-26 15:01:10 +02:00
rudy
7e6ce03b09 fix(optimizer): multi-parameters, DEBUG, display reason for lower bound 2023-09-26 15:00:29 +02:00
rudy
d64c9b0f25 fix(optimizer): multi-parameters, shorter_dump for the compiler --display-optimizer-choice 2023-09-25 15:55:22 +02:00
rudy
3cd26192bc fix(optimizer): incorrect broadcast shape 2023-09-25 15:53:19 +02:00
rudy
1c0a70f911 fix(compiler): conversion to optimizer dag, bad dot before signed lut
this has no effect apart making the shape incorrect
2023-09-25 15:53:19 +02:00
Umut
49dc0578f4 fix(compiler-bindings): don't crash on unknown location formats 2023-09-20 15:01:58 +02:00
rudy
90e62f551b feat(optimizer): multi-params, key sharing 2023-09-19 12:13:25 +02:00
Umut
5d3e4bb2d6 chore(compiler): decrease p_error for a flanky test 2023-09-18 12:42:50 +02:00
Alexandre Péré
d28bf3767b feat(compiler): adds support for dynamic luts in fhelinalg 2023-09-18 12:42:50 +02:00
Nikita Frolov
73a992f0a6 refactor(compiler): generalize noise calculation in FHE/FHELinalg
Instead of having one `getSQManp` implementation per op with a lot of repetition, the noise
calculation is now modular.

- Ops that implements`UnaryEint`/`BinaryInt`/`BinaryEint` interfaces share the operand noise
presence check.
- For many scalar ops no further calculation is needed. If it's not the case, an op can override
`sqMANP`.
- Integer operand types lookups are abstracted into `BinaryInt::operandIntType()`
- Finding largest operand value for a type is abstracted into `BinaryInt::operandMaxConstant`
- Noise calculation for matmul ops is simplified and it's now general enough to work for
`matmul_eint_int`, `matmul_int_eint` and `dot_eint_int` at once.
2023-09-12 14:51:53 +01:00
Bourgerie Quentin
d71201ff8c fix(compiler): Use FHE.zero_tensor instead of bufferization.alloc_tensor as alloc_tensor explictly has a alloc semantic, so it cannot be eliminated by dce 2023-09-11 15:08:49 +02:00
rudy
f4099936e2 fix(compiler): ci, format_cpp.sh, bug + better message 2023-09-11 14:19:08 +02:00
aPere3
1e726a50ed feat(compiler): add support for dynamic luts in compiler. 2023-09-11 10:29:59 +02:00
Alexandre Péré
083ab1103f chore(compiler): moves EncryptMulToDoubleTLU includes 2023-09-11 10:29:59 +02:00
aPere3
b58821b1d1 chore(compiler): refactor e2e tlu tests to use dynamic lut. 2023-09-11 10:29:59 +02:00
rudy
229bbc2327 fix(compiler): do not optimize llvm twice 2023-09-08 15:26:24 +02:00
rudy
74c4a7eae5 fix(compiler): check minimal lwe size 2023-09-08 14:26:32 +02:00
rudy
dc0a3d8a2e feat(optimizer): levelled circuit, no power of two constraint 2023-09-08 14:26:32 +02:00
rudy
be77fb26b8 feat(compiler): bench, cifar-16 2023-09-08 10:03:42 +02:00
rudy
4907577b1c feat(compiler): bench, llm, big mat mul 2023-09-08 10:03:42 +02:00
rudy
a28a7bf397 feat(compiler): bench, activate levelled ops 2023-09-08 10:03:42 +02:00
rudy
4244ae3b41 fix(compiler): explicit global_p_error disable high error warning 2023-09-07 09:20:37 +02:00
youben11
41e1fdf1f8 refactor(frontend): change location format 2023-09-04 09:22:28 +01:00
youben11
530bacb2e3 refactor(compiler): clean statistic passes 2023-09-04 09:22:28 +01:00
youben11
4e8b9a199c feat(compiler): allow forcing encoding from python 2023-09-01 10:29:08 +01:00
youben11
cba3847c92 feat(compiler): setting v0 parameters from py bindings 2023-09-01 10:29:08 +01:00
youben11
9e8c44ed00 feat(compiler/python): expose memory usage in bindings 2023-08-29 15:47:25 +01:00
youben11
54089186ae refactor(compiler): reorganize passes and add memory usage pass 2023-08-29 15:47:25 +01:00
youben11
d88b2c87ac feat(compiler): compute memory usage per location 2023-08-29 15:47:25 +01:00
rudy
7782f4e967 fix(optimizer): woppbs, cost model, cmux tree size x2 2023-08-28 14:47:54 +02:00
Ayoub Benaissa
c4686c3631 fix(compiler): lower fhe.zero to either scalar or tensor variant based on encoding
When using crt encoding, some fhe.zero op results will be converted to tensors (crt encoded eint), so should be converted to tfhe.zero_tensor operations instead of tfhe.zero
2023-08-11 18:23:29 +01:00
Bourgerie Quentin
245836b8ba fix(compiler): Fix conv2d with bias equals to zero in multi parameters
The zero bias was folded and lead to empty loops, i.e. loops with copy only and make the TFHE parametrization fail
2023-08-08 11:01:29 +02:00
Umut
9a5b08938e feat(compiler): support multi precision encrypted multiplications 2023-08-04 13:17:14 +02:00
rudy
2c348f6a3d chore(optimizer): update for nightly rust 2023-08-02 14:14:58 +02:00
Bourgerie Quentin
8e8b2dd8ed fix(compiler/tests): Fixing the generation of dot/matmul signed tests 2023-08-01 19:03:57 +02:00
Bourgerie Quentin
bd4540102c fix(compiler/multi-parameters): Fixing encrypted dot and encrypted matmul with multi-parameters 2023-08-01 19:03:57 +02:00
Bourgerie Quentin
ea65637796 fix(compiler/tests): Fixing some skipped tests laucnhed with gtest parallel
The gtest-parallel tools first list test names then launch in parallel the end_to_end_test tool with the gtest_filter=<test_name>,
so if in the test_name a - appears it skip it due the gtest filtering that treat the string after - as an exlude pattern
2023-08-01 19:03:57 +02:00
Umut
ade83d5335 feat(compiler): add more detailed statistics 2023-08-01 18:40:08 +02:00
rudy
8ff9158424 fix(optimizer): multi-parameters, levelled only circuit 2023-08-01 17:01:30 +02:00