Commit Graph

376 Commits

Author SHA1 Message Date
Benoit Chevallier-Mames
e37a840e7e docs(compiler): adding API doc 2024-03-13 17:10:00 +01:00
Bourgerie Quentin
5370fb3cf9 fix(compiler): Do not reinstantiate csprng each time in the simulation backend 2024-03-13 16:28:52 +01:00
Bourgerie Quentin
9dcf1c4b6f feat(frontend-python): Expose compress_input_ciphertexts as a compilation options and tests 2024-03-12 17:58:40 +01:00
Bourgerie Quentin
3043573922 refactor(compiler/tests): Move bug and boolean to specific yaml files 2024-03-12 16:57:06 +01:00
Bourgerie Quentin
e0a7aaa479 test(compiler): Run all tests only on default options and run random tests on several options to tests 2024-03-12 16:57:06 +01:00
Bourgerie Quentin
1804081064 refactor(compiler): Refactor options naming of the end-to-end-test tool 2024-03-12 16:57:06 +01:00
Bourgerie Quentin
d3cb43b517 fix(compiler): Put dag-multi as default optimizer strategy 2024-03-12 16:57:06 +01:00
Bourgerie Quentin
721858346a refactor(compiler): Just reorder options for better readability 2024-03-12 16:57:06 +01:00
Bourgerie Quentin
2ac4f52ca5 feat(compiler/tests): Add random-tests options to end-to-end-test tool 2024-03-12 16:57:06 +01:00
Bourgerie Quentin
6b4ce8889b feat(compiler): Add input ciphertext compression with seeded ciphertext 2024-03-12 16:57:06 +01:00
Bourgerie Quentin
0fdc7d78ff perf(compiler): Use parallel implementation to decompress bs and ks keys 2024-03-11 16:51:05 +01:00
Andi Drebes
b9589146f4 test(compiler): Add tests generating explicit optimizer partition frontiers 2024-03-07 15:42:26 +01:00
Andi Drebes
9b6878316f fix(compiler): Preserve explicit optimizer partition boundaries through the pipeline
The Concrete Optimizer is invoked on a representation of the program
in the high-level FHELinalg / FHE Dialects and yields a solution with
a one-to-one mapping of operations to keys. However, the abstractions
used by these dialects do not allow for references to keys and the
application of the solution is delayed until the pipeline reaches a
representation of the program in the lower-level TFHE dialect. Various
transformations applied by the pipeline along the way may break the
one-to-one mapping and add indirections into producer-consumer
relationships, resulting in ambiguous or partial mappings of TFHE
operations to the keys. In particular, explicit frontiers between
optimizer partitions may not be recovered.

This commit preserves explicit frontiers between optimizer partitions
as `optimizer.partition_frontier` operations and lowers these to
keyswitch operations before parametrization of TFHE operations.
2024-03-07 15:42:26 +01:00
Andi Drebes
a701b3a742 feat(compiler): Add support for tensor.empty in the pipeline from FHE to std 2024-03-06 14:50:27 +01:00
Andi Drebes
8e660e2f75 feat(compiler): Add dialect with operations related to the optimizer
This adds a new dialect called `Optimizer` with operations related to
the Concrete Optimizer. Currently, there is only one operation
`optimizer.partition_frontier` that can be inserted between a producer
and a consumer which belong to different partitions computed by the
optimizer. The purpose of this operation is to preserve explicit key
changes from the invocation of the optimizer on high-level dialects
(i.e., FHELinalg / FHE) until the IR is provided with actual
references to keys in low-level dialects (i.e., TFHE).
2024-03-06 14:50:27 +01:00
Andi Drebes
3d16efb681 feat(compiler): Add functions for type inference debugging to TypeInferenceUtils
The main debugging function is
`TypeInferenceUtils::dumpAllState(mlir::Operation* op)` which dumps
the entire state of type inference for the function containing `op`.
2024-03-06 14:50:27 +01:00
Andi Drebes
282cacaef4 fix(compiler): Do not omit assignment of optimizer ID to FHE.reinterpret_precision
The DAG pass establishing a mapping between operations in the IR and
the optimizer DAG currently omits assignment of the optimizer ID to
`FHE.reinterpret_precision` operations via the `TFHE.OId`
attribute. This prevents subsequent passes from determining to which
optimizer partition a `FHE.reinterpret_precision` operation belongs.

