From b742ac35ae507af2121144f0b88e749cd3664004 Mon Sep 17 00:00:00 2001 From: rudy Date: Fri, 2 Dec 2022 16:41:15 +0100 Subject: [PATCH] fix(ci): force crt for 9, 10, 11 for table lookup --- .github/workflows/continuous-integration.yml | 4 ++-- compiler/Makefile | 2 +- .../tests/end_to_end_fixture/EndToEndFixture.cpp | 12 ++++++++++++ compiler/tests/end_to_end_fixture/EndToEndFixture.h | 1 + .../end_to_end_apply_lookup_table_gen.py | 3 +++ .../end_to_end_linalg_apply_lookup_table_gen.py | 3 +++ compiler/tests/end_to_end_tests/end_to_end_test.cc | 1 + 7 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 00bada03b..a55a5b85a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -165,7 +165,7 @@ jobs: if: ${{ github.ref == 'refs/heads/main' }} uses: actions/upload-artifact@v3 with: - name: KeySetCacheV3 + name: KeySetCaCheV4 path: KeySetCache retention-days: 90 @@ -173,7 +173,7 @@ jobs: uses: Remagpie/gha-remove-artifact@v1 if: ${{ github.ref == 'refs/heads/main' }} with: - only-name: KeySetCacheV3 + only-name: KeySetCaCheV4 max-count: 1 - name: Build the documentation diff --git a/compiler/Makefile b/compiler/Makefile index f53ca4240..052dd614b 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -16,7 +16,7 @@ CONCRETE_OPTIMIZER_DIR ?= $(shell pwd)/concrete-optimizer KEYSETCACHEDEV=/tmp/KeySetCache KEYSETCACHECI ?= ../KeySetCache -KEYSETCACHENAME ?= KeySetCacheV3 +KEYSETCACHENAME ?= KeySetCacheV4 HPX_VERSION?=1.7.1 HPX_URL=https://github.com/STEllAR-GROUP/hpx/archive/refs/tags/$(HPX_VERSION).tar.gz diff --git a/compiler/tests/end_to_end_fixture/EndToEndFixture.cpp b/compiler/tests/end_to_end_fixture/EndToEndFixture.cpp index ab8bf6618..96931ff96 100644 --- a/compiler/tests/end_to_end_fixture/EndToEndFixture.cpp +++ b/compiler/tests/end_to_end_fixture/EndToEndFixture.cpp @@ -337,6 +337,18 @@ template <> struct llvm::yaml::MappingTraits { desc.v0Constraint->p = v0constraint[0]; desc.v0Constraint->norm2 = v0constraint[1]; } + std::string str_encoding = "auto"; + io.mapOptional("encoding", str_encoding); + if (str_encoding == "auto") { + desc.encoding = concrete_optimizer::Encoding::Auto; + } else if (str_encoding == "native") { + desc.encoding = concrete_optimizer::Encoding::Native; + } else if (str_encoding == "crt") { + desc.encoding = concrete_optimizer::Encoding::Crt; + } else { + io.setError("encoding can only be native or crt"); + } + mlir::concretelang::LargeIntegerParameter largeInterger; io.mapOptional("large-integer-crt-decomposition", largeInterger.crtDecomposition); diff --git a/compiler/tests/end_to_end_fixture/EndToEndFixture.h b/compiler/tests/end_to_end_fixture/EndToEndFixture.h index 362d39667..771e85c7b 100644 --- a/compiler/tests/end_to_end_fixture/EndToEndFixture.h +++ b/compiler/tests/end_to_end_fixture/EndToEndFixture.h @@ -51,6 +51,7 @@ struct EndToEndDesc { std::vector tests; llvm::Optional v0Parameter; llvm::Optional v0Constraint; + concrete_optimizer::Encoding encoding; llvm::Optional largeIntegerParameter; std::vector test_error_rates; diff --git a/compiler/tests/end_to_end_fixture/end_to_end_apply_lookup_table_gen.py b/compiler/tests/end_to_end_fixture/end_to_end_apply_lookup_table_gen.py index 9093682a4..46178cc8f 100644 --- a/compiler/tests/end_to_end_fixture/end_to_end_apply_lookup_table_gen.py +++ b/compiler/tests/end_to_end_fixture/end_to_end_apply_lookup_table_gen.py @@ -6,6 +6,7 @@ import argparse MIN_PRECISON = 1 MAX_PRECISION = 16 +PRECISION_FORCE_CRT = 9 def generate(args): print("# /!\ DO NOT EDIT MANUALLY THIS FILE MANUALLY") @@ -23,6 +24,8 @@ def generate(args): f" %1 = \"FHE.apply_lookup_table\"(%arg0, %tlu): (!FHE.eint<{p}>, tensor<{2**p}xi64>) -> (!FHE.eint<{p}>)") print(f" return %1: !FHE.eint<{p}>") print(" }") + if p >= PRECISION_FORCE_CRT: + print("encoding: crt") print("tests:") print(" - inputs:") print(" - scalar: 0") diff --git a/compiler/tests/end_to_end_fixture/end_to_end_linalg_apply_lookup_table_gen.py b/compiler/tests/end_to_end_fixture/end_to_end_linalg_apply_lookup_table_gen.py index 4582d7386..8cf4b4d72 100644 --- a/compiler/tests/end_to_end_fixture/end_to_end_linalg_apply_lookup_table_gen.py +++ b/compiler/tests/end_to_end_fixture/end_to_end_linalg_apply_lookup_table_gen.py @@ -2,6 +2,7 @@ from platform import mac_ver import numpy as np import argparse +PRECISION_FORCE_CRT = 9 def generate(args): print("# /!\ DO NOT EDIT MANUALLY THIS FILE MANUALLY") @@ -23,6 +24,8 @@ def generate(args): print(f" (tensor<{n_ct}x!FHE.eint<{p}>>, tensor<{2**p}xi64>) -> (tensor<{n_ct}x!FHE.eint<{p}>>)") print(f" return %{n_lut}: tensor<{n_ct}x!FHE.eint<{p}>>") print(" }") + if p >= PRECISION_FORCE_CRT: + print("encoding: crt") random_input = np.random.randint(max_value+1, size=n_ct) print("tests:") print(" - inputs:") diff --git a/compiler/tests/end_to_end_tests/end_to_end_test.cc b/compiler/tests/end_to_end_tests/end_to_end_test.cc index 6885df7fa..c3bbc290f 100644 --- a/compiler/tests/end_to_end_tests/end_to_end_test.cc +++ b/compiler/tests/end_to_end_tests/end_to_end_test.cc @@ -185,6 +185,7 @@ void registerEndToEnd(std::string suiteName, std::string libpath, if (desc.v0Constraint.hasValue()) { options.v0FHEConstraints = desc.v0Constraint; } + options.optimizerConfig.encoding = desc.encoding; auto i = 0; for (auto test : desc.tests) { auto valueName = std::to_string(i);