Commit Graph

199 Commits

Author SHA1 Message Date
Quentin Bourgerie
31d9f568fa refactor(test): Move HLFHELinalg e2e test 2021-10-29 12:18:30 +02:00
Quentin Bourgerie
a135d05e4d feat(compiler): Lowering of HLFHELinalg.mul_eint_int 2021-10-29 12:18:30 +02:00
Quentin Bourgerie
0b5ee3497a feat(compiler): Lowering of HLFHELinalg.sub_int_eint 2021-10-29 12:18:22 +02:00
Quentin Bourgerie
b81cb978d0 feat(compiler): Lowering of HLFHELinalg.add_eint_int 2021-10-29 12:17:38 +02:00
Quentin Bourgerie
a804e90291 fix(compiler): Fix lowering MidLFHE.add_glwe_int, the operand type can be already lowered 2021-10-29 12:17:38 +02:00
Quentin Bourgerie
ba54560680 feat(compiler): Lower HLFHELinalg binary operators 2021-10-29 12:17:38 +02:00
Quentin Bourgerie
dea1be9d52 feat(compiler): HLFHELinalg.apply_lookup_table definition 2021-10-29 12:17:38 +02:00
Quentin Bourgerie
f72d51d98d feat(compiler): HLFHELinalg.mul_eint_int 2021-10-29 12:17:38 +02:00
Quentin Bourgerie
64e327209f feat(compiler): HLFHELinalg.sub_int_eint 2021-10-29 12:17:32 +02:00
Quentin Bourgerie
3b02a16f7b feat(compiler): HLFHELinalg.add_eint definition 2021-10-29 12:16:41 +02:00
Quentin Bourgerie
0d4e10169b feat(compiler): Introduce the HLFHELinalg dialect and a first operator HLFHELinalg.add_eint_int 2021-10-29 12:16:41 +02:00
Quentin Bourgerie
247cc489c5 refactor(compiler): Refactor JITLambda::Argument::setArg 2021-10-21 14:40:07 +02:00
Quentin Bourgerie
b5f68c20c7 fix(compiler): Remove the default constraint since tensor operators are supported 2021-10-20 16:21:52 +02:00
Quentin Bourgerie
1c202ebaff enhance(compiler): Support of tensor operators in MANP pass (close #169) 2021-10-20 16:21:52 +02:00
Quentin Bourgerie
fcc992db2b chore(compiler): Rename std tensor test to clear tensor 2021-10-15 16:48:03 +02:00
Quentin Bourgerie
b6be5b5743 test(compiler): Test tensor.extract_slice and tensor.insert_slice with encrypted tensor #168 2021-10-15 16:47:53 +02:00
Quentin Bourgerie
d93da5bdc0 enhance(compiler): Handle tensor.extract_slice and tensor.insert_slice in the FHE lowering #168 2021-10-15 16:47:35 +02:00
Quentin Bourgerie
3e27592cd1 test(compiler): Add test on 2D clear tensor, tensor.extract, tensor.extract_slice, tensor.insert_slice #168 2021-10-15 16:47:35 +02:00
Quentin Bourgerie
3b2f21a715 enhance(compiler): Handle multi-dimensional tensor #167 2021-10-15 16:44:19 +02:00
Quentin Bourgerie
8aaeff525c test(compiler): Retry when an apply_lookup_table fail 2021-10-13 10:28:35 +02:00
Quentin Bourgerie
966160bc2c fix(compiler): apply_lookup_table operators take tensor of i64
We decide to make this choice as they are issue to crate tensor of custom integer type in python.
+ we don't do the integer extension before convert to the concrete CAPI that requires i64
2021-10-13 10:28:35 +02:00
Quentin Bourgerie
b7e9f12799 test(compiler): Enhance HLFHE.apply_lookup_table test, still need to make some distribution test 2021-10-13 10:28:35 +02:00
Quentin Bourgerie
8f4da14bdb fix(compiler): Pad constant tabulated lambda when the input precision of apply_lookup_table has been changed 2021-10-13 10:28:35 +02:00
youben11
6204f93878 fix: call getChecked to better handle failure 2021-10-12 16:57:18 +02:00
youben11
33d75a92f4 ci: remove logging of LLVM commit
the loggign is actually incorrect, as this would be the version of the
repo, not the one in the env, so it doesn't even make sense
2021-10-12 11:50:15 +01:00
youben11
01757fa6d5 fix: forward errors instead of creating new ones
LLVM errors should be handled/consumed. Creating a new one and leaving
the previous one alive will crash the compiler. Whenever we don't want a
crash (e.g. logging the error is enough), but still wanna continue the
execution, we can just consume it.
2021-10-12 11:50:15 +01:00
github-actions
1c030ac10b chore: update LLVM to f1e9ecea4 2021-10-11 01:45:15 +00:00
github-actions
e682394a6d chore: update LLVM to 02ac5e5cf 2021-10-09 11:44:46 +01:00
youben11
952968567b ci: update msg of LLVM auto-update commit 2021-10-09 11:44:46 +01:00
youben11
b30e09546b test: use 6bits only for LUT tests 2021-10-08 16:37:43 +01:00
youben11
5a308ddc75 fix(python): add missing import
Also added a test to catch future similar failure. Mainly, we didn't
have tests that imported and used the HLFHE dialect from the python
bindings
2021-10-08 14:21:45 +01:00
github-actions
86c127d198 Commit from GitHub Actions (LLVM Compatibility) 2021-10-08 13:13:28 +00:00
youben11
50236f4f18 ci: auto-update llvm 1/week if no breaking changes 2021-10-08 12:28:10 +01:00
youben11
ebdc95f827 chore: update llvm and fix API breaks 2021-10-08 12:11:34 +01:00
youben11
34f114cda9 ci: fix compatibility checks 2021-10-07 16:33:00 +01:00
youben11
8535ab797e ci: compatibility check workflows concretelib/llvm 2021-10-07 14:38:50 +01:00
youben11
bfc763144c ci: new unified build system 2021-10-07 14:38:50 +01:00
youben11
2972fa4403 refactor(python): rework the bindings with latest MLIR version
- Go through CAPI for python bindings
- Consuming LLVM errors in CAPI: fixes previous issue which made this
  impossible in the python bindings
2021-10-07 14:38:50 +01:00
youben11
3406b322d5 fix: prefix builtin ops w/ builtin. 2021-10-07 14:38:50 +01:00
youben11
09ad814e95 fix: use ref to PatternRewriter in NativeCodeCall 2021-10-07 14:38:50 +01:00
youben11
7a48900fae chore: build zamacompiler as an LLVM external proj 2021-10-07 14:38:50 +01:00
youben11
450925b7bf chore(python test): clean test case by adding ids 2021-10-07 14:38:50 +01:00
Mayeul@Zama
cb0e8b0e98 doc(compiler): update the instructions to build and test the compiler in the README 2021-09-29 11:16:05 +02:00
Andi Drebes
2acfa63eb7 feat(compiler): Determine FHE circuit constraints instead of using default values
This replaces the default FHE circuit constrains (maximum encrypted
integer width of 7 bits and a Minimal Arithmetic Noise Padding of 10
with the results of the `MaxMANP` pass, which determines these values
automatically from the input program.

Since the maximum encrypted integer width and the maximum value for
the Minimal Arithmetic Noise Padding can only be derived from HLFHE
operations, the circuit constraints are determined automatically by
`zamacompiler` only if the option `--entry-dialect=hlfhe` was
specified.

For lower-level dialects, `zamacompiler` has been provided with the
options `--assume-max-eint-precision=...` and `--assume-max-manp=...`
that allow a user to specify the values for the maximum required
precision and maximum values for the Minimal Arithmetic Noise Padding.
2021-09-28 11:35:58 +02:00
Andi Drebes
2ed1720234 bugfix(compiler): Do not apply offset of -1 to 2-norm in getV0Parameter
A value of 1 is perfectly valid for the 2-norm of the constant vector
of a dot operation. Hence, the log2 of that value of 0 is also
perfectly valid. However, the offset of -1 in `getV0Parameter` applied
to that value yields an offset into a static lookup table of -1, which
triggers a segmentation fault.

This patch removes the offset of -1 for the log2 value of the 2-norm
in `getV0Parameter`.
2021-09-28 11:35:58 +02:00
Andi Drebes
5ce3fd5f43 refactor(compiler): Move ceilLog2 to separate header file 2021-09-28 11:35:58 +02:00
Andi Drebes
1200a46e49 feat(compiler): Add HLFHE pass selecting maximum MANP and encrypted integer width
This pass calculates the squared Minimal Arithmetic Noise Padding
(MANP) for each operation using the MANP pass and extracts the maximum
(non-squared) Minimal Arithmetic Noise Padding and the maximum
ecrypted integer width from.
2021-09-28 11:35:58 +02:00
Andi Drebes
6a6fae96f6 test(compiler): Add tests for the Minimal Arithmetic Noise Padding analysis pass
This adds tests for the Minimal Arithmetic Noise Padding analysis pass
that is invoked with --debug-manp, testing both elementary operations
and DAGs of computations on encrypted integers.
2021-09-28 11:35:58 +02:00
Andi Drebes
54661528a8 feat(compiler): Add action dump-hlfhe-manp
The new option --acion=dump-hlfhe-manp invokes the Minimal Arithmetic
Noise Padding Analysis pass based on the squared 2-norm metric from
`lib/Dialect/HLFHE/Analysis/MANP.cpp` and dumps the module afterwards
with an extra attribute `MANP` for each HLFHE operation.
2021-09-28 11:35:58 +02:00
Andi Drebes
ed762942c1 feat(compiler): Add pass for Minimal Arithmetic Noise Padding
This pass calculates the squared Minimal Arithmetic Noise Padding
(MANP) for each operation of a function and stores the result in an
integer attribute named "sqMANP". This metric is identical to the
squared 2-norm of the constant vector of an equivalent dot product
between a vector of encrypted integers resulting directly from an
encryption and a vector of plaintext constants.

The pass supports the following operations:

 - HLFHE.dot_eint_int
 - HLFHE.zero
 - HLFHE.add_eint_int
 - HLFHE.add_eint
 - HLFHE.sub_int_eint
 - HLFHE.mul_eint_int
 - HLFHE.apply_lookup_table

If any other operation is encountered, the pass conservatively
fails. The pass further makes the optimistic assumption that all
values passed to a function are either the direct result of an
encryption of a noise-refreshing operation.
2021-09-28 11:35:58 +02:00