From 3a8dca0b63fd02e5f44bc442e433bc97bb503fc7 Mon Sep 17 00:00:00 2001 From: Andrei Stoian Date: Thu, 13 Jun 2024 09:45:50 +0200 Subject: [PATCH] fix: add test without key compression --- tests/deployment/test_client_server.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/deployment/test_client_server.py b/tests/deployment/test_client_server.py index c14e64aea..dfd4bc821 100644 --- a/tests/deployment/test_client_server.py +++ b/tests/deployment/test_client_server.py @@ -119,10 +119,25 @@ def test_client_server_sklearn_inference( max_bit_width = fhe_circuit.graph.maximum_integer_bit_width() print(f"Max width {max_bit_width}") - # Compare the FHE predictions with the clear ones. Simulated predictions are not considered in - # this test. + # Check that key compression is enabled + assert os.environ.get("USE_KEY_COMPRESSION") == "1", "'USE_KEY_COMPRESSION' is not enabled" + + # Check with key compression check_is_good_execution_for_cml_vs_circuit(x_test, model, simulate=False, n_allowed_runs=1) + # Check without key compression + with pytest.MonkeyPatch.context() as mp_context: + + # Disable input ciphertext compression + mp_context.setenv("USE_KEY_COMPRESSION", "0") + + # Check that input ciphertext compression is disabled + assert os.environ.get("USE_KEY_COMPRESSION") == "0", "'USE_KEY_COMPRESSION' is not disabled" + + # Compare the FHE predictions with the clear ones. Simulated predictions are not + # considered in this test. + check_is_good_execution_for_cml_vs_circuit(x_test, model, simulate=False, n_allowed_runs=1) + # Check client/server FHE predictions vs the FHE predictions of the dev model check_client_server_inference( x_test, model, key_dir, check_array_equal, check_float_array_equal