-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve explicit optimizer partition frontiers for TFHE circuit parametrization #702
Conversation
e029d59
to
efe7c7e
Compare
efe7c7e
to
670b95e
Compare
670b95e
to
156e622
Compare
@slab-ci concrete-python-tests-linux |
...oncrete-compiler/compiler/lib/Dialect/TFHE/Transforms/TFHECircuitSolutionParametrization.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please split that in several PR next time, even if all other commits are small.
Agreed that this diverts the focus from the actual commit fixing the parametrization pass by submerging it in CI fixes. The idea was to give the CI a chance to complete for the review and then to rebase the commits to main once the CI fixes are merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow our online discussion the following case is not handled as you don't find the extra keyswitch as ancestor due of loop nest
func.func @main(%arg0: tensor<2x!FHE.eint<1>>, %arg1: tensor<2x!FHE.eint<7>>) -> (tensor<2x!FHE.eint<8>>, tensor<2x!FHE.eint<5>>) {
%cst = arith.constant dense<[0, 1]> : tensor<2xi64>
%0 = "FHELinalg.apply_lookup_table"(%arg0, %cst) : (tensor<2x!FHE.eint<1>>, tensor<2xi64>) -> tensor<2x!FHE.eint<8>>
%cst_0 = arith.constant dense<0> : tensor<128xi64>
%1 = "FHELinalg.apply_lookup_table"(%arg1, %cst_0) : (tensor<2x!FHE.eint<7>>, tensor<128xi64>) -> tensor<2x!FHE.eint<8>>
%2 = "FHELinalg.add_eint"(%0, %1) : (tensor<2x!FHE.eint<8>>, tensor<2x!FHE.eint<8>>) -> tensor<2x!FHE.eint<8>>
%c4_i4 = arith.constant 4 : i4
%cst_1 = arith.constant dense<0> : tensor<256xi64>
%3 = "FHELinalg.apply_lookup_table"(%1, %cst_1) : (tensor<2x!FHE.eint<8>>, tensor<256xi64>) -> tensor<2x!FHE.eint<5>>
return %2, %3 : tensor<2x!FHE.eint<8>>, tensor<2x!FHE.eint<5>>
}
got assertion
concretecompiler: /home/yundsi/code/concrete/compilers/concrete-compiler/compiler/lib/Dialect/TFHE/Transforms/TFHECircuitSolutionParametrization.cpp:150: const concrete_optimizer::dag::ConversionKeySwitchKey& mlir::concretelang::{anonymous}::CircuitSolutionWrapper::lookupConversionKeyswitchKey(uint64_t, uint64_t) const: Assertion `convKSKIt != solution.circuit_keys.conversion_keyswitch_keys.cend() && "Required conversion key must be available"' failed.
Aborted (core dumped)
156e622
to
b9fcf6a
Compare
Updated this to include explicit optimizer partition frontiers. |
965b02e
to
f8ec3f4
Compare
54384a1
to
9de637b
Compare
@slab-ci concrete-python-tests-linux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be great to add the example that I spotted (same as 538 but with linalg ops) and remove skipping of min max test in concrete python test.
name.endswith("xfail_if_multi")
and configuration.parameter_selection_strategy == fhe.ParameterSelectionStrategy.MULTI
)
if can_be_known_failure:
pytest.skip(
reason="Compiler parametrization pass make the compilation fail with an assertion"
)
compilers/concrete-compiler/compiler/lib/Dialect/FHE/Transforms/Optimizer.cpp
Outdated
Show resolved
Hide resolved
compilers/concrete-compiler/compiler/lib/Transforms/PreBufferization.cpp
Outdated
Show resolved
Hide resolved
b66979c
to
86c327e
Compare
@slab-ci concrete-python-tests-linux |
a45f265
to
151c394
Compare
@slab-ci concrete-python-tests-linux |
71f2701
to
763fb84
Compare
…erenceUtils The main debugging function is `TypeInferenceUtils::dumpAllState(mlir::Operation* op)` which dumps the entire state of type inference for the function containing `op`.
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).
11cddff
to
fbc18a6
Compare
…gh 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.
fbc18a6
to
3219929
Compare
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 util the pipeline reaches a
representation of the program in the lower-level TFHE dialect. Various
transformation applied by the pipeline along the way may break the
one-to-one mapping and add indirections into producer-consumer
relationships, resulting in abiguous 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 tokeyswitch operations before parametrization of TFHE operations.
Resolves Issue #538.