Commit Graph

2944 Commits

Author SHA1 Message Date
Antoniu Pop
81eaaa7560 feat(compiler): add multi-gpu scheduler for batched ops. Scheduler splits op batches in chunks to fit GPU memory and balance load across GPUs. 2023-06-12 22:51:30 +01:00
Andi Drebes
38e14446d6 feat(compiler): Batching: Add pattern folding operations on tensors of constants
This adds a new pattern to the batching pass that folds operations on
tensors of constants into new tensors of constants. E.g.,

  %cst = arith.constant dense<...> : tensor<Nxi9>
  %res = scf.for %i = %c0 to %cN {
    %cst_i9 = tensor.extract %cst[%i]
    %cst_i64 = arith.extui %cst_i9 : i64
    ...
  }

becomes:

  %cst = arith.constant dense<...> : tensor<Nxi64>
  %res = scf.for %i = %c0 to %cN {
    %cst_i64 = tensor.extract %cst[%i]
    ...
  }

The pattern only works for static loops, indexes that are quasi-affine
expressions on single loop induction variables with a constant step
size across iterations and foldable operations that have a single
result.
2023-06-12 22:51:30 +01:00
Andi Drebes
3516ae7682 feat(compiler): Add option for maximum batch size to batching pass
This adds a new compilation option `maxBatchSize` and a command line
option `--max-batch-size` to `concretecompiler`.
2023-06-12 22:51:30 +01:00
Andi Drebes
38a5b5e928 feat(compiler): Add support for batching with multiple batchable operands
The current batching pass only supports batching of operations that
have a single batchable operand, that can only be batched in one way
and that operate on scalar values. However, this does not allow for
efficient batching of all arithmetic operations in TFHE, since these
are often applied to pairs of scalar values from tensors, to tensors
and scalars or to tensors that can be grouped in higher-order tensors.

This commit introduces three new features for batching:

  1. Support of multiple batchable operands

     The operation interface for batching now allows for the
     specification of multiple batchable operands. This set can be
     composed of any subset of an operation's operands, i.e., it is
     not limited to sets of operands with contiguous operand indexes.

  2. Support for multiple batching variants

     To account for multiple kinds of batching, the batching operation
     interface `BatchableOpInterface` now supports variants. The
     batching pass attempts to batch an operation by trying the
     batching variants expressed via the interface in order until it
     succeeds.

  3. Support for batching of tensor values

     Some operations that could be batched already operate on tensor
     values. The new batching pass detects those patterns and groups
     the batchable tensors' values into higher-dimensional tensors.
2023-06-12 22:51:30 +01:00
Antoniu Pop
20394368bf feat(compiler): add lowering of batched mapped bootstrap operations to wrappers and SDFG, with support in the runtime. 2023-06-12 22:51:30 +01:00
Andi Drebes
5a6ed84076 fix(compiler): Batching: Do not attempt to extract static bounds for dynamic loops
The batching pass erroneously assumes that any expression solely
composed of an induction variable has static bounds. This commit adds
a test for the lower bound, upper bound and step checking that they
are indeed static before attempting to determine their static values.
2023-06-12 22:51:30 +01:00
Antoniu Pop
3a679a6f0a feat(compiler): add mapped version of batched bootstrap wrappers for CPU and GPU. 2023-06-12 22:51:30 +01:00
Antoniu Pop
7407948b18 test(compiler): add SDFG as default to GPU backend options and batched SDFG GPU test. 2023-06-12 22:51:30 +01:00
Antoniu Pop
3f9f228a23 feat(compiler): add runtime support for batched operations in SDFG/GPU. 2023-06-12 22:51:30 +01:00
Antoniu Pop
60412f7f61 feat(compiler): add SDFG op generation for batched operations. 2023-06-12 22:51:30 +01:00
Antoniu Pop
3f230957cb feat(compiler): add batched operations for all levelled ops. 2023-06-12 22:51:30 +01:00
Antoniu Pop
799e64e8ab feat(compiler): add task creation using vectors of futures as inputs and outputs. 2023-06-12 22:51:30 +01:00
Andi Drebes
d94993ede2 fix(compiler): Replace in-place updated with conversion patterns when lowering TFHE to Concrete
The current scheme with in-place updates of the types of values may
result in operations recognized as legal and thus preventing them from
being converted when the operations producing their operands have been
converted earlier, as their types have been updated and legality is
solely based on types.

For example, the conversion pattern for an `tensor.insert_slice`
operation working on tensors of encrypted values may not trigger if
the operations producing its operands have been converted, leaving the
operation with updated operand types with the extra dimension added by
the type conversion from TFHE to Concrete, but with unmodified sizes,
strides and offsets, not taking into account the extra dimension. This
causes the verifier of the affected operation to fail and the
compilation to abort.