This commit removes the early exit in `FunctionToDag::addOperation`
for the handling of `FHE.reinterpret_precision` that prevented the
code assigning the optimizer ID from being executed.
2024-03-06 14:50:27 +01:00
Bourgerie Quentin
7651cb1129 fix(compiler): Guard decompression of seeded keys to avoid access conflicts in parallel programs 2024-03-06 14:43:40 +01:00
Alexandre Péré
9b5a2e46da feat(compiler): support multi-circuit compilation 2024-03-01 15:35:52 +01:00
Antoniu Pop
bda568ab6b feat(compiler): distributed execution - on-demand key transfer to remote nodes. 2024-02-23 13:55:52 +00:00
Antoniu Pop
da1f30023f feat(compiler): upgrade HPX library version to 1.9.1. 2024-02-23 10:31:18 +00:00
Umut
29503dfc17 feat(compiler): fusing table lookups 2024-02-20 12:39:57 +01:00
Bourgerie Quentin
22bbdec086 fix(ci/compiler): Remove KeySetCache directory on mac os CI to avoid space disk issues 2024-02-20 09:17:13 +01:00
Alexandre Péré
c53985f112 fix(compiler): fix double free on aliased outputs 2024-02-19 16:14:12 +01:00
Alexandre Péré
d1b62462f2 fix(compiler): fix mac arm exception propagation
On Mac arm, the c api backing the python bindings does not propagate the
exceptions properly to the concretelang python module. This makes all
exceptions raised through `CompilerEngine.cpp` fall in the catch-all
case of the pybind exceptions handler.

Since there is no particular need for a public c api, we just remove it
from the bindings, and move all the content of `CompilerEngine.cpp`
directly in the `CompilerAPIModule.cpp` file.
2024-02-14 15:08:19 +01:00
Bourgerie Quentin
ebea2e3cae chore(ci): Reduce number of compiler test for macos 2024-02-13 17:02:46 +01:00
Bourgerie Quentin
7c3e4388aa chore(ci): Use a stable version of the nightly rust toolchain for concrete-cpu build 2024-02-13 17:02:46 +01:00
rudy
86e88443fc feat(optimizer): accept high precision weight 2024-02-08 17:53:23 +01:00
Andi Drebes
972eb962ee test(compiler): Add check tests for type inference
Add various check tests for type inference testing forward and
backward propagation, including propagation into nested regions.
2024-02-01 16:18:45 +01:00
Andi Drebes
21a7eead6c refactor(compiler): Re-implement TFHE multi-parameter parametrization with type inference
The current pass applying the parameters determined by the optimizer
to the IR propagates the parametrized TFHE types to operations not
directly tagged with an optimizer ID only under certain conditions. In
particular, it does not always properly propagate types into nested
regions (e.g., of `scf.for` loops).

This burdens preceding transformations that are applied in between the
invocation of the optimizer and the parametrization pass with
data-flow analysis and book-keeping in order to tag newly inserted
operations with the right optimizer IDs that ensure proper
parametrization.

This commit replaces the current parametrization pass with a new pass
that propagates parametrized TFHE types up and down def-use chains
using type inference and a proper rewriter. The pass is limited to the
operations supported by `TFHEParametrizationTypeResolver::resolve`.
2024-02-01 16:18:45 +01:00
Andi Drebes
775171c69d fix(compiler): Run canonicalizer after TFHE circuit parametrization
In order to avoid leftover TFHE operations to be lowered further down
the pipeline after parametrization, run the canonicalizer, which
includes dead code eliminiation.
2024-02-01 16:18:45 +01:00
Andi Drebes
bc171dde82 test(compiler): Run canonicalizer in TFHE parametrization tests 2024-02-01 16:18:45 +01:00
Andi Drebes
79d8337026 feat(compiler): Add support for batched keyswitch ops in TFHE key normalization 2024-02-01 16:18:45 +01:00
Andi Drebes
1faeb2d10d feat(compiler): Add rewriter applying the results from type inference
This adds the `TypeInferenceRewriter` class, which applies the results
for type inference obtained from the state of a `DataFlowSolver` and
from a final invocation of a type resolver to a module.
2024-02-01 16:18:45 +01:00
Andi Drebes
43180a70be feat(compiler): Add infrastructure for type inference
Type inference is implemented through the two classes
`ForwardTypeInferenceAnalysis` and `BackwardTypeInferenceAnalysis`,
which can be used as forward and backward dataflow analyses with the
MLIR sparse dataflow analysis framework.

Both classes rely on a type resolver, which must be a class inheriting
`TypeResolver` and that specifies which types are to be considered as
unresolved and that resolves the actual types for the values related
to an operation based on the previous state of type inference.

The type inference state for an operation is represented by an
instance of the class `LocalInferenceState`, which maps the values
related to an operation to instances of `InferredType` (either
indicating the inferred type as an `mlir::Type` or indicating that no
type has been inferred, yet).

The local type inference by a type resolver can be implemented with
type constraints (instances of sub-classes of `TypeConstraint`), which
can be combined into a `TypeConstraintSet`. The latter provides a
function that attempts to apply the constraints until the resulting
type inference state converges.

There are multiple, predefined type constraint classes for common
constraints (e.g., if two values must have the same type or the same
element type). These exist both as static constraints and as dynamic
constraints. Some pre-defined type constraints depend on a class that
yields a pair of values for which the contraints shall be applied
(e.g., yielding two operands or an operand and a result, etc.).
2024-02-01 16:18:45 +01:00
Andi Drebes
e78883cc24 feat(compiler): Add a dialect for type inference debugging
The `TypeInference` dialect provides three operations.

The operation `TypeInference.propagate_downwards` respresents a type
barrier, which is supposed to forward the type of its operand as its
result type during type inference.

The operation `TypeInference.propagate_upwards` also respresents a
type barrier, but is supposed to forward the type of its result as the
type for its operand during type inference.

The operation `TypeInference.unresolved_conflict` can be used as a
marker when two different types have beed inferred for a value (e.g.,
one type during forward dataflow analysis and the other during
backward dataflow analysis)
2024-02-01 16:18:45 +01:00
Andi Drebes
8b1c6ab034 fix(compiler): Fix typos in the summaries of batched TFHE ops 2024-02-01 16:18:45 +01:00
Andi Drebes
8d71dc2028 feat(compiler): Add verifier to TFHE.encode_expand_lut_for_bootstrap 2024-01-29 15:35:14 +01:00
Andi Drebes
ea07239732 feat(compiler): Add verifiers to TFHE bootstrap operations 2024-01-29 15:35:10 +01:00
Andi Drebes
a133407035 test(compiler): Fix the size of lookup tables used in tests with bootstrap operations
Some of the tests use lookup tables whose numbers of elements do not
match the sizes of the polynoms of the bootstrap operations they are
passed to. This commit replaces these lookup tables with tables of the
right size.
2024-01-29 15:28:49 +01:00
Alexandre Péré
f113e8bcfe fix(ci): fix the doc verification 2024-01-26 17:15:03 +01:00
Alexandre Péré
a02bf3bae9 fix(optimizer): compiler output forwarding
In the optimizer, nodes without consumers are identified as outputs.
Since we can now return multiple values, this is inherently buggy,
since a value can then be both returned, and consumed to create another
input.

This commit fixes this by allowing the compiler to tag nodes as being
outputs.
2024-01-26 17:15:03 +01:00
Alexandre Péré
9beb98c141 chore(optimizer): allow debug mode compilation 2024-01-22 15:54:02 +01:00
Alexandre Péré
4df041c399 chore(optimizer): fix new nightly lints 2024-01-18 14:03:35 +01:00
Alexandre Péré
75d33d4f94 fix(optimizer): enhance error reported on non-composability 2024-01-18 14:03:35 +01:00
Alexandre Péré
2746bda27e chore(optimizer): add dot partitioning visualization 2024-01-18 14:03:35 +01:00
Alexandre Péré
52427d129b fix(optimizer): add test for composition with 3 partitions 2024-01-18 14:03:35 +01:00
Alexandre Péré
939ae72292 fix(optimizer): allow composability of input only circuits 2024-01-18 14:03:35 +01:00
rudy
cd390b02dc fix(optimizer): do not mix lsb and tlu-0bits from round 2024-01-15 14:42:25 +01:00
Bourgerie Quentin
c438fb21d0 fix(compiler/benchamrk): Fix command line for compilation options of e2e tools 2024-01-09 12:40:31 +01:00