Skip to content
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

fix: key compression always #726

Merged
merged 6 commits into from
Jun 13, 2024
Merged

Conversation

andrei-stoian-zama
Copy link
Collaborator

@andrei-stoian-zama andrei-stoian-zama commented Jun 12, 2024

Enable key compression for all models

@andrei-stoian-zama andrei-stoian-zama requested a review from a team as a code owner June 12, 2024 10:13
@cla-bot cla-bot bot added the cla-signed label Jun 12, 2024
@@ -347,7 +347,7 @@ def _get_training_quantized_module(
# Enable the underlying FHE circuit to be composed with itself
# This feature is used in order to be able to iterate in the clear n times without having
# to encrypt/decrypt the weight/bias values between each loop
configuration = Configuration(composable=True)
configuration = Configuration(composable=True, compress_evaluation_keys=True)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compress pbs keys for training

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which makes me thinkg, it should be using enable_input_compression as well here !

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you're right, same as for DF which was not enabled before

Copy link
Collaborator

@RomanBredehoft RomanBredehoft Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually same as below, we should probably revert this change : it's enabled by QM's compilation anyway, so it's a bit confusing to add it here

DF is different because it directly compiles with CP tho yes

@@ -40,6 +40,8 @@ def run_hybrid_llm_test(
# Multi-parameter strategy is used in order to speed-up the FHE executions
configuration = Configuration(
single_precision=False,
compress_input_ciphertexts=True,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these circuits can be fully leveled or not, always good to test with default compilation parameters

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so why not also enabling key compression ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is enabled by the QM compilation (the env variable defaults to 1)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so is compress_input_ciphertexts then right ? imo either we put both here or we revert this small change 🤔

@@ -120,6 +122,8 @@ def function_to_compile(x):
enable_unsafe_features=is_fast,
use_insecure_key_cache=is_fast,
insecure_key_cache_location=keyring_dir_as_str,
compress_input_ciphertexts=True,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sanity checks should run with default compile parameters

conftest.py Outdated
@@ -173,6 +174,7 @@ def simulation_configuration():
fhe_simulation=True,
fhe_execution=False,
compress_input_ciphertexts=os.environ.get("USE_INPUT_COMPRESSION", "1") == "1",
compress_eval_keys=True,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests should use the default for compressed keys, which is True

Copy link
Collaborator

@RomanBredehoft RomanBredehoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo we shouldn't force it like this but do like for input compression, meaning we use env variables. The main reason is that forcing it like this makes it impossible to disable it for tests or other things through input configuration objects. Basically this is what I reverted for fhe/simu exec in #724 (which is going to conflict a bit with your PR btw)

additionally we probably want to add tests to make sure that the compression properly works, like we did for input compression

@andrei-stoian-zama andrei-stoian-zama force-pushed the fix/compress_keys_always branch from 0b7e4e4 to 3a8dca0 Compare June 13, 2024 11:33
Copy link
Collaborator

@RomanBredehoft RomanBredehoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks !! I think we could add a few small things in a follow up PR

Copy link

Coverage passed ✅

Coverage details

---------- coverage: platform linux, python 3.8.18-final-0 -----------
Name    Stmts   Miss  Cover   Missing
-------------------------------------
TOTAL    7881      0   100%

60 files skipped due to complete coverage.

@andrei-stoian-zama andrei-stoian-zama merged commit b4e1060 into main Jun 13, 2024
12 checks passed
@andrei-stoian-zama andrei-stoian-zama deleted the fix/compress_keys_always branch June 13, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants