Commit Graph

885 Commits

Author SHA1 Message Date
rudy
ddb2b7fa58 fix(ci): more robust keysetcache download 2022-11-29 09:28:57 +01:00
Luis Montero
30be8cf4ae fix: fix MacOS test launching
* Update makefile to use appropriate arguments to find executables on
  macos systems.
* Add `set -e` to make sure that the tests crash if something goes wrong
  in the build or test of the macos job of the CI.

closes #783
2022-11-25 09:48:45 +01:00
Quentin Bourgerie
3bade6603a fix(compiler): Fix lowering of tensor.from_elements with crt 2022-11-24 16:30:37 +01:00
Quentin Bourgerie
5d89ad0f84 enhance(feedback): Add p_error and global_perror to the compiler feedback 2022-11-24 09:59:19 +01:00
Umut
722e4d2eba feat: give crt decomposition feedback 2022-11-24 09:59:19 +01:00
David Testé
1e8c0df381 chore(ci): change benchmark parser input name
The use of "schema" was incorrect since it's meant to be used as
database name when sending data to Slab.
2022-11-23 16:22:17 +01:00
youben11
7f65f4f527 fix(ci): set env var to look for lib in build/lib
LD_LIBRARY_PATH is set to BUILD_DIR/lib during rust tests in order to
find the runtime lib which it depends on
2022-11-23 14:01:25 +01:00
youben11
2877281aa6 chore(ci): re-enable rust tests in the CI
they were mostly removed by a rebase
2022-11-23 14:01:25 +01:00
youben11
96c958bd06 feat(rust): add compiler module with round_trip feature 2022-11-23 14:01:25 +01:00
youben11
5661b758d7 feat(CAPI): add initial API to do round-tripping with CompilerEngine 2022-11-23 14:01:25 +01:00
youben11
824aaaeff5 refactor(rust): separate generated CAPI under ffi module 2022-11-23 14:01:25 +01:00
youben11
c0d007e396 refactor: separate python bindings wrapper from CAPI
current CAPI of CompilerEngine isn't really a CAPI. It's initial need
was for the python bindings to have access to the CompilerEngine through
a convenient API. So we now make a clear separation of CAPI and python
wrappers. So we now have wrappers functions, that can be implemented
using C/C++, and will be exposed to python via pybind11. And we have a
CAPI (still need fixing as it still contains C++ code), that can be used
as is, or to build bindings for other languages (such as Rust).
2022-11-23 14:01:25 +01:00
rudy
454edbb538 fix(ci): KeySetCache pruning was broken 2022-11-22 17:28:40 +01:00
rudy
c20b10194f fix: optimizer display, nan proba and 0 complexity
Resolves zama-ai/concrete-optimizer#201
Resolves zama-ai/concrete-optimizer#202
Resolves zama-ai/concrete-optimizer#204
2022-11-22 11:55:16 +01:00
Andi Drebes
fd362342f5 fix(compiler): Batching: Emit collapse/expand shape operations only for rank > 1
The batching pass passes operands to the batched operation as a flat,
one-dimensional vector produced through a `tensor.collapse_shape`
operation collapsing all dimensions of the original tensor of
operands. Similarly, the shape of the result vector of the batched
operation is expanded to the original shape afterwards using a
`tensor.expand_shape` operation.

The pass emits the `tensor.collapse_shape` and `tensor.expand_shape`
operations unconditionally, even for tensors, which already have only
a single dimension. This causes the verifiers of these operations to
fail in some cases, aborting the entire compilation process.

This patch lets the batching pass emit `tensor.collapse_shape` and
`tensor.expand_shape` for batched operands and batched results only if
the rank of the corresponding tensors is greater than one.
2022-11-21 14:53:43 +01:00
David Testé
3c2a75186f chore(ci): run ml benchmarks in a matrix with slab
This CI "feature" is meant to circumvent the 6 hours hard-limit
for a job in GitHub Action.
The benchmark is done using a matrix which is handled by Slab.
Here's the workflow:

  1. ML benchmarks are started in a fire and forget fashion via
     start_ml_benchmarks.yml
  2. Slab will read ci/slab.toml to get the AWS EC2 configuration
     and the matrix parameters
  3. Slab will launch at most max_parallel_jobs EC2 instances in
     parallel
  4. Each job will trigger ml_benchmark_subset.yml which will run
     only one of the generated YAML file via make generate-mlbench,
     based on the value of the matrix item they were given.
  5. As soon as a job is completed, the next one in the matrix
     will start promptly.

This is done until all the matrix items are exhausted.
2022-11-21 11:25:40 +01:00
Quentin Bourgerie
8e4be10eb9 chore(bench): Better number of ct for benchmarks 2022-11-21 11:18:23 +01:00
rudy
a8e2724b69 fix: use less error prone json parsing for CompilationFeedback
Both the error message and the type were wrong for complexity
2022-11-18 17:27:07 +01:00
Mayeul@Zama
0657767bae style(cmake): run format_cmake.sh 2022-11-18 15:15:41 +01:00
Mayeul@Zama
fa3556e8cc feat(CI): add cmake-format CI job 2022-11-18 15:15:41 +01:00
Andi Drebes
84e0742fbe test(compiler): Add check tests for batching pass 2022-11-18 12:06:07 +01:00
Andi Drebes
ef26c73cb8 test(compiler): Add end-to-end test for batched operations
This adds a new end-to-end test `apply_lookup_table_batched`, which
forces batching of Concrete operations when invoking the compiler
engine, indirectly causing the `concrete.bootstrap_lwe` and
`concrete.keyswitch_lwe` operations generated from the
`FHELinalg.apply_lookup_table` operation of the test to be batched
into `concrete.batched_bootstrap_lwe` and
`concrete.batched_keyswitch_lwe` operations. The batched operations
trigger the generation of calls to batching wrapper functions further
down the pipeline, effectively testing the lowering and implementation
of batched operations altogether.
2022-11-18 12:06:07 +01:00
Andi Drebes
46366eec41 feat(compiler): Add fallback implementations for batched keyswitch and bootstrap
Add default implementations for batched keyswitch and bootstrap, which
simply call the scalar versions of these operations in a loop.
2022-11-18 12:06:07 +01:00
Andi Drebes
9f153d2129 feat(compiler): ConcreteToBConcrete: Add patterns for batched keyswitch and bootstrap 2022-11-18 12:06:07 +01:00
Andi Drebes
d46db1bf69 feat(compiler): BConcrete: Add batched keyswitch and bootstrap 2022-11-18 12:06:07 +01:00
Andi Drebes
c9bb6541e9 feat(compiler): Add option --batch-concrete-ops and action dump-concrete-with-loops
The new option `--batch-concrete-ops` invokes the batching pass after
lowering to the Concrete dialect and after lowering linalg operations
with operations from the Concrete dialect to loops.

The new action `dump-concrete-with-loops` dumps the IR right before
batching.
2022-11-18 12:06:07 +01:00
Andi Drebes
75b70054b2 feat(compiler): Make Concrete.bootstrap_lwe and Concrete.keyswitch_lwe batchable 2022-11-18 12:06:07 +01:00
Andi Drebes
c367a4b6fd feat(compiler): Add batching pass
This adds a new pass that is able to hoist operations implementing the
`BatchableOpInterface` out of a loop nest that applies the operation
to the elements of a tensor indexed by the loop induction variables.

Example:

  scf.for %i = c0 to %cN step %c1 {
    scf.for %j = c0 to %cM step %c1 {
      scf.for %k = c0 to %cK step %c1 {
        %s = tensor.extract %T[%i, %j, %k]
        %res = batchable_op %s
        ...
      }
    }
  }

is replaced with:

  %batchedSlice = tensor.extract_slice
       %T[%c0, %c0, %c0] [%cN, %cM, %cK] [%c1, %c1, %c1]
  %flatSlice = tensor.collapse_shape %batchedSlice
  %resTFlat = batchedOp %flatSlice
  %resT = tensor.expand_shape %resTFlat

  scf.for %i = c0 to %cN step %c1 {
    scf.for %j = c0 to %cM step %c1 {
      scf.for %k = c0 to %cK step %c1 {
        %res = tensor.extract %resT[%i, %j, %k]
        ...
      }
    }
  }