By using op conversion patterns, the original types of each operation
are preserved during the actual rewrite, correctly triggering all
conversion patterns based on the legality of data types.
2023-06-12 22:51:30 +01:00
Umut
3ec17a74b6 feat(frontend-python): support python 3.11 2023-06-12 14:34:23 +02:00
Umut
0845921f3a refactor(compiler-bindings): rename create to new in python bindings 2023-06-09 17:41:41 +02:00
Umut
b0f83ebe97 refactor(frontend-python): rename Data to Value 2023-06-09 17:41:41 +02:00
Umut
8a3e24d204 refactor(frontend-python): rename Value to ValueDescription 2023-06-09 17:41:41 +02:00
youben11
9c077852bb feat(compiler): load lib compilation result from directory 2023-06-09 14:30:46 +01:00
Umut
c8cc8a811d feat(frontend-python): separate arguments 2023-06-09 13:01:27 +02:00
Umut
71d511756a chore(frontend-python): fix local test failures on ANSI terminals 2023-06-09 13:01:27 +02:00
Umut
27d081e255 feat(compiler/bindings): create bindings for value management 2023-06-09 13:01:27 +02:00
Bourgerie Quentin
f7f94a1663 feat(compiler/client-lib): Implement ValueExporter to allows partial encryption 2023-06-09 13:01:27 +02:00
aquint-zama
17f1107231 chore(common): add a Code of Conduct 2023-06-08 14:52:47 +02:00
Ayoub Benaissa
91b4fcc208 fix(compiler/frontend): provide ld in the docker image
the concrete-python docker image didn't have the `ld` binary, which is required during compilation
2023-06-07 17:28:44 +01:00
Ayoub Benaissa
a689dba8d7 fix(compiler/rust): fix const declaration of target-specific static libs
for aarch64
2023-06-07 12:42:50 +01:00
youben11
c4232eb71a feat(compiler/ci): enable rust bindings tests 2023-06-05 17:48:01 +01:00
youben11
c0e9f94810 fix(compiler): fix linking of the rust bindings 2023-06-05 17:48:01 +01:00
youben11
aae05e60c6 feat(compiler): copy cpp optim lib into output lib dir
this makes sure it will be installed as part of the compiler, as needed
currently by the rust bindings
2023-06-05 17:48:01 +01:00
youben11
566f119a06 feat(backend): expose random gaussian function 2023-06-05 16:48:52 +01:00
Andi Drebes
83c1654768 fix(compiler): Move operations in scf.for reinstantiation pattern before replacement
The reinstantianting rewrite pattern for `scf.for` operations,
`TypeConvertingReinstantiationPattern<scf::ForOp, false>`, calls
`mlir::ConversionPatternRewriter::replaceOpWithNewOp()` before moving
the operations of the original loop to the newly created loop. Since
`replaceOpWithNewOp()` indirectly marks all operations of the old loop
as ignored for dialect conversion, the dialect converter never
descends recursively into the newly created loop.

This causes operations that are illegal to be preserved, which results
in illegal IR after dialect conversion.

This commit splits the replacement into three steps:

  1. Creation of the new loop via
     mlir::ConversionPatternRewriter::create()`
  2. Moving operations from the old loop to the newly created one
  3. Replacement of the original loop with the results of the new one
     via `mlir::ConversionPatternRewriter::replaceOp()`

This causes the operations of the loops not to be ignored and fixes
dialect conversion.
2023-05-30 16:56:39 +02:00
rudy
07d97f266d feat(frontend-python): display progress during fhe execution 2023-05-26 15:56:23 +02:00
rudy
07e0f93001 fix(optimizer/ci): benchmark commit comment 2023-05-25 03:51:17 -04:00
Bourgerie Quentin
f487432207 fix(compiler): fold mul and matmul by zero to zero
That will close https://github.com/zama-ai/concrete-internal/issues/297 also for dag-multi optimization
2023-05-25 03:48:33 -04:00
Agnes Leroy
3561b51329 bench(backend-gpu): add multi-gpu support in pbs benchmark
Remove amortized PBS bench & bench with copy as well, it is deprecated
2023-05-24 15:32:20 +02:00
Antoniu Pop
900018c44e fix(compiler): increase the maximum number of DFR task inputs to 50. Split generated switches in separate files. 2023-05-24 09:56:34 +02:00
Agnes Leroy
72ee8eb572 fix(backend-gpu): decrease opt values for N >= 2048 for new low lat pbs 2023-05-23 11:34:53 +02:00
Quentin Bourgerie
caee0bae66 fix(compiler): Workaround fallback to Strategy::V0 when solving with Strategy::DAG_MONO
close https://github.com/zama-ai/concrete-internal/issues/297
2023-05-23 04:00:56 -04:00
Quentin Bourgerie
0bdb85b67d refactor(compiler/clientlib): Remove the building of the calling convention in the EncryptedArguments and test serialization in end_to_end_tests 2023-05-22 16:21:33 -04:00
rudy
b3ec478de9 fix(optimizer): optimize partition in reverse order
note: it was initially the case, but it was simplified and we didn't see shortcomings on tests.
2023-05-22 18:22:46 +02:00
Umut
fdfd4760f1 refactor(frontend-python): matmul and dot tests to be consistent with the rest of the tests 2023-05-18 09:15:27 +02:00
Umut
9e73a20d1e fix(frontend-python): accept full range of clear arguments 2023-05-18 09:15:27 +02:00
Umut
01850f68e6 test(frontend-python): increase the number of retries for encrypted matmul and encrypted dot tests 2023-05-18 09:15:27 +02:00
Agnes Leroy
b174f81687 fix(backend-gpu): avoid warp branching in the PBS 2023-05-17 15:01:37 +02:00
rudy
577e7847c6 fix(common): .gitmodules, relative url to stay on ssh or https 2023-05-17 14:15:16 +02:00
Quentin Bourgerie
5df44ad6f8 chore(compiler/build): Remove script to get BUILD_DIR 2023-05-17 13:57:37 +02:00
Umut
b6b6a642d8 test(frontend-python): add edge error tests for encrypted matmul and dot 2023-05-16 15:29:02 +02:00
Umut
fe314b140c fix(frontend-python): add dot to multiplication group during bit-width assignment 2023-05-16 15:29:02 +02:00
Umut
73c1aec7bd chore(frontend-python): fix pylint warnings 2023-05-16 15:29:02 +02:00
Umut
6d16d34b22 fix(frontend-python): add missing error messages on high bit-width encrypted dot and matmul 2023-05-16 15:29:02 +02:00
Umut
52cc0c108a fix(frontend-python): update outdated tests after bit-width optimizations 2023-05-16 15:29:02 +02:00