Skip to content

Commit

Permalink
chore(frontend-python): levenshtein with parallelization
Browse files Browse the repository at this point in the history
  • Loading branch information
rudy-6-4 committed Jul 30, 2024
1 parent f01c7a8 commit 66b3dcc
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,23 @@ 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(
{
"char_cost_align": inputset_char_cost_align,
"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):
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 66b3dcc

Please sign in to comment.