Every index of the tensor with the input values may be a quasi-affine
expression on a single loop induction variable, as long as the
difference between the results of the expression for any two
consecutive values of the referenced loop induction variable is
constant.
2022-11-18 12:06:07 +01:00
Andi Drebes
3ce7c96f3f feat(compiler): Add operation interface for batchable operations
This adds a new operation interface that allows an operation to
specify that a batched version of the operation exists that applies it
on the elements of a flat tensor in parallel.
2022-11-18 12:06:07 +01:00
Antoniu Pop
c5ceccaeee tests: disable dataflow tests when compiler not built with dataflow support. 2022-11-17 16:37:44 +00:00
youben11
52d5d908bb test(rust): complete tests of rust bindings
updated also the API to make it easier to use by:
- creating MLIR components from native rust types instead of require
  MLIR components in the API
- adding helpers around the creation of standard dialects
2022-11-17 09:54:51 +01:00
youben11
5b46a74b7f feat(CAPI): API to get the width of an eint/esint 2022-11-17 09:54:51 +01:00
youben11
5576d1d176 feat(CAPI): expose encrypted signed int in CAPI 2022-11-17 09:54:51 +01:00
youben11
0a57af37af feat(rust): add API for FHEDialect's op creation 2022-11-17 09:54:51 +01:00
youben11
ff3f1afd59 refactor(rust): separate API into modules
- mlir module contains the MLIR API and generic helper functions
- fhe module contains helper functions for the FHE dialect
2022-11-17 09:54:51 +01:00
youben11
5e1a6f0069 feat(rust): complete FHE dialect API
helper functions to create all operations of the FHE dialect
2022-11-17 09:54:51 +01:00
Luis Montero
aad2a42634 chore(ffi): support ARM64 chips 2022-11-17 01:04:36 +01:00
rudy
76c58c6305 fix: optimizer AST update 2022-11-16 11:44:46 +01:00
Samuel Tap
8a231974f7 chore(ffi): update to concrete-ffi without fftw 2022-11-16 11:44:46 +01:00
David Testé
77729514e0 chore(ci): parse benchmark results to send to postgres instance
Previousely, we were sending parsed benchmark results to a
Prometheus instance. Do to its time-series nature, Prometheus would
downsample database content to avoid having to much data points
for a given range of time. While this behavior is good for a
continuous stream of data, like monitoring CPU load, it's not suited
for benchmarks. Indeed benchmarks are discrete events that would
occurr once in a while (i.e once a day). Downsampling would, at
some point, simply omit some of benchmarks results.
Using a regular SQL database like PostgreSQL solves this issue.
2022-11-15 16:18:25 +01:00
Mayeul@Zama
e99d8d6e2c chore: activate Wall Werror on Mac 2022-11-14 14:04:46 +01:00
Mayeul@Zama
f26abad001 chore(compiler): fix return-type-c-linkage 2022-11-14 14:04:46 +01:00
Mayeul@Zama
28594db536 chore(compiler): fix c++11-narrowing 2022-11-14 14:04:46 +01:00
Mayeul@Zama
aaad84ee63 chore(compiler): fix string-conversion 2022-11-14 14:04:46 +01:00
Mayeul@Zama
ddbf4cf8e4 chore(compiler): disable dollar-in-identifier-extension 2022-11-14 14:04:46 +01:00
Mayeul@Zama
2a6d1958fd chore(compiler): remove unused loopParallelize 2022-11-14 14:04:46 +01:00
Mayeul@Zama
dd62896bc8 chore(compiler): fix pessimizing-move 2022-11-14 14:04:46 +01:00
Mayeul@Zama
39c5d46a50 style(compiler): format CMakeLists.txt 2022-11-14 14:04:46 +01:00
rudy
1abea50ff8 chore(ci): only cancel continuous-integration.yml on PR update 2022-11-14 11:09:03 +01:00
rudy
1bce0f3c01 fix: error rate test, no p_error overriding global_p_error 2022-11-14 11:08:18 +01:00