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

Openfhe: get mulDepth from LWE type #1189

Conversation

ZenithalHourlyRate
Copy link
Collaborator

@ZenithalHourlyRate ZenithalHourlyRate commented Dec 14, 2024

Related to #1145. This is a step towards a generic configuring crypto context pass, as the Lattigo backend also needs one.

Since we have RNS lowering for secret-to-, we can get mulDepth from LWE type.

Still marked as draft as the CKKS RNS lowering has not landed. All tests working when merged with #1176

Several changes

  • hasMulOp becomes hasRelinOp as we actually does not emit openfhe.mul (implicit relin)
  • the configure_crypto_context_complex.mlir removed scf.if and used arith.add instead, as
    • we can not lower correctly through a plaintext scf.if for now
    • for oblivious if, arith.select also does not have a lowering

@ZenithalHourlyRate ZenithalHourlyRate force-pushed the openfhe-configure-crypto-context branch 2 times, most recently from e245811 to a8a52f3 Compare December 16, 2024 16:14
@ZenithalHourlyRate ZenithalHourlyRate marked this pull request as ready for review December 16, 2024 16:14
@ZenithalHourlyRate
Copy link
Collaborator Author

Rebased and Marked as ready since #1176 merged.

}

// CHECK: @complex_func
// CHECK: @complex_func__generate_crypto_context
// CHECK: mulDepth = 3
// CHECK: mulDepth = 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just for confirmation: this is 2 now because of the inclusion of the optimal relin insertion pass (or rather, the maximum constraint within that pass that prevents going to depth 3).

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 due to operation-balancer.

Without them we get mulDepth 3 but with them (--secretize --wrap-generic --cse --canonicalize --operation-balancer --secret-insert-mgmt-bgv --secret-distribute-generic --secret-to-bgv=poly-mod-degree=32 --openfhe-configure-crypto-context=entry-function=complex_func) we get mulDepth 2.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I put the detailed flag in the test so we still get mulDepth = 3. Otherwise it is too confusing.

@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Dec 16, 2024
@ZenithalHourlyRate
Copy link
Collaborator Author

Oh this one should wait until #1190

@ZenithalHourlyRate ZenithalHourlyRate marked this pull request as draft December 16, 2024 20:57
@j2kun j2kun removed the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Dec 16, 2024
@ZenithalHourlyRate ZenithalHourlyRate force-pushed the openfhe-configure-crypto-context branch from a8a52f3 to f77a913 Compare December 16, 2024 21:16
@ZenithalHourlyRate ZenithalHourlyRate force-pushed the openfhe-configure-crypto-context branch from f77a913 to ca9b464 Compare December 16, 2024 22:31
@ZenithalHourlyRate ZenithalHourlyRate marked this pull request as ready for review December 16, 2024 22:31
@ZenithalHourlyRate
Copy link
Collaborator Author

Rebased and ready now.

Copy link
Collaborator

@AlexanderViand-Intel AlexanderViand-Intel left a comment

Choose a reason for hiding this comment

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

LGTM👍, just a few questions/thoughts (that shouldn't stand in the way of merging this)

@AlexanderViand-Intel AlexanderViand-Intel added pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing dialect: openfhe Issues related to the openfhe dialect labels Dec 16, 2024
@copybara-service copybara-service bot merged commit 8ba7a63 into google:main Dec 16, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialect: openfhe Issues related to the openfhe dialect pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants