From 66b3dcc641f27b33c52fcbd69d58921c0ed74593 Mon Sep 17 00:00:00 2001 From: rudy Date: Mon, 29 Jul 2024 10:44:52 +0200 Subject: [PATCH] chore(frontend-python): levenshtein with parallelization --- .../levenshtein_distance/levenshtein_distance.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/frontends/concrete-python/examples/levenshtein_distance/levenshtein_distance.py b/frontends/concrete-python/examples/levenshtein_distance/levenshtein_distance.py index dd80004b00..9b5ffd11a3 100644 --- a/frontends/concrete-python/examples/levenshtein_distance/levenshtein_distance.py +++ b/frontends/concrete-python/examples/levenshtein_distance/levenshtein_distance.py @@ -166,6 +166,14 @@ def _compile_module(self, args): for _ in range(1000) ] + conf = fhe.Configuration( + enable_unsafe_features=True, + use_insecure_key_cache=True, + insecure_key_cache_location=".lev_keys", + min_max_strategy_preference=fhe.MinMaxStrategy.ONE_TLU_PROMOTED, + show_mlir=args.show_mlir, + show_optimizer=args.show_optimizer, + ) # pylint: disable-next=no-member self.module = LevenshsteinModule.compile( { @@ -173,10 +181,8 @@ def _compile_module(self, args): "min_cost": inputset_min_cost, "constant": [i for i in range(len(self.alphabet.mapping_to_int))], }, - show_mlir=args.show_mlir, - p_error=10**-20, - show_optimizer=args.show_optimizer, - min_max_strategy_preference=fhe.MinMaxStrategy.ONE_TLU_PROMOTED, + conf, + auto_schedule_run = True, ) def _compute_in_simulation(self, list_patterns: list): @@ -205,9 +211,9 @@ def _compute_in_fhe(self, list_patterns: list, show_distance: bool = False): time_begin = time.time() l1_fhe_enc = levenshtein_fhe(self.module, a_enc, b_enc) - time_end = time.time() l1_fhe = self.module.min_cost.decrypt(l1_fhe_enc) # type: ignore + time_end = time.time() l1_clear = levenshtein_clear(a, b)