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

feat: expose statuses to compile torch #261

Merged

Conversation

fd0r
Copy link
Collaborator

@fd0r fd0r commented Sep 20, 2023

No description provided.

@cla-bot cla-bot bot added the cla-signed label Sep 20, 2023
@fd0r fd0r force-pushed the 3829-add-encryption-status-per-input-in-compile_torch_model branch from 137570e to 02d8c10 Compare September 20, 2023 15:09
@fd0r fd0r marked this pull request as ready for review September 20, 2023 18:43
@fd0r fd0r requested a review from a team as a code owner September 20, 2023 18:43
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 for this ! I have a few comments

Copy link
Collaborator

@jfrery jfrery left a comment

Choose a reason for hiding this comment

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

This could be needed indeed thanks!

@@ -577,6 +577,7 @@ def compile(
p_error: Optional[float] = None,
global_p_error: Optional[float] = None,
verbose: bool = False,
statuses: Optional[Dict[str, str]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't feel like statuses is very talkative. Should be referring to the input I think. input_statuses or input_encryption where the user passes booleans in a list following the order of the input in the forward call? so that you don't have to specify onnx node names.

@fd0r fd0r marked this pull request as draft September 21, 2023 11:07
@fd0r fd0r force-pushed the 3829-add-encryption-status-per-input-in-compile_torch_model branch 3 times, most recently from 1b48bff to 782f399 Compare September 21, 2023 17:21
@fd0r fd0r marked this pull request as ready for review September 21, 2023 17:39
@fd0r
Copy link
Collaborator Author

fd0r commented Sep 21, 2023

Looks like KNN test is flaky

jfrery
jfrery previously approved these changes Sep 22, 2023
Copy link
Collaborator

@jfrery jfrery left a comment

Choose a reason for hiding this comment

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

Looks great thanks!

@fd0r
Copy link
Collaborator Author

fd0r commented Sep 22, 2023

What I did:

  • changed the name of the variable to a more explicit naming.
  • updated the doc-strings to something clearer.
  • added match= to the tests
  • changed the type of the variable from a dict to a list to avoid having to handle onnx names

@@ -598,9 +599,15 @@ def compile(
error to a default value.
verbose (bool): Indicate if compilation information should be printed
during compilation. Default to False.
inputs_encryption_status (Optional[Sequence[str]]): encryption status ('clear',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would still mention that everything is encrypted if the parameter is set to None !

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's mentionned in all the user facing APIs, I don't think many users will use this one tbh

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean it was mostly for making the docstring consistent with what this parameters does, as we now provide a way to chose what inputs to encrypt, to avoid confusion that we don't chose which ones are encrypted or not based on whatever other rules. But sure if no one else pushes for this then go for it

@@ -142,6 +143,8 @@ def _compile_torch_or_onnx_model(
global_p_error (Optional[float]): probability of error of the full circuit. In FHE
simulation `global_p_error` is set to 0
verbose (bool): whether to show compilation information
inputs_encryption_status (Optional[Sequence[str]]): encryption status ('clear', 'encrypted')
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same what? There is a comment on the fact that by default everything is encrypted

Copy link
Collaborator

Choose a reason for hiding this comment

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

same as in "same comment as above" in order to not avoid making changes in both places if there are some

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.

I still have a few comments

@fd0r fd0r force-pushed the 3829-add-encryption-status-per-input-in-compile_torch_model branch from 782f399 to f962849 Compare September 22, 2023 09:28
@fd0r
Copy link
Collaborator Author

fd0r commented Sep 22, 2023

Adressed the feedback made by @RomanBredehoft

@fd0r
Copy link
Collaborator Author

fd0r commented Sep 22, 2023

KNN flaky, relaunching

@fd0r fd0r requested a review from RomanBredehoft September 22, 2023 11:28
@fd0r fd0r force-pushed the 3829-add-encryption-status-per-input-in-compile_torch_model branch from f962849 to 8346a08 Compare September 22, 2023 11:42

Returns:
Circuit: The compiled Circuit.

Raises:
ValueError: if inputs_encryption_status does not match with the
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's a bit more than that right ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well it's if the configuration is wrong, how would you formulate it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would usually very quickly describe what are bad configurations

@github-actions
Copy link

Coverage passed ✅

Coverage details

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

51 files skipped due to complete coverage.

@fd0r fd0r requested a review from RomanBredehoft September 22, 2023 14:31
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.

if no one pushes for these last comments, fine for me, thanks a lot for this feature !

@fd0r fd0r merged commit 8abddf6 into main Sep 25, 2023
@fd0r fd0r deleted the 3829-add-encryption-status-per-input-in-compile_torch_model branch September 25, 2023 08:08
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.

4 participants